ROS Toolbox - Can't access a ROS Message Array

조회 수: 9 (최근 30일)
Jeff Vandegrift
Jeff Vandegrift 2019년 10월 29일
답변: Cam Salzberger 2020년 5월 1일
(cannot paste from clip board to here so I'm retyping by hand)
uwb_ts = timeseries(uwb, 'Pose.Pose.Position.X', Pose.Pose.Position.Y', 'Pose.Covariance')
where uwb is a nav_msgs/Odometry message
I can Read the scalars but I can't read the array. I don't see any examples of getting arrays.
Matlab sees this as: (can't paste into this buffer so trust me, it's Pose.Covariance) yet it crashes with a no such thing message
  댓글 수: 1
Jeff Vandegrift
Jeff Vandegrift 2019년 10월 30일
I switched from calling timeseries(<rosbag>, 'Pose.Covariance') which assumes timeseries() is working for all non-custom message types. So now I select the topic, execute readMessages(), and then iterate on the messages. So something like messages{1}.Pose.Covariance{1} gives me the XX covariance for the first message. This does appear to be slower than letting timeseries do the work, but I haven't proven that yet by removing only the covariance access and then comparing the two methods (timeseries will work with X,Y positions as long as I don't attempt to get the covariance vector).

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

답변 (2개)

Jeff Vandegrift
Jeff Vandegrift 2019년 10월 30일
I've attached more detail including the error message.

Cam Salzberger
Cam Salzberger 2020년 5월 1일
Hello Jeff,
I know this is pretty old, but I wanted to get visibility on the reason for this error. I've just answered a similar question here.
The issue is that the timeseries method for BagSelection objects is only valid for use with numerical and scalar data. The Covariance field is an array, so timeseries cannot extract it. I understand that the error message is confusing, and have submitted a request to the appropriate team to look into improving it.
If you make use of readMessages(..., "DataFormat", "struct"), that is generally much faster than the standard "readMessages". It's a good way to get quick access to data.
-Cam

카테고리

Help CenterFile Exchange에서 Specialized Messages에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by