ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

set parameter when remapped (launch file) [closed]

asked 2022-05-20 02:17:44 -0500

naihart gravatar image

updated 2022-05-20 02:19:01 -0500

I remapped the node name through launch file, also I set a parameter inside launch file. What happened is, the parameter is set on the original name of the node. Heres my launch file:

     <node name ="original_node" pkg ="test_pkg" type ="original_node" output="screen">
     <remap from="/original_node" to="/new_node"/>
     <param name="number_string" type="string" value="123456" />

Heres the rosparam list:


Im expecting to have /new_node/number_string on my rosparam list. Any guide on how can I set my parameter based on the remapped node name inside launch file?

Note: I tried putting under </node> but I explicitly typed the remapped node. This one works but is there any other method in which I only change the remap and not the param name?

     <node name ="original_node" pkg ="test_pkg" type ="original_node" output="screen">
     <remap from="/original_node" to="/new_node"/>
     <param name="/new_node/number_string" type="string" value="123456" />
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by naihart
close date 2022-05-21 01:39:38.730714

1 Answer

Sort by ยป oldest newest most voted

answered 2022-05-20 03:10:35 -0500

Joe28965 gravatar image

updated 2022-05-20 04:17:54 -0500

You might want to try removing the / from the remaps, I know they can cause issues.

<remap from="original_node" to="new_node"/>

It also looks like your node of type original_node uses the name tag to add the namespace original_node. This means you could also do:

<node name ="new_node" pkg ="test_pkg" type ="original_node" output="screen">

And that might also work.

EDIT to respond to your comment:

If 1 already works, then 2 isn't adding anything. Which means the remap simply isn't working. Hence why 3 works.

As for your question about the difference between remap and renaming it: If you check rosnode list you will see that, by renaming, it should also show up as new_node while if remapped correctly it should still show up as original_node.

Remapping is only simply changing the name of the topic to whatever you like. This can be useful if (example) you're using a robot that has the default cmd_vel topic as cmd_vel_unstamped and you need your teleop to work with that. Then you can simply remap your teleop from cmd_vel to cmd_vel_unstamped. Changing the node name in this case would also not solve anything. Teleop would still publish to the wrong topic.

So they're two very different solutions to (in this specific case) the same result.

There is something that I am wondering: Can you even remap a portion of the topic, or a namespace like that?

Which makes me wonder, would you not need to do something like: <remap from="original_node/number_string" to="new_node/123456"/>. Remapping the entire topic and combining the remap and parameter in 1.

edit flag offensive delete link more


These are the series of test that I have done.

  1. renaming the node name same as the remap to - it works
  2. with or without slashes on the remap as long as Ive done the number 1, everything works fine.
  3. tried to delete remap, just rename the node name and this also works

now Im wondering, what is the difference of using remap on renaming the node name?

naihart gravatar image naihart  ( 2022-05-20 03:36:09 -0500 )edit

Wow, thank you so much for explaining. I get it now. Cheers!

naihart gravatar image naihart  ( 2022-05-21 01:38:59 -0500 )edit

Question Tools



Asked: 2022-05-20 02:17:44 -0500

Seen: 40 times

Last updated: May 20 '22