Ask Your Question
0

How to remap a private parameter

asked 2018-02-21 02:45:27 -0500

Felix Widmaier gravatar image

In a launch file I want to remap parameters of my node to other, already existing parameters. It is working for global parameters but not for private ones.

This is a simple example node "param.py":

#!/usr/bin/env python
"""Just testing parameter mapping."""
import rospy

rospy.init_node("param")
print(rospy.get_param("foo"))
print(rospy.get_param("bar"))
print(rospy.get_param("~baz"))

The node is launched by this launch file "param.launch":

<launch>
    <node name="param" pkg="mypkg" type="param.py" output="screen">
        <remap from="/bar" to="/foo" />
        <remap from="baz" to="foo" />
    </node>
</launch>

In a terminal I run:

rosparam set foo 42
roslaunch mypkg param.launch

The output is:

42
42
KeyError: '~baz'

How can I make it work?

edit retag flag offensive close merge delete

Comments

I'm afraid rosparam would fail without Parameter server running. Maybe add roscore command a line above?

130s gravatar image130s ( 2018-09-20 12:47:55 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-21 02:47:04 -0500

Felix Widmaier gravatar image

Private parameter names have to be prefixed with ~ even when the <remap> is defined inside the <node> tag:

<launch>
    <node name="param" pkg="mypkg" type="param.py" output="screen">
        <remap from="/bar" to="/foo" />
        <remap from="~baz" to="foo" />
    </node>
</launch>

Output:

42
42
42
edit flag offensive delete link more

Comments

1

Nice dig! Added to remap page.

130s gravatar image130s ( 2018-09-20 12:46:53 -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

1 follower

Stats

Asked: 2018-02-21 02:45:27 -0500

Seen: 1,828 times

Last updated: Feb 21 '18