Function readMessages(from ROS toolbox) can't read message type "nmea_msgs/Sentence".

11 ビュー (過去 30 日間)
Kevin Tarn
Kevin Tarn 2021 年 3 月 29 日
編集済み: Kevin Tarn 2021 年 3 月 30 日
To reproduce this BUG:
>> bag = rosbag('any bag contains nmea sentence')
>> nmea = select(bag,"MessageType","nmea_msgs/Sentence")
>> readMessages(nmea,3)
When using readMessages, no matter which row you try to read, you will get this error:
Reference to non-existent field 'Sentence_'.
Error in ros.BagSelection/copyFromStruct (line 661)
cobj.(fc) = objArray(:);
Error in ros.BagSelection/getClassFromStruct (line 630)
ros1msg{k,1} = obj.copyFromStruct(ros1msg{k,1},msgStructs{k});
Error in ros.BagSelection/readMessages (line 275)
msgs = obj.getClassFromStruct(msgStructs);

回答 (1 件)

Karthik Reddy Vennapureddy
Karthik Reddy Vennapureddy 2021 年 3 月 29 日
Hello Kevin Tarn,
Thanks for reporting the issue. May I know which version of MATLAB are you using? Here are the quick workarounds, which can circumvent this error.
workaround 1: you can try to use 'DataFormat', 'struct' options to read messages from the bag file. I would recommend changing the following line
readMessages(nmea,3)
to
readMessages(nmea, 3, 'DataFormat', 'struct')
This reads messages much faster compared to reading class objects.
workaround 2: If you do not want to use 'DataFormat','struct' options for reading messages, please reach out to Tech Support team.
Thanks,
Karthik Reddy
  1 件のコメント
Kevin Tarn
Kevin Tarn 2021 年 3 月 30 日
編集済み: Kevin Tarn 2021 年 3 月 30 日
I'm using 2020b.
And actually I make a workaround myself:
  1. Open "C:\Program Files\MATLAB\R2020b\toolbox\ros\mlroscpp\+ros\BagSelection.m" in text editor with privilege.
  2. Go to line 661: cobj.(fc) = strObj.(fc);
  3. Replace it with:
if fc(end)=='_'
cobj.(fc) = strObj.(fc(1:end-1));
else
cobj.(fc) = strObj.(fc);
end
This works fine so far (shrug

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNetwork Connection and Exploration についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by