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

roscpp parameters with roslaunch remapping

asked 2014-03-03 13:14:23 -0500

stebl gravatar image

How can I access roscpp parameters if the node name has been remapped with roslaunch?

launch file,

<node pkg="my_package" type="my_package_node" name="remapped_name" ns="my_namespace">
    <param name="camera_index" value="$(arg camera_index)" />
</node>

in cpp file,

ros::init(argc, argv, "node_default_name");
ros::NodeHandle n;

ros::param::get("node_default_name/camera_index", camera_index); // Fails
ros::param::get("remapped_name/camera_index", camera_index); // Works 

n.getParam("node_default_name/camera_index", camera_index); // Fails
n.getParam("remapped_name/camera_index", camera_index); // Works

How can I get the parameters in the .cpp file without knowing the node name? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-03-03 15:17:21 -0500

brice rebsamen gravatar image

I think you should use the private namespace:

ros::param::get("~camera_index", camera_index);

ros::NodeHandle nh("~");
nh.getParam("camera_index", camera_index);

see http://wiki.ros.org/roscpp/Overview/P...

edit flag offensive delete link more

Comments

Yep, worked for me, thanks! ros::NodeHandle nh("~"); nh.getParam("camera_index", camera_index);

stebl gravatar imagestebl ( 2014-03-05 11:44:27 -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: 2014-03-03 13:14:23 -0500

Seen: 781 times

Last updated: Mar 03 '14