I have been attempting to prepare my workspace for gazebo multi-vehicle simulation w/ ROS2 offboard control. The steps of launching multiple PX4 nodes talking to gazebo are causing trouble. Here is where I am now:
gazebo_sitl_multiple_run.sh -m iris -n 2 -w empty -t px4_sitl_rtps
( 2x iris model, empty default world, sitl_rtps target… everything appears to launch appropriately; console output and log files are fine )
micrortps_agent -t UDP -s 2019 -r 2020 -n iris0
micrortps_agent -t UDP -s 2021 -r 2022 -n iris1
( 2 micrortps agent instances; namespaced to match custom ROS2 offboard control nodes using matching namespaces )
On ROS2 side, topics /<vehicle_id>/VehicleOdometry_PubSubTopic for each vehicle_id in [iris0, iris1] are published appropriately. Affecting the corresponding gazebo iris models produces expected changes to odometry on that vehicle’s topic. Additionally, messages published to /iris0/TrajectorySetpoint_PubSubTopic, /iris0/OffboardControlMode_PubSubTopic and /iris0/VehicleCommand_PubSubTopic are received by PX4 and the simulated model responds accordingly (arms, takes off, transforms, etc). However, messages published to these topics within the iris1 namespace result in no response from that PX4 node.
Basically, PX4 → ROS2 is functional for all vehicles, but ROS2 → PX4 is functional for only the first vehicle, despite micrortps ports matching on agent and client ends.
During my attempted fixes, I examined build/px4_sitl_rtps/instance_/out.log files and found that for all instances other than 0, the micrortps_client failed to bind UDP transport. I traced the gazebo_sitl_multiple_run.sh script to the rcS script (build/px4_sitl_rtps/etc/init.d-posix/rcS) which starts the micrortps_client on line 232. I added the -r flag before the receive port argument, and lauching the PX4 nodes again showed that both micrortps_clients now bind to UDP transport successfully. Before this step, neither PX4 → ROS2 or ROS2 → PX4 worked for iris1 (note, it still worked fine for iris0). This step did fix PX4 → ROS2, but as mentioned earlier, ROS2 → PX4 still does not behave.
Any recommendations on how to proceed with this debugging are greatly appreciated. I will happily provide additional information if anyone feels that enough has not been proactively provided. Thanks all!