ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Why can't I 'get' my rosrun parameters?

asked 2014-08-12 23:29:04 -0500

falseazure gravatar image

updated 2014-08-12 23:31:49 -0500

I have a node that should be able to run other nodes. It has a basic method of doing so using

system("rosrun myproject Robot robotname:='Botty'");

This should set the parameter robotname to 'Botty'. In my Robot node file, I have this code that should retrieve that parameter:

std::string robotname;
n.getParam("robotname", robotname);
ROS_INFO(robotname.c_str());

However, nothing is printed. When I execute rosparam list, the corresponding parameter is /RobotNode1/robotname. What am I doing wrong? I think that rosparam list output might be a good hint - is there a way to set that parameter when executing rosrun without referencing RobotNode1?

[edit] n is a NodeHandle.

edit retag flag offensive close merge delete

Comments

1

Note that robotname:='Botty' does not set /RobotNode1/robotname, but just /robotname. Use _robotname:=Botty for parameters in the node's namespace.

dornhege gravatar image dornhege  ( 2014-08-13 04:20:19 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-08-13 01:04:03 -0500

BennyRe gravatar image

/RobotNode1/robotname means that this parameter has been set in the private namespace of the node.

So, you have to create a private node handle to retrieve this parameter. Do this:

ros::NodeHandle private_node_handle("~");
edit flag offensive delete link more

Comments

Thank you!

falseazure gravatar image falseazure  ( 2014-08-13 01:18:29 -0500 )edit

I just spent several hours trying to get the parameter fetching to work, because someone thought it was a good idea to use this private and public parameter setting thing.

db gravatar image db  ( 2019-05-23 14:17:15 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-08-12 23:29:04 -0500

Seen: 4,194 times

Last updated: Aug 13 '14