http://wiki.ros.org/roscpp_tutorials/Tutorials/AccessingPrivateNamesWithNodeHandle
This tutorial will show you how to access private Names with roscpp’s NodeHandle API.
1 Why not just ~name?
2 Accessing Private Names
The solution is to construct a NodeHandle with a private name as its namespace:
1 ros::init(argc, argv, "my_node_name");
2 ros::NodeHandle nh1("~"); // must be in main()
3 ros::NodeHandle nh2("~foo");
nh1’s namespace is /my_node_name, and nh2’s namespace is /my_node_name/foo.
So instead of doing this:
1 ros::NodeHandle nh;
2 nh.getParam("~name", ... );
You do this:
1 ros::NodeHandle nh("~");
2 nh.getParam("name", ... );