ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

multiple turtlebots simulation using gazebo problems [closed]

asked 2014-11-07 18:01:25 -0500

hjh gravatar image

Hi everyone. I am trying to simulate multiple turtlebots in the gazebo using turtlebot_simulator. I followed the answer here , and use gazebo to simulate the robots, use rviz to visualize data. I have 3 launch files as follows:

the main simulation launch file

   <!-- gazebo world start -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="use_sim_time" value="true"/>
    <arg name="debug" value="false"/>
    <arg name="world_name" value="$(find turtlebot_gazebo)/worlds/"/>
  <!-- include our robots -->
  <include file="$(find turtlebot_gazebo)/launch/robots.launch"/>

robots launch file

  <arg name="base"      value="$(optenv TURTLEBOT_BASE kobuki)"/> 
  <arg name="battery"   value="$(optenv TURTLEBOT_BATTERY /proc/acpi/battery/BAT0)"/>  
  <arg name="stacks"    value="$(optenv TURTLEBOT_STACKS hexagons)"/>  
  <arg name="3d_sensor" value="$(optenv TURTLEBOT_3D_SENSOR kinect)"/>

  <arg name="urdf_file" default="$(find 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="robot1">
    <arg name="robot_name" value="robot1"/>
    <param name="tf_prefix" value="$(arg robot_name)_tf" />
    <include file="$(find turtlebot_gazebo)/launch/one_robot.launch" >
      <arg name="init_pose" value="-x 1 -y 1 -z 0" />
      <arg name="robot_name" value="$(arg robot_name)"/>

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


each robot launch by this file

   <arg name="init_pose" />
  <arg name="robot_name" />
  <arg name="basefile" value="kobukis"/>

  <!--robot related params-->
  <include file="$(find turtlebot_gazebo)/launch/includes/$(arg basefile).launch.xml">
    <arg name="init_pose" value="$(arg init_pose)"/>
    <arg name="robot_name" value="$(arg robot_name)"/>

  <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher">
  <remap from="/$(arg robot_name)/joint_states" to="/joint_states"/>
    <param name="publish_frequency" type="double" value="30.0" />
    <param name="tf_prefix" type="string" value="$(arg robot_name)_tf"/>

  <!-- 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="/camera_depth_frame"/>
    <param name="range_min" value="0.45"/>
    <remap from="image" to="/camera/depth/image_raw"/>
    <remap from="scan" to="/scan"/>

robot spawn file

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

  <!-- Gazebo model spawner -->
  <node name="spawn_turtlebot_model" pkg="gazebo_ros" type="spawn_model"
        args="$(arg init_pose) -unpause -urdf -param /robot_description -model $(arg robot_name)_base">

  <!-- Velocity muxer -->
  <node pkg="nodelet" type="nodelet" name="mobile_base_nodelet_manager" args="manager"/>
  <node pkg="nodelet" type="nodelet" name="cmd_vel_mux"
        args="load yocs_cmd_vel_mux/CmdVelMuxNodelet mobile_base_nodelet_manager">
    <param name="yaml_cfg_file" value="$(find turtlebot_bringup)/param/mux.yaml" />
    <remap from="/$(arg robot_name)/cmd_vel_mux/output" to="/$(arg robot_name)_base/commands/velocity"/>


I can add two turtlebots into the gazebo however the topics are not similar to the tutorial.

in the tutorial, gazebo will publish data to the /joint_states topic and /joint_states topic will publish data to /robot_state_publisher which will finally publish data to /tf which is used in rviz for transform. it is like this:

/gazebo ------> /joint_states------>/robot_state_publisher------>/tf

however ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by hjh
close date 2014-11-18 08:54:22.523833

1 Answer

Sort by ยป oldest newest most voted

answered 2014-11-18 08:53:56 -0500

hjh gravatar image

problem solved according to this

edit flag offensive delete link more

Question Tools



Asked: 2014-11-07 18:01:25 -0500

Seen: 1,061 times

Last updated: Nov 18 '14