-
Notifications
You must be signed in to change notification settings - Fork 422
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
Dynamic Message Deserialization #2260
Comments
After some further investigation, it looks like the cast to members always returns junk.
Steps to reproduce issueI wrote this code sample. #include "rclcpp/rclcpp.hpp"
#include "rosidl_typesupport_introspection_cpp/message_introspection.hpp"
int main(int argc, char * argv[])
{
std::string topic_type = "std_msgs/msg/String";
std::shared_ptr<rcpputils::SharedLibrary> library = rclcpp::get_typesupport_library(topic_type, "rosidl_typesupport_cpp");
const rosidl_message_type_support_t * message_type_support = rclcpp::get_typesupport_handle(topic_type, "rosidl_typesupport_cpp", *library);
auto members = static_cast<const rosidl_typesupport_introspection_cpp::MessageMembers *>(message_type_support->data);
}
When I bring up a debugger, I get the following output: (I also tested with can_msgs/msg/Frame): It seems that the cast should be valid if I correctly understand the IDL generators here. If this is more relevant in the IDL repo, I'd be happy to move it there. |
So I don't know about the exact code you are using above. But we do have examples of using serialized messages and successfully decoding. One such example is in https://github.com/ros2/demos/blob/rolling/demo_nodes_cpp/src/topics/listener_serialized_message.cpp . More specifically, Let me know if that helps at all. |
Hi, I also have a similar problem. I want to write a collector application that output a JSON object periodically. That json object will include a list of items. Each item will include 3 things: the name of the topic, the type of the topic and the deserialized last message in that topic. This is close to what I want to do, but it does not provide a parse method Rosbag2 seem to just put the serialized message inside their own serialized message I guess dynamic deserialization is what I need, but it is not implemented Is it possible to do what I want? I would prefer using C++ or python. It probably is possible with C but I am not sure about which way to go. |
Your ideas are similar to the current service event. Please refer to https://github.com/ros-infrastructure/rep/blob/336d3b66135ca71a82d5e903de1e865e4ceddd2d/rep-2012.rst#service-event-definition. |
Hi,
I'm relatively new to the rclcpp client after several years of using rclpy and both ROS1 clients. I'm trying to deserialize a message dynamically at runtime. I have the following callback for a generic subscriber:
When I run this, I get a members->size_of_ of 140737332973024, so I assume the casting to message members is incorrect.
I also tried the init_function() in members.
I may be misunderstanding the mechanism for introspection or the serialization API. Any help would be great. Thanks.
The text was updated successfully, but these errors were encountered: