Reading Custom Messages from ROS2 bag files without redefining messages
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to read my ROS2 bag file (.db3) using Matlab just to plot some variables of interest from my custom package. I don't want to edit, send, or receive messages from this ROS2. However, my code returns an error referencing my custom messages.
Error using ros2
Unrecognized message type custom_package/custom_message_name. Use ros2 msg list to see available types.
Error in ros2bag (line 156)
rosMsgDef = ros2("msg","show",topicTypes{i});
Error in ExtractPlot_ROS2 (line 33)
bag = ros2bag(folder_path);
Other answers regarding this issue want me to use pyenv to individually define these messages. Is there a way to just view the data without having to remake my entire custom ROS2 environment in Matlab?
1 Commento
Varun
il 31 Gen 2024
Hey! I think that to retrieve data from DB3 file, MATLAB would need information regarding your custom packages regardless of whether you send or receive messages. Maybe importing the definitions of these custom messages can help resolve the issue. Please check whether the custom ROS messages have been added to MATLAB path or not.
If they aren't, use the "ros2genmsg" function to generate the custom messages from ROS 2 definitions. Here's the documentation link for the same: https://www.mathworks.com/help/ros/ref/ros2genmsg.html.
If the message definitions are not on the path, you can add them to the MATLAB path using the "addpath" function and then run the following commands:
savepath
clear classes
rehash toolboxcache
After this, you can call 'ros2 msg list' to verify the creation of new custom messages.
ros2 msg list
This should add the custom message definitions to your path and help MATLAB reference them. Hope this helps!
Risposte (0)
Vedere anche
Categorie
Scopri di più su Publishers and Subscribers in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!