How to extract data from sensor_msgs/Joy ROS as timeseries in MATLAB script?
12 views (last 30 days)
Thanks for your help. I am working with rosbag files in MATLAB R2016B. Following the examples in https://www.mathworks.com/help/robotics/examples/work-with-rosbag-logfiles.html I try to extract data from sensor_msgs/Joy from an specific topic like this:
bagselection_setpoint_attitude = select(bag,'Topic','/controlbot/joystick'); ts_setpoint_attitude = timeseries(bagselection_setpoint_attitude);
When I type ts_setpoint_attitude.Data the answer is:
0 0 0
1 0 0
2 0 0
3 0 0
4 0 0
5 0 0
6 0 0
But this type of messages contains Header, Axes and Buttons. If I use the following code:
>> test = readMessages(bagselection_setpoint_attitude)
The result is:
946×1 cell array
If I go into each cell, the property Axes which is that I need, show the correct values:
4×1 single column vector
Why when I work with timeseries, the data is not visualized correctly? In fact the size of timeseries columns is not correct?
How can I access to Axes data from this type of message successfully?
MathWorks Robotics and Autonomous Systems Team on 5 Dec 2017
As shown in the example: https://www.mathworks.com/help/robotics/ref/timeseries.html
>> filepath = fullfile(fileparts(which('ROSWorkingWithRosbagsExample')), 'data', 'ex_multiple_topics.bag'); bag = rosbag(filepath); >> bagSelection = select(bag,'Topic','/odom'); >> ts = timeseries(bagSelection,'Pose.Pose.Position.X');
There was only one topic in the "bagSelection" variable, and then only one data from Pose data was extracted and was put in timeseries fashion.
Follow a similar pattern and you will be able to extract the data you are looking for.