Define a custom message type for .msg files
Hey so my problem is that I need a custom format for msgs which I have no idea how to do with ROS. The problem is that I have a really complex dynamic format and I would basically need a serialize() and deserialize() or something along those lines where I can define how to serialize and deserialize the msg. The main problem is that its changing during runtime and I found no way to do that with ros yet. I have values similar to this I need to send in the message:
message Variant {
oneof value {
int64 int_value = 3;
double double_value = 4;
bool bool_value = 5;
string string_value = 6;
}
}
Not saying you're wrong, but just so we avoid an xy-problem: can you please describe what you actually are trying to do, instead of what you believe is the solution to your problem? Are you trying to interface with another middleware that has variant support fi?
Send protobuff messages between nodes
I don't really understand: there is no protobuf transport for ROS 1, so that would seem to be impossible.
Can you say anything about the semantics of the messages that you are trying to pub-sub? Perhaps an approach where you transform incoming protobuf msgs into their ROS equivalents ..
.. would work here.
Semantics of 'variant' msgs are typically not something I'm too thrilled about anyway, but that is personal.
There has been some discussion of using protobuf with ROS recently, I believe on the
ros_comm
tracker, perhaps that can be of help.Thanks. Basically I wana just serialize protobuff stuff and send that with ros and deserialize that at the other end.
So you want to serialise protobuf msgs into bytestrings, send those over using the TCPROS and then deserialise?
This still sounds like an
xy-problem
to me, but in that case a byte array sounds like what you'd use.Or if you really want to, abuse a.std_msgs/String
Yeah but how can I distinguish which message is which if I just send them as byte arrays?
This is all rather nasty anyway, but how about making separate msgs for each of the protobuf msgs that you'd want to pub-sub?
So a ROS
MsgA.msg
with just a byte array to serialise ProtobufA
msgs into, one forB
, etc.