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

How to move any 2 robots simultaneously in gazebo?

asked 2016-06-14 00:02:50 -0500

Pikachu gravatar image

I need to put any 2 robots in gazebo and keep them moving simultaneously in a fixed square path. I wanted to know which robot should I use and how should I command them to move? I am using ROS-Indigo with Gazebo-2.2.2 on Ubuntu 14.04.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-06-14 03:28:15 -0500

Orhan gravatar image

updated 2016-06-17 04:42:06 -0500

  1. If Your robot models and names are same, you need to cover in a namespace each of them. As far as I know, There is no tutorial exists for converting any robot's packege to namespaced one in indigo. I'll write later. But You can start by following this answer.

  2. If their models aren't same, Directly start from this 2nd section. (But I don't think so. Because everyone is naming topics by same way.) Just publish to their own velocity topics simultaneously. or You can use their own move_base topics to do it.

After following stages in the link above, You must create launch files before section 2 above. You need one gazebo process, sample launch file, world.launch;

<launch>
  <arg name="world"  default="milvus_repo"/>  
  <arg name="world_path" default="$(find mrp2_gazebo)/worlds/"/>             
  <arg name="gui" default="true"/>
  <arg name="debug" default="false"/>
  <arg name="paused" default="false"/>
  <env name="GAZEBO_MODEL_PATH" value="$(find mrp2_gazebo)/models:$(optenv GAZEBO_MODEL_PATH)" />

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(arg world_path)$(arg world).world"/>
    <arg name="gui" value="$(arg gui)"/>
    <arg name="debug" value="$(arg debug)"/>
    <arg name="paused" value="$(arg paused)"/>
  </include>
</launch>

Then start one of the robots with its namespace via robot1.launch;

<launch>
    <arg name="robot_name" default="robot1" />
    <group ns="$(arg robot_name)">
        <include file="$(find mrp2_gazebo)/launch/include/single_mrp2.launch" >
            <arg name="init_pose" value="-x 3.0 -y 0.0 -z 0.0 -R 0.0 -P 0.0 -Y 0.0" />
            <arg name="robot_name" value="$(arg robot_name)" />
        </include>
        <include file="$(find mrp2_control)/launch/controls.launch" >
            <arg name="robot_name" value="$(arg robot_name)" />
            <arg name="sim" value="true" />
        </include>
    </group>
</launch>

single_mrp2.launch contains mrp2.launch and some teleop and diagnostic launches. If you have a running robot without namespace, you probably have these ones. (And if you will use these ones in first try, some remapping operations may be needed in inside of them). mrp2.launch file:

<launch>
    <arg name="robot"  default="full"/>
    <arg name="gzpose" default=""/>
    <arg name="robot_name" default="robot1"/>
    <!-- PARSE ROBOT MODEL -->
    <include file="$(find mrp2_description)/launch/description.launch" >
        <arg name="robot" value="$(arg robot)"/>
        <arg name="robot_name" value="$(arg robot_name)"/>
    </include>
    <!-- SPAWN IN GAZEBO -->
    <node pkg="gazebo_ros" type="spawn_model" name="$(anon spawn_model)"
          args="-urdf -param robot_description $(arg gzpose) -model mrp2_$(arg robot_name)" />
    <remap from="odom" to="$(arg robot_name)/odom"/>
</launch>

Finally, here is the description file, also be sure the joints and frames are different, (You must edit your urdf files for this) description.launch;

<launch>
    <arg name="config" default="base" />
    <arg name="robot" default="full" />
    <arg name="robot_name" default="robot1"/>
    <param name="robot_description" command="$(find xacro)/xacro.py '$(find mrp2_description)/robots/mrp2_$(arg robot).urdf.xacro' robot_name:=$(arg robot_name)" />
    <node name="robot_state_publisher_$(arg robot_name)" pkg="robot_state_publisher" type="robot_state_publisher">
        <param name="use_tf_static" value="true"/>
        <remap from="/joint_states" to="/$(arg robot_name)/joint_states" />
    </node>
</launch>

After following steps carefully, and after remapping some topics like this: <remap from="odom" to="$(arg robot_name)/odom"/>, Do same steps for each robot. (Just change robot name ... (more)

edit flag offensive delete link more

Comments

Thanks ! It really helped. :)

Pikachu gravatar image Pikachu  ( 2016-06-17 01:11:37 -0500 )edit
0

answered 2016-06-14 02:35:39 -0500

F.Brosseau gravatar image

If they have to move the same way, you can make them subscribe to the same command topic.

You can also take a look at this : http://wiki.ros.org/turtlesim#mimic. In the tutorial, it allows a robot to reproduce the movement of another one.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-14 00:02:50 -0500

Seen: 1,600 times

Last updated: Jun 17 '16