Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular velocity is composed differently in the IMU msg versus the Velocity msg #16

Open
crazy-harry opened this issue May 17, 2023 · 2 comments

Comments

@crazy-harry
Copy link

sensor_msgs::msg::Imu imu(const NComRxC *nrx, std_msgs::msg::Header head) {
  ....
  ....
  ....
  // Rotate angular rate data before copying into message ----------------------
  veh_w = tf2::Vector3(nrx->mWx, nrx->mWy, nrx->mWz);
  veh_w *= NAV_CONST::DEG2RADS;
  imu_w = tf2::quatRotate(q_vat, veh_w);
  msg.angular_velocity.x = imu_w.x();
  msg.angular_velocity.y = imu_w.y();
  msg.angular_velocity.z = imu_w.z();
  msg.angular_velocity_covariance[0] = 0.0; // Row major about x, y, z axes
  // ...
  msg.angular_velocity_covariance[8] = 0.0;
  ....
  ....
  ....
  return msg;
}

geometry_msgs::msg::TwistStamped velocity(const NComRxC *nrx,
                                          std_msgs::msg::Header head) {
  auto msg = geometry_msgs::msg::TwistStamped();
  msg.header = std::move(head);

  // Construct vehicle-imu frame transformation --------------------------------
  auto q_vat = getVat(nrx);
  auto r_vat = tf2::Matrix3x3(q_vat);
  auto veh_v = tf2::Vector3(nrx->mIsoVoX, nrx->mIsoVoY, nrx->mIsoVoZ);
  auto veh_w = tf2::Vector3(nrx->mWx, nrx->mWy, nrx->mWz);
  auto imu_w = tf2::Vector3();
  auto imu_v = tf2::Vector3();
  auto q_iso_oxts = tf2::Quaternion();

  q_iso_oxts.setRPY(180.0 * NAV_CONST::DEG2RADS, 0.0, 0.0);
  auto r_iso_oxts = tf2::Matrix3x3(q_iso_oxts);

  imu_v = r_vat * r_iso_oxts * veh_v;
  imu_w = r_vat * veh_w;
  ....
  ....
  ....

  return msg;
}

When parsing and building both the IMU and velocity messages, the vehicle frame angular velocity (veh_w) is initialized the same with the <mWx, mWy, mWz> measurements, but the IMU message has this converted to radians while the velocity veh_w skips this step.

Is there any reason why the resulting imu_w is using radians/sec in the IMU message vs the velocity message using deg/sec? They are both in the INS/IMU frame

@ljones-oxts
Copy link
Contributor

Hi @jake-from-safeai

Thanks for your question. To my knowledge, there is no reason why they would be encoded differently. Indeed the only possible reason why one is encoded in deg/s would be due to our desktop software's preference for deg/s as a user-friendly unit of angular rate.

My understanding is that, as an ecosystem, ROS2 prefers the rad/s unit, am I correct? In which case, my gut instinct tells me the fix would be to encode both in rad/s.

Thanks

Llyr Jones

@crazy-harry
Copy link
Author

Given the ROS2 msg output from the driver has both the IMU and Velocity msgs embedded in it, I would think they would atleast in the same units. Could be pretty confusing for someone reading the output of the driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants