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

Advice needed on a suitable method to transmit ROS msgs, with unknown msg types. In cpp

asked 2013-11-01 05:51:25 -0500

kurisu gravatar image

updated 2013-11-01 06:04:11 -0500

Hey guys,

So I have been contracted to write a ROS driver to facilitate the transmission (and reception) of currently undefined ROS msgs underwater with an acoustic modem.

My plan is to create a node that listens to all ROS msg traffic, then to discriminate the msgs to be transmitted across the acoustic link (with aid of topic names in a conf file), then serialise those selected msgs (one at a time), and then transmit. On the receiving side the date will need to be de serialised and re-published into a msg.

Due to not knowing the msgs before compilation, and the requirement of a configuration file to discriminate, this obviously means that I need a way to serialize and de-serialize without knowing the msg type (unless I have this information in the config file aswell). I have also been asked that it is programmed in CPP.

I realise that similar questions have been asked before , mostly stating that it is impossible (?) in cpp due to introspection... but these were asked several years ago.

So I wonder if there is any new advice, possibly from changes in ROS.

Many thanks,

Chris

edit retag flag offensive close merge delete

Comments

Hi, I've a similar problem but since m new to ros coding i'm unable to deal with the issue . can u lead through the basics ?it would b a great help.

thnx rythima

rpxz gravatar image rpxz  ( 2016-05-31 00:58:43 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-11-01 12:46:22 -0500

The obvious non-answer is to use python. It's almost trivial to do what you ask in python. Assuming that python won't work, you might want to look at the rosbag code. It is written in C++ and uses a shapeShifter message type to generically read and write messages in binary format. Here is a link to the shape shifter documentation ( http://docs.ros.org/hydro/api/topic_tools/html/classtopic__tools_1_1ShapeShifter.html ).

edit flag offensive delete link more

Comments

Thanks, I'll have a look into the rosbag code, but I'm starting to think that the non-answer might be an easier and better option, I might suggest that the serialization / deserialization stuff is coded into it's own ROS node and the rest is done in C++. Do you by chance know of any python examples?

kurisu gravatar image kurisu  ( 2013-11-03 21:18:28 -0500 )edit
0

answered 2013-11-01 06:31:23 -0500

teddybouch gravatar image

If your node is just listening in on topics, you're going to have to know the type of message to expect on that topic, which we will generically call Type. Then you could add some parsing to the .msg file that would tell you the format of the messages. However, with ROS's support for nested types in messages, that could get really complex, and with the bandwidth limitations of acoustic modems the additional information that you would have to encode in every message to handle this generically would be a killer. Which modems are you using? Are you writing the driver, or do you have a lower-level driver you are using?

edit flag offensive delete link more

Comments

Evologics 18/34 (ethernet), best-case 13.9 kbps so I'd anticipated that the need to encode more information could be a problem, the data throughput apparently shouldn't be too 'heavy' though. No driver, so it is my remit to code both the low-level interface, and the high level ROS 'transport' stuff

kurisu gravatar image kurisu  ( 2013-11-03 21:15:28 -0500 )edit

Question Tools

Stats

Asked: 2013-11-01 05:51:25 -0500

Seen: 1,123 times

Last updated: Nov 01 '13