Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support rclrs::SerializedMessage #326

Open
fawdlstty opened this issue Aug 17, 2023 · 0 comments
Open

support rclrs::SerializedMessage #326

fawdlstty opened this issue Aug 17, 2023 · 0 comments

Comments

@fawdlstty
Copy link
Contributor

fawdlstty commented Aug 17, 2023

Hi all,

In rosbag2, receiving topic messages of unknown types is achieved through type rclcpp::SerializedMessage, which is not effective in rust through type std_msgs::msg::ByteMultiArray. I hope to add support for type rclcpp::SerializedMessage, so that after specifying a topic, I can receive messages of any unknown type.

example code:

fn main() -> Result<(), rclrs::RclrsError> {
    let context = rclrs::Context::new(std::env::args())?;

    let node = rclrs::create_node(&context, "test_rosbag")?;

    let _subscription = node.create_subscription::<std_msgs::msg::ByteMultiArray, _>(
        "/odom",
        rclrs::QOS_PROFILE_DEFAULT,
        move |msg: rclrs::ReadOnlyLoanedMessage<'_, std_msgs::msg::ByteMultiArray>| {
            println!("I heard {} bytes", msg.data.len());
        },
    )?;

    rclrs::spin(node).map_err(|err| err.into())
}

then publish:

ros2 topic pub /odom std_msgs/String "{data: aabbcc}"

and then the node cannot received the message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant