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

Message data type and accessing message fields

asked 2011-11-05 08:41:19 -0500

Paul0nc gravatar image

I'm trying to use the /body_msgs/skeletons message (from the MIT hand_interaction demo). I'm trying to write a subscriber callback function. How can I tell the type of the message (for the callback prototype declaration)?

Also, this message has many fields (x,y,z coordinates of various joints). How would I access any individual coordinate such as left_hip/y ?

Thanks, Paul

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-11-05 10:42:38 -0500

kwc gravatar image

I recommend following the relevant ROS tutorials on writing publishers and subscribers for your relevant language:

e.g. "Writing a Simple Publisher and Subscriber (C++)"

edit flag offensive delete link more


Thanks kwc. I have worked through these tutorials. I'm still not clear on how to access fields of a message or what is the type of a message composed of many variables. The tutorials use standard types having only a single field. Apologies if this is basic.
Paul0nc gravatar image Paul0nc  ( 2011-11-05 13:49:40 -0500 )edit
Multiple fields is no different from a single field: you just access the field by its name. i.e. if you type "", you are accessing the 'data' field.
kwc gravatar image kwc  ( 2011-11-05 15:22:28 -0500 )edit

Question Tools


Asked: 2011-11-05 08:41:19 -0500

Seen: 4,132 times

Last updated: Nov 05 '11