Problems using navigation stack with multiple Turtlebots 2

asked 2022-01-10 04:25:45 -0500

camacar36 gravatar image

updated 2022-02-13 16:50:18 -0500

lucasw gravatar image

Hi! I am trying to launch two turtlebots in a world I created. The spawn seems to work correctly, but when I try to launch the navigation stack it doesnt work.

First, I have created a launch file for one turtlebot following the instructions given in https://answers.ros.org/question/2398... :

<?xml version="1.0" ?>

<launch>
    <arg name="robot_name"/>
    <arg name="init_pose"/>

    <node name="spawn_turtlebot_model" pkg="gazebo_ros" type="spawn_model" 
    args="$(arg init_pose) -unpause -urdf -param /robot_description -model $(arg robot_name)"/> <!-- launch-prefix="xterm -e ddd" /> -->


    <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
      <param name="publish_frequency" type="double" value="30.0" />
    </node>


    <!-- The odometry estimator, throttling, fake laser etc. go here -->
    <!-- All the stuff as from usual robot launch file -->

  <!-- Fake laser -->
    <node pkg="nodelet" type="nodelet" name="laserscan_nodelet_manager" args="manager"/>
    <node pkg="nodelet" type="nodelet" name="depthimage_to_laserscan"
          args="load depthimage_to_laserscan/DepthImageToLaserScanNodelet laserscan_nodelet_manager">
      <param name="scan_height" value="10"/>
      <param name="output_frame_id" value="$(arg robot_name)/camera_depth_frame"/>
      <param name="range_min" value="0.45"/>
      <remap from="image" to="/$(arg robot_name)/camera/depth/image_raw"/>
      <remap from="scan" to="/$(arg robot_name)/scan"/>
    </node>
</launch>

Then the launch file where I add two Turtlebots:

<?xml version="1.0" ?>
    <launch>
      <arg name="base"      value="$(optenv TURTLEBOT_BASE kobuki)"/> <!-- create, roomba -->
      <arg name="battery"   value="$(optenv TURTLEBOT_BATTERY /proc/acpi/battery/BAT0)"/>  <!-- /proc/acpi/battery/BAT0 --> 
      <arg name="stacks"    value="$(optenv TURTLEBOT_STACKS hexagons)"/>  <!-- circles, hexagons --> 
      <arg name="3d_sensor" value="$(optenv TURTLEBOT_3D_SENSOR kinect)"/>  <!-- kinect, asus_xtion_pro --> 

      <!-- No namespace here as we will share this description. 
           Access with slash at the beginning -->
        <arg name="urdf_file" default="$(find xacro)/xacro '$(find turtlebot_description)/robots/$(arg base)_$(arg stacks)_$(arg 3d_sensor).urdf.xacro'"/>
        <param name="robot_description" command="$(arg urdf_file)"/>

      <!-- BEGIN ROBOT 1-->
      <group ns="player1">
        <param name="tf_prefix" value="player1_tf" />
        <include file="$(find turtlebot_gazebo)/launch/one_turtlebot.launch" >
          <arg name="init_pose" value="-x 0 -y 0 -z 0" />
          <arg name="robot_name"  value="player1" />
        </include>
      </group>

      <!-- BEGIN ROBOT 2 -->
      <group ns="player2">
        <param name="tf_prefix" value="player2_tf" />
        <include file="$(find turtlebot_gazebo)/launch/one_turtlebot.launch" >
          <arg name="init_pose" value="-x -1 -y 1 -z 0" />
          <arg name="robot_name"  value="player2" />
        </include>
      </group>

    </launch>

Finally I include this one to the main launch file where the world is launched:

<launch>
  <arg name="gui"        default="true"/>
  <arg name="world_file" default="$(find turtlebot_gazebo)/maps/turtlecup.sdf"/>

  <arg name="base"       value="$(optenv TURTLEBOT_BASE kobuki)"/> <!-- create, roomba -->
  <arg name="battery"    value="$(optenv TURTLEBOT_BATTERY /proc/acpi/battery/BAT0)"/>  <!-- /proc/acpi/battery/BAT0 -->
  <arg name="stacks"     value="$(optenv TURTLEBOT_STACKS hexagons)"/>  <!-- circles, hexagons -->
  <arg name="3d_sensor"  value="$(optenv TURTLEBOT_3D_SENSOR kinect)"/>  <!-- kinect, asus_xtion_pro -->

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg ...
(more)
edit retag flag offensive close merge delete