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

From structure to message

asked 2011-11-07 03:39:41 -0600

Guido gravatar image

updated 2011-11-07 21:49:20 -0600

Hi everybody,

Does someone has ideas about how to directly send a C structure over topics/services/actions ? Currently I read some data from a file and end up with this data in a structure S, then I copy the data in S into a ROS msg data structure ROS_S (which is identical to S). This copy-past step bothers me and I would like to know if someone has a simple solution about this.

Guido

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2011-11-07 04:11:32 -0600

bhaskara gravatar image

To avoid the extra step of converting from S to ROS_S on the publisher, you can define custom serialization functions for S. http://www.ros.org/wiki/roscpp/Overview/MessagesSerializationAndAdaptingTypes

edit flag offensive delete link more

Comments

This should work quit fine. Thank you.
Guido gravatar image Guido  ( 2011-11-07 21:57:51 -0600 )edit
1

answered 2011-11-07 04:12:44 -0600

tfoote gravatar image

If they're actually identical you could just use ROS_S instead of S the first time.

edit flag offensive delete link more

Comments

Indeed it would be simpler. However I don't have control on the first reading step (from data to S) so I can't read the data and put it directly in ROS_S.
Guido gravatar image Guido  ( 2011-11-07 21:50:38 -0600 )edit

Question Tools

Stats

Asked: 2011-11-07 03:39:41 -0600

Seen: 2,893 times

Last updated: Nov 07 '11