Supply mavros with dynamic sys id to ensure connection

This commit is contained in:
Youssof 2024-06-04 16:50:26 -03:00
parent 50c823c66c
commit 2534b048ca
2 changed files with 7 additions and 2 deletions

View File

@ -4,7 +4,7 @@ version: "3.8"
services:
mavros:
image: git.spirirobotics.com/spiri/services-ros1-mavros:master
command: roslaunch mavros px4.launch fcu_url:="udp://:14555@host.docker.internal:${MAVLINK_SIM_PORT:-14550}"
command: roslaunch mavros px4.launch fcu_url:="udp://:${MAVROS_SIM_FCU_PORT}@127.0.0.1:${MAVROS_SIM_GCS_PORT:-14557}" tgt_system:=${DRONE_SYS_ID:-1}
environment:
- "ROS_MASTER_URI=http://ros-master:${ROS_MASTER_PORT:-11311}"
depends_on:
@ -19,6 +19,9 @@ services:
nofile:
soft: 1024
hard: 524288
ports:
- "${MAVROS_SIM_FCU_PORT:-14540}:${MAVROS_SIM_FCU_PORT:-14540}/udp"
- "${MAVROS_SIM_GCS_PORT:-14557}:${MAVROS_SIM_GCS_PORT:-14557}/udp"
ros-master:
image: git.spirirobotics.com/spiri/services-ros1-core:main

View File

@ -112,7 +112,9 @@ def start(sys_id: int = 1):
PX4_GZ_MODEL_POSE=os.environ.get("PX4_GZ_MODEL_POSE") or f"0,{(sys_id-1)}",
PX4_INSTANCE="intance_id",
ROS_MASTER_PORT=str(11310 + sys_id),
MAVLINK_SIM_PORT=str(14549 + sys_id),
MAVROS_SIM_GCS_PORT=str(14556 + sys_id),
MAVROS_SIM_FCU_PORT=str(14539 + sys_id),
DRONE_SYS_ID=str(sys_id),
):
instance_id = sys_id - 1 # PX4 will add 1 to the instance ID to get sysID
px4Instance = px4(