Control multiple robots separately using geometry_msgs/Twist
Hi,
I am trying to control separately three robots by using a geometry_msgs/Twist command. The robots are spawning successfully and I am able to make them move using the following command (this command moves the three robots at the same time):
rostopic pub /cmd_vel geometry_msgs/Twist '[1.0, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
My problem is that I would like to be able to control them separately using geometry_msgs/Twist command. (Ex. one robot going forward while the other one robot is going backward). But when I do a rostopic list, there is only one /cmd_vel and I would like to have a separate cmd_vel for each robot (/robot1/cmd_vel, /robot2/cmd_vel, etc.) to be able to use these commands :
rostopic pub /robot1/cmd_vel geometry_msgs/Twist '[1.0, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
rostopic pub /robot2/cmd_vel geometry_msgs/Twist '[-1.0, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
rostopic pub /robot3/cmd_vel geometry_msgs/Twist '[0.7, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
I am currently using the libgazebo_ros_skid_steer_drive.so plugin as followed in my URDF:
<gazebo>
<plugin name="skid_steer_drive_controller1" filename="libgazebo_ros_skid_steer_drive.so">
<updateRate>100.0</updateRate>
<robotNamespace>/</robotNamespace>
<leftFrontJoint>exterior_left_front_wheel_joint</leftFrontJoint>
<rightFrontJoint>exterior_right_front_wheel_joint</rightFrontJoint>
<leftRearJoint>exterior_left_reer_wheel_joint</leftRearJoint>
<rightRearJoint>exterior_right_reer_wheel_joint</rightRearJoint>
<wheelSeparation>0.59196</wheelSeparation>
<wheelDiameter>0.1524</wheelDiameter>
<robotBaseFrame>plateau</robotBaseFrame>
<torque>9.8</torque>
<commandTopic>cmd_vel</commandTopic>
<odometryTopic>odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<broadcastTF>false</broadcastTF>
</plugin>
</gazebo>
Here are my two launch files : 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>
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" />
<group ns="robot1">
<node name="spawn_foxtrot_model" pkg="gazebo_ros" type="spawn_model"
args="-x -1.9064 -y 0 -z 0 -urdf -param /robot_description -model robot1"
respawn="false" output="screen" >
<param name="tf_prefix" value="robot1_tf" />
</node>
</group>
<group ns="robot2">
<node name="spawn_foxtrot_model" pkg="gazebo_ros" type="spawn_model"
args="-x 0 -y -1.25 -z 0 -urdf -param /robot_description -model robot2"
respawn="false" output="screen" >
<param name="tf_prefix" value="robot2_tf" />
</node>
</group>
<group ns="robot3">
<node name="spawn_foxtrot_model" pkg="gazebo_ros" type="spawn_model"
args="-x 0 -y 1.25 -z 0 -urdf -param /robot_description -model robot3"
respawn="false" output="screen" >
<param name="tf_prefix" value="robot3_tf" />
</node>
</group>
</launch>
I am not sure what I need to change to have separate cmd_vel for each robot (/robot1/cmd_vel, /robot2/cmd_vel, etc.)
PS. I followed that video : YouTube Tutorial that was an update to this : ROSanswers. I am using ROS Melodic.