필터 지우기
필터 지우기

Reading Custom Messages from ROS2 bag files without redefining messages

조회 수: 34 (최근 30일)
megalomaniac
megalomaniac 2023년 9월 22일
댓글: Varun 2024년 1월 31일
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
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!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Publishers and Subscribers에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by