Ask Your Question
0

Plotting covariance from amcl_pose in Matlab

asked 2020-03-05 02:16:37 -0500

fendrbud gravatar image

updated 2020-03-05 02:17:29 -0500

I have recorded a bag-file and am trying to plot the /amcl_pose/pose/covariance matrix which has a message type geometry_msgs/PoseWithCovarianceStamped. I followed this tutorial on plotting data from topics, however, when I try:

bagselect = select(bag, 'Topic', '/amcl_pose');
msgs = readMessages(bagselect);
ts = timeseries(bagselect, 'Pose.Covariance');

I Get the error:

The Pose.covariance property does not exist for message type geometry_msgs/PoseWithCovarianceStamped.

What am I doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-05 02:46:02 -0500

fendrbud gravatar image

updated 2020-03-05 02:46:29 -0500

I found out I have to read the messages as structures as in this example.

bSel = select(bag, 'Topic', '/amcl_pose');
msgStructs = readMessages(bSel, 'DataFormat', 'struct');

I am then able to read amcl_pose as a struct and can then extract the first covariance matrix by

msgStructs{1}.Pose.Covariance

I now have to iterate through all the matrices and concatenate them in order to plot their values.

edit flag offensive delete link more

Comments

I've converted your comment to an answer as it would appear this is the answer.

To link it to my comment about the covariance field not being at the top-level of the message (but at pose.pose.covariance: it would appear msgStructs{1} contains the top-level message contents. So then pose.covariance does exist there.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-05 02:58:40 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-03-05 02:16:37 -0500

Seen: 50 times

Last updated: Mar 05