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

Ask about the usage of the tilde '~'sign

asked 2016-12-15 01:44:45 -0500

sonictl gravatar image

Ask about the usage of the tilde '~'sign

what's the difference between :

pub = rospy.Publisher('~cmd_vel', Twist, queue_size=5)


pub = rospy.Publisher('cmd_vel', Twist, queue_size=5)

By the way, what's the queue_size in the bracket mean?

Thank you!!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-15 01:54:38 -0500

mgruhler gravatar image

The tilde is due to namespacing. a ~ puts a topic or a parameter in the nodes private namespace (i.e. /some_ns/node_ns/private_topic), whereas without the tilde, it resides in the nodes namespace (i.e. /some_ns/topic). If you add a / instead of the tilde, you'll end up in the global namespace (/topic).

Python does not have the concept of a NodeHandle as C++, but in essence this is the same as ros::NodeHandle nh("~"), ros::NodeHandle nh("") and ros::NodeHandle nh("/").

About the queue_size, there is a good explanation on the wiki.

edit flag offensive delete link more

Question Tools



Asked: 2016-12-15 01:44:45 -0500

Seen: 4,415 times

Last updated: Dec 15 '16