Ask Your Question
0

roslaunch group ns doesn't work

asked 2021-09-05 10:43:58 -0500

Morteza70 gravatar image

updated 2021-09-07 04:11:36 -0500

Hello,

As far as I know, there is two ways to change topics in the launch file:

  • using group ns (<group ns="t1"> <node ..... > </group>)
  • using remapping for node

I have tried both methods. But the first method is not always working. For example, I’ve tried to run the turtlebot3_teleop_key node within a group namespace. But still, it publishes to /cmd_vel topic. But when I use remapping, it works (publishes /t1/cmd_vel).

I want to know why sometimes using does not work, or what are the requirements?

this is my launch file (in noetic):

<launch>
  <arg name="model" default="$(env TURTLEBOT3_MODEL)"/>
  <arg name="name_space" default="t1"/>

  <group ns = "$(arg name_space)">
    <param name="model" value="$(arg model)"/>
    <node pkg="turtlebot3_teleop" type="turtlebot3_teleop_key" name="turtlebot3_teleop"  output="screen">
      <!--remap from="/cmd_vel" to="/$(arg name_space)/cmd_vel"/-->
    </node>
  </group>

</launch>

If I comment remap part, it still publishes /cmd_vel topic, not /t1/cmd_vel

edit retag flag offensive close merge delete

Comments

The group tag works as expected for me in melodic, and remaps to /t1/cmd_vel. Please edit your question to show us your launch file.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-09-05 15:33:22 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2021-09-06 09:01:17 -0500

Mike Scheutzow gravatar image

Your launch file works properly (changes the node name and topic name) in melodic... if I delete the remap line. I can't test this on noetic at the moment. A few comments about the launch file:

  • I would not have spaces around the '=' in your group tag.

  • Your remap tag should use from="cmd_vel" without the slash. The topic name is relative to the node the remap tag is nested under.

  • # is not a valid comment character in a launch file.

  • The first line of your launch file should be <?xml version="1.0"?>

edit flag offensive delete link more

Comments

@Morteza70, Just for your knowledge

If you want to comment in the launch file you should use

<!--   launch file content  -->

Just to add on the last point of @Mike Scheutzow

I think that adding or removing <?xml version="1.0"?> will have no impact on the code, I think it is harmless. #280146

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-06 10:17:12 -0500 )edit
1

@Ranjit Kathiriya: it is more correct to have the xml declaration than to not have it. In my opinion, just because roslaunch is lazy and does not check for the proper syntax is not a good reason to skip it.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-09-06 11:56:40 -0500 )edit

thanks for your comments. In noetic, the node still publishes cmd_vel, not /t1/cmd_vel (not using remap and just using namespace). It baffles me! because I have tried the same method (namespace) for other nodes, sometimes it works and sometimes it doesn't.

Morteza70 gravatar image Morteza70  ( 2021-09-07 04:16:06 -0500 )edit

Thanks, @Mike Scheutzow,

For providing clarity to this topic.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-09-07 05:03:23 -0500 )edit

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: 2021-09-05 10:43:58 -0500

Seen: 64 times

Last updated: Sep 07 '21