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

What does tilde(~) mean in ROS?

asked 2022-07-08 14:25:10 -0500

RoboTBiLL gravatar image

updated 2022-07-08 14:30:06 -0500

I have this sample of code:

def ranger(channel, frame_id):
range_pub = rospy.Publisher('~', Range, queue_size=10)
rate = rospy.Rate(15)

and this sample

if __name__ == '__main__':
    rospy.init_node('obstacle_sensor', anonymous=True)
    c = rospy.get_param('~channel')
    f = rospy.get_param('~frame_id')
    try:
        ranger(channel=c, frame_id=f)
    except rospy.ROSInterruptException:
        pass

Any help?

edit retag flag offensive close merge delete

Comments

As it's already been answered we'll leave this open, but it's a duplicate of #q250092 (which has a very similar title: "Ask about the usage of the tilde '~'sign").

gvdhoorn gravatar image gvdhoorn  ( 2022-07-08 14:54:25 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-07-08 14:27:15 -0500

fergs gravatar image

updated 2022-07-08 14:28:54 -0500

The tilde means "local namespace" and will prefix your node name to the value after the tilde. So if your node was named "my_node" and you publish to "~topic" the actual topic name published will be "my_node/topic".

edit flag offensive delete link more

Comments

Thank you!

RoboTBiLL gravatar image RoboTBiLL  ( 2022-07-08 14:36:50 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-07-08 14:25:10 -0500

Seen: 203 times

Last updated: Jul 08 '22