Ask Your Question
0

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)

and:

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
4

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 2,715 times

Last updated: Dec 15 '16