Skip to content

deserialize SerializedMessage into arbitrary message type on runtime? #1283

Description

@nyxaria

Hello,

I am just starting to use ROS2 and am looking into creating a generic subscriber which can subscribe to any topic, get rclcpp::SerializedMessage and then convert it to the message_type of the topic that the message came from.

So far I have the generic subscriber working and have a SerializedMessage, but am confused how to go about converting it to a normal ros message.

My thought is to use the Serialization.deserialize_message. To do this, I would need a function which does "std_msgs::msg::String" -> std_msgs::msg::String (ie string name of message_type -> actual message_type class). Is there something which achieves this?

What I'm ultimately trying to achieve is to get a key-value vector of all the data inside any message.

Furthermore, for this approach I would need to create a Serialization object for each message_type. Is there a better way?

Many thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions