Launching multiple robots in gazebo (PX4 and non-PX4 robots/drones)

Hello there, been trying to make this work for a while now.

General idea:

  1. Launch a drone (typhoon) and a ground robot (turtlebot) in the same gazebo world
  2. Move the turtlebot in gazebo via keyboard teleop
  3. The drone would follow the turtlebot based on the FollowMe module

Im currently stuck at launching the typhoon and turtlebot in the same gazebo world!
I followed the documentation here and eddited my launch files as follows:

The multi_uav_mavros_sitl.launch:

<launch>

<!-- vehicle model and world -->
<arg name="est" default="ekf2"/>
<arg name="vehicle" default="iris"/>
<arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/empty.world"/>

<!-- gazebo configs -->
<arg name="gui" default="true"/>
<arg name="debug" default="false"/>
<arg name="verbose" default="false"/>
<arg name="paused" 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)"/>
</include>

<!-- UAV0 -->
<group ns="uav0">
    <!-- MAVROS and vehicle configs -->
    <arg name="ID" value="0"/>
    <arg name="fcu_url" default="udp://:14540@localhost:14580"/>
    <!-- PX4 SITL and vehicle spawn -->
    <include file="$(find px4)/launch/dev_single_vehicle_spawn.launch">
        <arg name="x" value="0"/>
        <arg name="y" value="0"/>
        <arg name="z" value="0"/>
        <arg name="R" value="0"/>
        <arg name="P" value="0"/>
        <arg name="Y" value="0"/>
        <arg name="vehicle" value="$(arg vehicle)"/>
        <arg name="mavlink_udp_port" value="14560"/>
        <arg name="mavlink_tcp_port" value="4560"/>
        <arg name="ID" value="$(arg ID)"/>
    </include>

    <!-- MAVROS -->
    <include file="$(find mavros)/launch/px4.launch">
        <arg name="fcu_url" value="$(arg fcu_url)"/>
        <arg name="gcs_url" value=""/>
        <arg name="tgt_system" value="$(eval 0 + arg('ID'))"/>
        <arg name="tgt_component" value="1"/>
    </include>
</group>


<group ns="turtlebot">
    <arg name="ID" value="1"/>
    <include file="$(find turtlebot3_gazebo)/launch/turtlebot3_empty_world.launch">
        <arg name="model" default="burger"/>
        <arg name="x_pos" default="1.0"/>
        <arg name="y_pos" default="0.0"/>
        <arg name="z_pos" default="0.0"/>
    </include>
</group>

The turtlebot3_empty_world.launch is edited as follows:

<launch>

<arg name="model" default="burger"/>
<arg name="x_pos" default="0.0"/>
<arg name="y_pos" default="0.0"/>
<arg name="z_pos" default="0.0"/>


<param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />

<node pkg="gazebo_ros" type="spawn_model" name="spawn_urdf" args="-urdf -model turtlebot3_$(arg model) -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" />
</launch>`

Both robots are spawned and im able to control/takeoff with the drone. However, the turtlebot is unresponsive to the keyboard teleop node, moreover as soon as it is spawned it just seems to go in circles at a steady and slow speed (with or without teleop)…

I was told here on github that i would need a seperate working directory as shown here #12482

  • If i understand #12482 correctly there should be a different working directory for each spawned vehicle, and to do that I have to add an argument as noted in this line <node name="sitl_$(arg ID)" pkg="px4" type="px4" output="screen" args="$(find px4)/ROMFS/px4fmu_common -s etc/init.d-posix/rcS -i $(arg ID) -w sitl_$(arg vehicle)_$(arg ID) $(arg px4_command_arg1)">
    in the launch/single_vehicle_spawn.launch file?

Moreover for the above to work, the changes for platforms/posix/src/main.cpp have to be pulled too?

  • As for the rCS file, I was under the impression that its needed only for other px4 vehicles? Since turtlebot is not using parameters such as mavlink_udp_port SITL_UDP_PRT fcu_url do i still need that rCS file? If so, then i need to include values of these parameters in the <group ns="turtlebot"> part of launch file?

Thanks for the feedback!

The namespace doesn’t signify anything as far as px4 is concerned. You need to understand the difference between the ROS side and the px4 side. I can elaborate more later, but essentially you need an rCS for the robot. On a basic level for what you care about, it sets up the communication on the px4 side. For this you could simply use the rover.