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

Why do we use equal sign?

asked 2022-07-12 11:27:30 -0500

RoboTBiLL gravatar image

In these two lines, the author has used the equal sign inside the parenthesis.

self.vel_pub = rospy.Publisher(name=self.cmd_vel_topic, data_class=Twist, queue_size=10)


self.front_topic_subscriber = rospy.Subscriber(name=self.front_sensor_topic, data_class=Range, callback=self.front_callback)

for example: name=self.cmd_vel_topic

Why did he do that?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-07-12 11:37:59 -0500

Stkr22 gravatar image

updated 2022-07-12 11:38:37 -0500

The author is telling the function (in this case the constructor for the rospy subscriber class) which particular arguments the value they are passing in is for. If you look at the documentation for the subscriber class you will notice the __init__() function has name,data_class, and callback as arguments in the function definition. You don't necessarily have to do that, but then you need to be careful about the order you pass in the values to the function. Basically, the authors are explicitly telling the function which argument each value they pass in relates to.

Docs: Subscriber

edit flag offensive delete link more

Question Tools



Asked: 2022-07-12 11:27:30 -0500

Seen: 68 times

Last updated: Jul 12 '22