SITL with PX4 Firmware on Remote Machine

#1

Hello all,

I’m trying to create a test setup with Gazebo/MAVROS on one machine (machine alpha) and PX4 running on a second machine (machine beta). I have successfully separated the launch files so that I have two separate launch files that do exactly that. They work successfully when I run them on the same machine, but when I try to move the MAVROS/PX4 launch script to a separate machine there is never a connection made between the two machines. The simulator portion of the code gets stuck at :
INFO [simulator] Waiting for initial data on UDP port 14560. Please start the flight simulator to proceed..

Checking the machine running the Gazebo/MAVROS launch file with Wireshark, I can see that these packets are being produced and have destination 127.0.0.1:14560. I’m assuming I need to change something in the setup to get these packets sent to the correct IP? I’ve been hunting around trying to see where this setting might be, but have not been able to find it. Can anyone give me some direction in what I need to do to get this set up going?

I have set the ROS_MASTER_URI/GAZEBO_MASTER_URI to the IP of the machine running the Gazebo launch script with the ports 11311/11345 respectively. I have also set the ROS_IP on both machines to their own IP.

I have also attached the launch files I’m using below

To launch Gazebo/MAVROS I’m using this on machine alpha:
<?xml version="1.0"?> <launch> <!-- launches Gazebo environment, and spawns vehicle --> <!-- vehicle pose --> <arg name="x" default="0"/> <arg name="y" default="0"/> <arg name="z" default="0"/> <arg name="R" default="0"/> <arg name="P" default="0"/> <arg name="Y" default="0"/> <!-- vehicle model and world --> <arg name="est" default="ekf2"/> <arg name="vehicle" default="plane"/> <arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/empty.world"/> <arg name="sdf" default="$(find mavlink_sitl_gazebo)/models/$(arg vehicle)/$(arg vehicle).sdf"/> <!-- gazebo configs --> <arg name="gui" default="false"/> <arg name="debug" default="false"/> <arg name="verbose" default="false"/> <arg name="paused" default="false"/> <arg name="respawn_gazebo" default="false"/> <!-- Gazebo sim --> <include file="$(find gazebo_ros)/launch/empty_world.launch"> <arg name="gui" value="$(arg gui)"/> <arg name="world_name" value="$(arg world)"/> <arg name="debug" value="$(arg debug)"/> <arg name="verbose" value="$(arg verbose)"/> <arg name="paused" value="$(arg paused)"/> <arg name="respawn_gazebo" value="$(arg respawn_gazebo)"/> </include> <!-- gazebo model --> <node name="$(anon vehicle_spawn)" pkg="gazebo_ros" type="spawn_model" output="screen" args="-sdf -file $(arg sdf) -model $(arg vehicle) -x $(arg x) -y $(arg y) -z $(arg z) -R $(arg R) -P $(arg P) -Y $(arg Y)"/> <!-- MAVROS configs --> <!-- fcu_url is the IP / port of the computer running the simulation --> <arg name="fcu_url" default="udp://:14540@beta:14557"/> <arg name="respawn_mavros" default="false"/> <!-- MAVROS --> <include file="$(find mavros)/launch/px4.launch"> <!-- GCS link is provided by SITL --> <arg name="gcs_url" value=""/> <arg name="fcu_url" value="$(arg fcu_url)"/> <arg name="respawn_mavros" value="$(arg respawn_mavros)"/> </include> </launch>

To launch the PX4 Firmware I’m using this on machine beta:
<?xml version="1.0"?> <launch> <!-- launches PX4 SITL --> <!-- vehicle model and world --> <arg name="est" default="ekf2"/> <arg name="vehicle" default="plane"/> <arg name="rcS" default="$(find px4)/posix-configs/SITL/init/$(arg est)/$(arg vehicle)"/> <!-- PX4 configs --> <arg name="interactive" default="true"/> <!-- PX4 SITL --> <arg unless="$(arg interactive)" name="px4_command_arg1" value="-d"/> <arg if="$(arg interactive)" name="px4_command_arg1" value=""/> <node name="sitl" pkg="px4" type="px4" output="screen" args="$(find px4) $(arg rcS) $(arg px4_command_arg1)" required="true"/> </launch>

#2

I solved this by changing the <mavlink_addr> tag in the .sdf file for the model to specifically point to the machine running the PX4 firmware. This solution seems inelegant at best though. Is there a better way to do this?

#3

Can you post a link to the file where you changed it? Thanks.