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

Revision history [back]

click to hide/show revision 1
initial version

You always need a message definition to publish a message. This allows non-C++ clients to decode the message.

If you have a specific C/C++ type that you want to publish (struct test), you could define a matching message:

test.msg:

int32 a
int32 b
int32 c
float32 d

And define a message which uses that:

combined.msg

int32 e
int32 f
my_package/test g

You can then define a struct which contains a test:

struct combined_t {
  int e;
  int f;
  struct test g;
}

And then you can define a serializer for combined_t, which either uses the serializer for struct test or does everything inline, and then, finally, you'll be able to publish combined_t onto a topic with the combined.msg type.