ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

How do I modify the name of topic in launch file?

asked 2020-03-15 04:41:34 -0600

kane_choigo gravatar image

Hello, I'm using ROS melodic on Ubuntu 18.04.

I'd like to spawn 4 mobile robots and make them move randomly on gazebo simulation.

I practiced with one robot and also set a node just publishing the topic kinds of geometry_msgs/Twist of cmd_vel.

However, it didn't move at all, because I also had attached the namespace of /robot_0/ to all the topic wrt the spawned robot. (so the name of cmd_vel changed from name of cmd_vel to /**robot_0**/name of cmd_vel.

To discriminate 4 different kinds of cmd_vel topics, I just set like below:

<group ns="robot_0">
<param name="tf_prefix" value="robot_0" />
 <include file="$(find turtlebot_gazebo)/launch/includes/$(arg base)_object.launch.xml">
   <!-- <arg name="init_pose" value="-x 0.5 -y 0.5 -z 0" /> -->
   <arg name="init_pose" value="-x 5.5 -y 5.5 -z 0" />
   <arg name="base" value="$(arg base)"/>
   <arg name="stacks" value="$(arg stacks)"/>
   <arg name="3d_sensor" value="$(arg 3d_sensor)"/>
   <arg name="robot_name"  value="robot_0" />
   <arg name="color" value="red" />
  <include>
</group>

But in the case of I made the lines wrt namespace be comment line like this,

<!-- <group ns="robot_0"> -->
<param name="tf_prefix" value="robot_0" />
<include file="$(find turtlebot_gazebo)/launch/includes/$(arg base)_object.launch.xml">
  <!-- <arg name="init_pose" value="-x 0.5 -y 0.5 -z 0" /> -->
  <arg name="init_pose" value="-x 5.5 -y 5.5 -z 0" />
  <arg name="base" value="$(arg base)"/>
  <arg name="stacks" value="$(arg stacks)"/>
  <arg name="3d_sensor" value="$(arg 3d_sensor)"/>
  <arg name="robot_name"  value="robot_0" />
  <arg name="color" value="red" />
</include>
<!-- </group> -->

It moved.

But I couldn't get the topic discriminated against following the namespace which means I couldn't distinguish which cmd_veltopic is from which robot.

What I want to do is, 1. To make the robot move. 2. To discriminate the topics following the 4 spawned robots.

If anyone can answer or give me advice, would you please give me help?

Thanks in advance. :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-15 10:25:05 -0600

updated 2020-03-15 10:27:29 -0600

you can remap topic names when you launch nodes on the command line, and also inside launch files.

You could also launch the nodes for controlling them within the same namespace section of the the launch file, and they would also have the robot details appended to their topics already.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-03-15 04:41:34 -0600

Seen: 699 times

Last updated: Mar 15 '20