mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
The runtime images send DDS to the host on Docker Desktop, but Zenoh would still dial 127.0.0.1 inside the container. Point it at the host router the same way, leaving an explicit PX4_ZENOH_LOCATOR untouched. Install rmw_zenoh_cpp in the ROS images so they can run the Zenoh router and talk to PX4 over Zenoh without extra setup. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
26 lines
894 B
Bash
26 lines
894 B
Bash
#!/bin/sh
|
|
# Docker entrypoint for PX4 SITL containers.
|
|
#
|
|
# On Docker Desktop (macOS/Windows), host.docker.internal resolves to the
|
|
# host machine. We detect this and configure MAVLink, DDS and Zenoh to send to
|
|
# the host IP instead of localhost (which stays inside the container VM).
|
|
#
|
|
# On Linux with --network host, host.docker.internal does not resolve and
|
|
# PX4 defaults work without modification.
|
|
|
|
set -e
|
|
|
|
. /usr/local/lib/px4/network.sh
|
|
|
|
if [ -n "$DOCKER_HOST_IP" ]; then
|
|
# Runtime-only images expect the DDS Agent on the host.
|
|
sed -i -E "s/(uxrce_dds_client start -t udp)( -h [^ ]+)?/\1 -h $DOCKER_HOST_IP/g" \
|
|
"$PX4_PREFIX/etc/init.d-posix/px4-rc.uxrce_dds"
|
|
# ...and the Zenoh router too, unless the user chose a locator.
|
|
if [ -z "$PX4_ZENOH_LOCATOR" ]; then
|
|
export PX4_ZENOH_LOCATOR="tcp/$DOCKER_HOST_IP:7447"
|
|
fi
|
|
fi
|
|
|
|
exec "$PX4_PREFIX/bin/px4" "$@"
|