How to control multiple robots separately

asked 2020-12-06 12:33:18 -0500

AMC gravatar image

updated 2022-05-28 16:46:46 -0500

lucasw gravatar image

Hi,

I am trying to control separately three robots but I only have one /cmd_vel.

I would expect the following :

/robot1/cmd_vel
/robot2/cmd_vel
/robot3/cmd_vel

But when I do rostopic list I have the following:

/clock
/cmd_vel
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/odom
/robot1/joint_states
/robot2/joint_states
/robot3/joint_states
/rosout
/rosout_agg
/tf
/tf_static

Here are my three launch files :

one_robot.launch

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

<node name="spawn_foxtrot_model" pkg="gazebo_ros" type="spawn_model"
 args="$(arg init_pose) -urdf -param /robot_description -model $(arg robot_name)"
 respawn="false" output="screen" />

<node pkg="robot_state_publisher" type="state_publisher"
      name="robot_state_publisher" output="screen"/>
</launch>

robots.launch

<launch>
<!-- No namespace here as we will share this description.
   Access with slash at the beginning -->
<param name="robot_description"
  command="$(find xacro)/xacro $(find robot_description)/urdf/robot.urdf.xacro" />

<!-- BEGIN ROBOT 1-->
<group ns="robot1">
  <param name="tf_prefix" value="robot1_tf" />
<include file="$(find robot_gazebo)/launch/one_robot.launch" >
  <arg name="init_pose" value="-x -1.9064 -y 0 -z 0" />
  <arg name="robot_name"  value="Robot1" />
</include>
</group>

<group ns="robot2">
<param name="tf_prefix" value="robot2_tf" />
<include file="$(find robot_gazebo)/launch/one_robot.launch" >
  <arg name="init_pose" value="-x 0 -y -1.25 -z 0" />
  <arg name="robot_name"  value="Robot2" />
</include>
</group>

<group ns="robot3">
<param name="tf_prefix" value="robot3_tf" />
<include file="$(find robot_gazebo)/launch/one_robot.launch" >
  <arg name="init_pose" value="-x 0 -y 1.25 -z 0" />
  <arg name="robot_name"  value="Robot3" />
</include>
</group>

</launch>

main.launch

<launch>
<param name="/use_sim_time" value="true" />

<!-- start world -->
<node name="gazebo" pkg="gazebo_ros" type="gazebo"
 args="$(find robot_gazebo)/world/robot.world" respawn="false" output="screen" />

<!-- start gui -->
<!-- <node name="gazebo_gui" pkg="gazebo" type="gui" respawn="false" output="screen"/> -->

<!-- include our robots -->
<include file="$(find robot_gazebo)/launch/robots.launch"/>
</launch>

I think the problem might be in my launch files but I am not sure.

edit retag flag offensive close merge delete

Comments

Which node is publishing /cmd_vel? Could you please tell me the response to rostopic info /cmd_vel?

You may have already been referring to it, as it's similar to comparing the launch files, but there are multiple robots at https://answers.ros.org/question/4143... You have a coherent way of moving the

miura gravatar image miura  ( 2020-12-07 08:58:56 -0500 )edit
1

Here is the response :

Type: geometry_msgs/Twist

Publishers: None

Subscribers: 
 * /gazebo (http://annemarie-UX370UAR:46275/)
AMC gravatar image AMC  ( 2020-12-07 09:20:36 -0500 )edit

That means that none of the nodes are issuing /cmd_vel. Good to see the Navigationsection of https://answers.ros.org/question/4143... Looks like.

miura gravatar image miura  ( 2020-12-07 09:33:48 -0500 )edit