0

I am trying to write a subscriber class which subscribe to a topic and read messages published for that topic. As I know I need to pass a callback function with message structure to read received messages. But this approach is not generic. Is there any way so that I can read any ros message in form of string and send it to client classes which can parse them accordingly

Jai
  • 1,292
  • 4
  • 21
  • 41
  • Suppose your data is in float format, then in your callback function you can cast it into string (it's straight forward in Python at least). Then you do whatever you like with the string. I am still not sure what you require though. – akshayk07 Jul 09 '19 at 08:57

1 Answers1

1

You can use python like akshayk07 suggests, or you can use the C++ alternative: ros_type_introspection. The author wrote exactly what you ask for in generic_subscriber.cpp.

aPonza
  • 492
  • 4
  • 10