Skip to content

Commit 8a13912

Browse files
authored
Populate pose covariance correctly in steering controllers (backport #2109) (#2137)
1 parent 3e5e153 commit 8a13912

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

steering_controllers_library/src/steering_controllers_library.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,15 @@ controller_interface::CallbackReturn SteeringControllersLibrary::on_configure(
355355
odom_state_msg_.child_frame_id = params_.base_frame_id;
356356
odom_state_msg_.pose.pose.position.z = 0;
357357

358-
auto & covariance = odom_state_msg_.twist.covariance;
359-
constexpr size_t NUM_DIMENSIONS = 6;
360-
for (size_t index = 0; index < 6; ++index)
361-
{
362-
// 0, 7, 14, 21, 28, 35
363-
const size_t diagonal_index = NUM_DIMENSIONS * index + index;
364-
covariance[diagonal_index] = params_.pose_covariance_diagonal[index];
365-
covariance[diagonal_index] = params_.twist_covariance_diagonal[index];
358+
const size_t NUM_DIMENSIONS = 6;
359+
auto & pose_cov = odom_state_msg_.pose.covariance;
360+
auto & twist_cov = odom_state_msg_.twist.covariance;
361+
for (size_t i = 0; i < NUM_DIMENSIONS; ++i)
362+
{
363+
// indices of the diagonal: 0, 7, 14, 21, 28, 35
364+
const size_t index = (NUM_DIMENSIONS + 1) * i;
365+
pose_cov[index] = params_.pose_covariance_diagonal[i];
366+
twist_cov[index] = params_.twist_covariance_diagonal[i];
366367
}
367368

368369
try

0 commit comments

Comments
 (0)