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

Is the 'x' in ConstPtr& x in callback functions specific to message types?

asked 2018-08-31 01:02:04 -0600

J. J. gravatar image

Hi I'm new to ROS and I'm an amateur when it comes to pointers. I just did the subscriber and publisher tutorials and I am currently experimenting and converting them into classes for future use. I noticed that in the callback function it has the following parameters:

 void chatterCallback(const std_msgs::String::ConstPtr& msg)

then I opened another cpp code with a subscriber and found:

  void joyCallback(const sensor_msgs::Joy::ConstPtr& joy);

My question, is 'joy' and 'msg' specifc to use for their message::message type? How can I know what to put after the ConstPtr& say for sensor_msgs::Range? Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-08-31 02:01:08 -0600

ahendrix gravatar image

No; the variable name is not specific to the message type or the callback. You can name the argument joy or msg or gerorge or whatever you want.

edit flag offensive delete link more

Comments

Thank you. That cleared up my mind.

J. J. gravatar image J. J.  ( 2018-08-31 02:16:42 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-31 01:02:04 -0600

Seen: 169 times

Last updated: Aug 31 '18