在 RCLC 中将 yaml 消息解析为 ros2 消息

问题描述 投票:0回答:0

我正在编写一个 C 库,它提供了一些创建与 ROS 主题交互的通用发布者和订阅者的功能。

我想像这样的字符串:

{data: 143}

鉴于此消息有一个 ROS 消息定义(在本例中为 std_msgs/msg/Int32),我想获取此字符串并将其转换为我可以发送给发布者的 rclc 消息。

有没有办法动态地做到这一点?我希望能够做这样的事情:

void *message_to_send = parse_yaml_to_msg(message_type, "{data: 143}");
rcl_publish(pub, message_to_send, NULL);

理想情况下,message_type 也可以从消息格式文件中动态加载。

这可能吗?

非常感谢

c parsing yaml ros
© www.soinside.com 2019 - 2024. All rights reserved.