Foxglove client example in typescript using ros-foxglove-bridge #990
-
I'm trying to replace ros-bridge-server with ros-foxglove-bridge to interact with a ROS2 application (to work with services and subscriber). I'm trying to create a test client in typescript to handle service For the typescript, I use FoxgloveClient from @foxglove/ws-protocol to create the socket and @foxglove/cdr to decode data provided by ros-foxglove-bridge on ROS2 installation. I'm able to decode simple messages such as strings (std_msgs/msg/String) but I'm not able to decode it when it's more complicated message types (nav_msgs/msg/Odometry.msg https://docs.ros2.org/foxy/api/nav_msgs/msg/Odometry.html). Version: Platform: Steps To Reproduce
If the message is a string, the console.log(reader.string()) provides the published string. With an odom message, the console.log(reader.string()) provides the following output: Expected Behavior Do you have an idea about how to decode this type of messages (maybe using https://github.com/foxglove/schemas/tree/main) ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
const reader = new CdrReader(response.data);
console.log(reader.string()) CDR is a low-level serialization format that is unaware of ROS messages. Reading a |
Beta Was this translation helpful? Give feedback.
CDR is a low-level serialization format that is unaware of ROS messages. Reading a
string()
value out of the message would ignore the other fields of the message, namely the header. You probably want to use@foxglove/rosmsg2-serialization
instead. See here for an example: https://github.com/foxglove/mcap/blob/b8a73890348ef2dc69272b377fd2faab56f0303f/typescript/examples/validate/scripts/validate.ts#L154-L158