Skip to content

Commit e668f03

Browse files
authored
Updated Heading and Orientation Calculations to be Consistent with ROS 1 branch (#216)
1 parent 8bc735e commit e668f03

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ublox_gps/src/hp_pos_rec_product.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ void HpPosRecProduct::callbackNavRelPosNed(const ublox_msgs::msg::NavRELPOSNED9
5454
imu_.angular_velocity_covariance[0] = -1;
5555

5656
// Transform angle since ublox is representing heading as NED but ROS uses ENU as convention (REP-103).
57-
// Alos convert the base-to-rover angle to a robot-to-base angle (consistent with frame_id).
58-
double heading = (static_cast<double>(m.rel_pos_heading) * 1e-5 / 180.0 * M_PI) - M_PI_2;
57+
double heading = M_PI_2 - (static_cast<double>(m.rel_pos_heading) * 1e-5 / 180.0 * M_PI);
5958
tf2::Quaternion orientation;
6059
orientation.setRPY(0, 0, heading);
6160
imu_.orientation.x = orientation[0];
@@ -67,7 +66,7 @@ void HpPosRecProduct::callbackNavRelPosNed(const ublox_msgs::msg::NavRELPOSNED9
6766
imu_.orientation_covariance[8] = 1000.0;
6867
// When heading is reported to be valid, use accuracy reported in 1e-5 deg units
6968
if (m.flags & ublox_msgs::msg::NavRELPOSNED9::FLAGS_REL_POS_HEAD_VALID) {
70-
imu_.orientation_covariance[8] = ::pow(m.acc_heading / 10000.0, 2);
69+
imu_.orientation_covariance[8] = ::pow(m.acc_heading * 1e-5 / 180.0 * M_PI, 2);
7170
}
7271

7372
imu_pub_->publish(imu_);

0 commit comments

Comments
 (0)