0
$\begingroup$

Rosanswers logo

I'm very new to ROS and am [slightly] more versed in python than C++, so that's the route I'm currently pursuing in my learning. One option that is shown in the C++ tutorials is how one would set a custom namespace or parent namespace :

You can also specify a parent NodeHandle and a namespace to append:

### adding the initialization call from above
ros::init(argc, argv, "my_node_name");

ros::NodeHandle nh1("ns1");
ros::NodeHandle nh2(nh1, "ns2");

In the python information, I've only ever seen this used, which I take as equivalent to ros::init():

rospy.init_node('my_node_name')

How would one put node my_node_name into a custom or parent namespace using rospy?


Originally posted by jwhendy on ROS Answers with karma: 60 on 2017-05-16

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

rospy doesn't have a direct analog to the ros::NodeHandle in C++. If you do need to resolve names relative to the node name (or another name) in Python, you can use rospy.resolve_name(name, caller_id=None), but instead of a dedicated object this just return a string.

There's some documentation about this on the rospy Names and Node Information wiki.


Originally posted by ahendrix with karma: 47576 on 2017-05-17

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.