Skip to content

Commit

Permalink
Fixed a bug in mavros_extras/src/plugins/odom.cpp by switching lines …
Browse files Browse the repository at this point in the history
…175 and 180.

Rationale: The pose covariance matrix published to the /mavros/odometry/in topic is exclusively zeros. This is because the transformation matrix r_pose is initialised as zeros (line 140), then applied to the covariance matrix cov_pose (line 176) and then populated (line 180). Clearly the latter two steps should be the other way around, and the comments in the code appear to suggest that this was the intention, but that lines 175 and 180 were accidentally written the wrong way around. Having switched them, the pose covariance is now published to /mavros/odometry/in as expected.

JohnG897
  • Loading branch information
John Gifford authored and vooon committed Feb 10, 2021
1 parent c8e166e commit 7ccca3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mavros_extras/src/plugins/odom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ class OdometryPlugin : public plugin::PluginBase {
* Covariances parsing
*/
//! Transform pose covariance matrix
r_vel.block<3, 3>(0, 0) = r_vel.block<3, 3>(3, 3) = tf_child2child_des.linear();
r_pose.block<3, 3>(0, 0) = r_pose.block<3, 3>(3, 3) = tf_parent2parent_des.linear();
cov_pose = r_pose * cov_pose * r_pose.transpose();
Eigen::Map<Matrix6d>(odom->pose.covariance.data(), cov_pose.rows(), cov_pose.cols()) = cov_pose;

//! Transform twist covariance matrix
r_pose.block<3, 3>(0, 0) = r_pose.block<3, 3>(3, 3) = tf_parent2parent_des.linear();
r_vel.block<3, 3>(0, 0) = r_vel.block<3, 3>(3, 3) = tf_child2child_des.linear();
cov_vel = r_vel * cov_vel * r_vel.transpose();
Eigen::Map<Matrix6d>(odom->twist.covariance.data(), cov_vel.rows(), cov_vel.cols()) = cov_vel;

Expand Down

0 comments on commit 7ccca3e

Please sign in to comment.