Reading Custom Messages from ROS2 bag files without redefining messages
조회 수: 26 (최근 30일)
이전 댓글 표시
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
Varun
2024년 1월 31일
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!
답변 (1개)
Sai
2024년 11월 15일 13:39
It is my understanding that you are trying to read from ROS2 bag file by referencing your custom message and you code returns error while referencing to your custom message.
The errors are relevant to the function used for custom message definition and syntax of the function used for reading the custom message from ros2 bag.
Your custom message must be created by using ros2genmsg function, before creating the ros2bag object.
You can refer to syntax and examples of ros2genmsg and ros2bag functions from below product documents. :
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Custom Message Support에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!