Getting the data from the rosbag msg, when the data is an array

5 ビュー (過去 30 日間)
Bren Pierce
Bren Pierce 2019 年 3 月 22 日
回答済み: Bren Pierce 2019 年 3 月 27 日
I can read data from my bag files, which works and I can plot the data
filepath = '/home/bren/rosbag/data/2019-03-21-17-06-24.bag'
bag = rosbag(filepath);
motors = select(bag, 'Topic', '/pennybot/motors');
update_ms = timeseries(motors,'UpdateDurationMs');
set_ms = timeseries(motors,'SetVelDurationMs');
But I can't figure out how to read from an array. I've tried a number of ways, but none work, for example:
rpm_l = timeseries(motors,'Rpm[1]');
This is the msg:
Header header
string[] name
# Feedback from the motors
float64[] rpm
# feedback from the controller
float64[] desired_rpm
float64 update_duration_ms
float64 set_vel_duration_ms
bool motor_error
I'm also can't read the motor_error, does matlab support. When I use the rosmsg info, it says the motor_error is 'logical MotorError'. So is there away to plot this boolean?

回答 (2 件)

Cam Salzberger
Cam Salzberger 2019 年 3 月 25 日
Hello Bren,
Rather than using timeseries, try using readMessages to extract messages from your rosbag selection object. Try it with both "DataFormat", "struct" and without if you are having issues with that as well.
-Cam

Bren Pierce
Bren Pierce 2019 年 3 月 27 日
Perfect, thanks you Cam
For people that might find this msg this code worked for me.
bagselect = rosbag(filepath);
motors = select(bagselect,'Time',[bagselect.StartTime bagselect.StartTime + 1],'Topic','/pennybot/motors');
motorsMsgs = readMessages(motors);
motorsMsgs{0}.Rpm

カテゴリ

Help Center および File ExchangeROS Log Files and Transformations についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by