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

Feature Request: Flag for changing NED to ENU frame #151

Closed
austin-InDro opened this issue Jul 11, 2022 · 3 comments
Closed

Feature Request: Flag for changing NED to ENU frame #151

austin-InDro opened this issue Jul 11, 2022 · 3 comments

Comments

@austin-InDro
Copy link

austin-InDro commented Jul 11, 2022

The current IMU uses the NED frame.

I believe it would be a nice feature if the IMU could be automatically set up to be in the ENU frame by doing the following to the acceleration, gyroscope, and magnetometer data as the ROS navigation stack requires IMUs to be in the ENU Frame,.

    // set linear acceleration
    msg->linear_acceleration.x = last_accel_x_;
    msg->linear_acceleration.y = last_accel_y_;
    msg->linear_acceleration.z = last_accel_z_;

    // set angular velocities
    msg->angular_velocity.x = last_gyro_x_;
    msg->angular_velocity.y = last_gyro_y_;
    msg->angular_velocity.z = last_gyro_z_;

    imu_pub_->publish(std::move(msg));

    // Fill out and publish magnetic message
    mag_msg->header.frame_id = frame_id_;

    mag_msg->header.stamp = ros_time;

    mag_msg->magnetic_field.x = last_mag_x_;
    mag_msg->magnetic_field.y = last_mag_y_;
    mag_msg->magnetic_field.z = last_mag_z_;

to

    // set linear acceleration
    msg->linear_acceleration.x = last_accel_y_; 
    msg->linear_acceleration.y = last_accel_x_;
    msg->linear_acceleration.z = - last_accel_z_;

    // set angular velocities
    msg->angular_velocity.x = last_gyro_y_;
    msg->angular_velocity.y = last_gyro_x_;
    msg->angular_velocity.z = - last_gyro_z_;

    imu_pub_->publish(std::move(msg));

    // Fill out and publish magnetic message
    mag_msg->header.frame_id = frame_id_;

    mag_msg->header.stamp = ros_time;

    mag_msg->magnetic_field.x = last_mag_y_;
    mag_msg->magnetic_field.y = last_mag_x_;
    mag_msg->magnetic_field.z = - last_mag_z_;
@clalancette
Copy link
Contributor

I agree that this would be a good feature to have. We added it to some other drivers in the past; see KumarRobotics/imu_vn_100@4441de2 for instance.

I'll warn that I don't think the above math is correct for converting NED to ENU. As far as I remember (it's been a while), you need to do something like https://github.com/KumarRobotics/imu_vn_100/blob/3ada41525b83b955f3d5a229c3d1f67dc31e7200/src/imu_vn_100.cpp#L722-L724 .

@austin-InDro
Copy link
Author

Thanks for the link @clalancette, I don't believe that's needed for the Phidget_spatial library though (sorry, I forgot to specifiy which library I was talking about). There is not quaternion published, I use the imu_filter_madgwick fo that. I've found a few links mentioning that this way works for the conversion. Here is one linked,
mavlink/mavros#49

However, the link posted I believe is correct once the quaternion has been generated from the acc, gyro and mag values.

@mintar
Copy link
Contributor

mintar commented Aug 19, 2022

Closing this as resolved. As you stated, the phidgets spatial does not publish orientations (yet), so NED / ENU / ... doesn't apply here. Feel free to reopen if necessary!

@mintar mintar closed this as completed Aug 19, 2022
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

3 participants