Reputation: 771
Based on the tutorial here, I tried to create my launches to run multiple robots in gazebo. Each robot has a node [called stopper] that takes care to move it. I want that each robot will move separately, so I will publish to {robot_name}/cmd_vel_mux/input/teleop topic.
when running "rostopic info /cmd_vel_mux/input/teleop" I noticed that I have only mobile_base_nodelet_manager as subscriber, with no publisher (the publisher exists into {robot_name}/cmd_vel_mux/input/teleop topic. Therefore, I used remap but it still doesn't work and the same problem appears.
one_robot.lanuch
<?xml version="1.0"?>
<launch>
<arg name="robot_name"/>
<arg name="init_pose"/>
<node name="spawn_minibot_model" pkg="gazebo_ros" type="spawn_model"
args="$(arg init_pose) -urdf -param /robot_description -model $(arg robot_name)"
respawn="false" output="screen" />
<!-- Launch stopper node -->
<node name="stopper" pkg="stopper" type="stopper" output="screen" args="$(arg robot_name)">
<remap from="scan" to="$(arg robot_name)/scan"/>
<remap from="cmd_vel_mux/input/teleop" to="$(arg robot_name)/cmd_vel_mux/input/teleop"/>
</node>
</launch>
robots.launch
<?xml version="1.0"?>
<launch>
<!-- No namespace here as we will share this description.
Access with slash at the beginning -->
<param name="robot_description"
command="$(find xacro)/xacro.py $(find turtlebot_description)/robots/kobuki_hexagons_asus_xtion_pro.urdf.xacro"/>
<!-- BEGIN ROBOT 1-->
<group ns="robot1">
<param name="tf_prefix" value="robot1_tf" />
<include file="$(find stopper)/launch/one_robot.launch" >
<arg name="init_pose" value="-x 1 -y 1 -z 0" />
<arg name="robot_name" value="Robot1" />
</include>
</group>
<!-- BEGIN ROBOT 2-->
<group ns="robot2">
<param name="tf_prefix" value="robot2_tf" />
<include file="$(find stopper)/launch/one_robot.launch" >
<arg name="init_pose" value="-x -1 -y 1 -z 0" />
<arg name="robot_name" value="Robot2" />
</include>
</group>
</launch>
multiple_robots.launch
<?xml version="1.0"?>
<launch>
<param name="/use_sim_time" value="true" />
<!-- include our robots -->
<include file="$(find stopper)/launch/robots.launch"/>
<!-- start world -->
<include file="$(find turtlebot_gazebo)/launch/turtlebot_world.launch"/>
</launch>
multiple_robots.launch
, but it's not really possible for me, because there we don't know the robot names, but just in one_robot.launch
.I would like to get your help to solve this issue, I spent a lot of time on this. Thank you very much!
Upvotes: 0
Views: 4665
Reputation: 1
When you say this, it makes me think remap is working:
when running "rostopic info /cmd_vel_mux/input/teleop" I noticed that I have only mobile_base_nodelet_manager as subscriber, with no publisher (the publisher exists into {robot_name}/cmd_vel_mux/input/teleop topic.
The old topic /cmd_vel_mux/input/teleop
doesn't have a publisher anymore, which would be true if remap worked. And you say the publisher exists for the remapped topic, {robot_name}/cmd_vel_mux/input/teleop
that means the remap is working.
You say mobile_base_nodelet_manager
is subscribing to the old topic, but it should be subscribing to the new topic. Remap doesn't change the topic for both publishers and subscribers. Remap isn't global.
I would make sure the nodes that were subscribing to the old topic, are now subscribing to the new topic. You'll have to do a remap on the Subscribers too, so they know what the new topic is and that they can subscribe to it.
The ROS docs describe remapping on a subscriber node: Remap Docs
Upvotes: 0
Reputation: 730
is an option for a given node. Thus I believe it needs to be added under a node tag. So it has to be within the <node> ... </node>
block.
Additionally, what you are trying to do could be achieved by launching your teleop nodes under appropriate namespace, either using the <group ns="XXX">
in a launch file or in the terminal by running export ROS_NAMESPACE=XXX
before launching the teleop node.
Upvotes: 0