kauailabs / navxmxp

Robotics Navigation Sensors. NavX-MXP designed for the National Instruments RoboRIO & FIRST FRC Robotics. Navx-MIcro designed for Android-based FIRST FTC Robots
MIT License
105 stars 89 forks source link

How to setFusedHeading in navx mxp #102

Closed mendax1234 closed 3 years ago

mendax1234 commented 3 years ago

We use the first version of navx , not the second. How can we setFusedHeading in it?

kauailabs commented 3 years ago

Do you mean getFusedHeading()?

This is an advanced feature, requiring careful magnetometer calibration and use within an environment without large magnetic anomalies. Unless the magnetometer has been properly calibrated, and is in an environment without magnetic field disturbances. This feature is not typically recommended for FRC robotics teams.

If the magnetometer is not calibrated, then the value from getFusedHeading() is identical to the value returned from getYaw().

Also note that even a calibrated magnetometer is less accurate than a gyroscope over a short period of time. So by using fused heading, you may be introducing unwanted errors. So again, this is an advanced feature.

Link to Magnetometer Calibration Info.

Also, the navXUI page describes how some of this information is displayed. Fused Heading is called "Heading" in the navXUI. If you do choose to use it, you can monitor it's behavior here.

mendax1234 commented 3 years ago

Emmm , thanks . l just want to achieve field-oriented mode on my swerve. l now use getYaw(), however , the field-oriented doesn't seem to work well. l try to look at the Yaw angle when l rotate my robot. When l rotate from 0 to 45 in clockwise direction , the angle seems to be -168.2699. l don't know why it be this ?

kauailabs commented 3 years ago

When l rotate from 0 to 45 in clockwise direction , the angle seems to be -168.2699.

Which angle? getYaw()? Or getFusedHeading()?

Orientation is important. Is the board mounted following the guidelines here https://pdocs.kauailabs.com/navx-mxp/installation/roborio-installation/? One of the board axes needs to be perpendicular to the earth. And if the board Z axis is not pointing up, then you'll need to run omnimount to calibrate the board to use that orientation.

On Wed, Sep 29, 2021 at 2:28 PM mendax1234 @.***> wrote:

Emmm , thanks . l just want to achieve field-oriented mode on my swerve. l now use getYaw(), however , the field-oriented doesn't seem to work well. l try to look at the Yaw angle when l rotate my robot. When l rotate from 0 to 45 in clockwise direction , the angle seems to be -168.2699. l don't know why it be this ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kauailabs/navxmxp/issues/102#issuecomment-930644869, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXLTCB7PKDPC7UDSKICMF3UEOVLNANCNFSM5E7CYRVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Scott Libert - Founder, Kauai Labs https://www.kauailabs.com

mendax1234 commented 3 years ago

GetYaw

l check it again, it seems that it is installed on the roborio correctly.

One of the board axes needs to be perpendicular to the earth. And if the board Z axis is not pointing up, then you'll need to run omnimount to calibrate the board to use that orientation.

What does this mean? If l install it just like the docs shows , is that correct? Do l need to calibrate again?

mendax1234 commented 3 years ago

Besides, how to set the navx's yaw angle increase for counter clockwise

kauailabs commented 3 years ago

If l install it just like the docs shows , is that correct?

If you install it like shown on the "Roborio installation page", and as long as the roborio is "flat" (not tilted) with respect to earth, then yes, by definition the Z axis will be "up", and the Z axis will be perpendicular https://en.wikipedia.org/wiki/Perpendicularto the earth. This meets the conditions for correct orientation of the navX-sensor's 3D coordinate system with respect to the robot.

You can learn more about the 3D coordinate system on the Terminology https://pdocs.kauailabs.com/navx-mxp/guidance/terminology/page. There is lots of helpful and educational info in this section and other pages in the "Guidance https://pdocs.kauailabs.com/navx-mxp/guidance/" section. For best results, it's recommended to review this material carefully.

Do l need to calibrate again?

It's recommended. And it's absolutely required if the last time Factory Calibration occurred the conditions described above were not met.

After verifying orientation, and after successfully performing Factory Calibration (reminder: the board must be still during the Factory Calibration), then you can use the navXUI. If you reset the yaw so that it's zero, you should then be able to rotate the roborio and see the angle updated in the navXUI.

On Wed, Sep 29, 2021 at 5:09 PM mendax1234 @.***> wrote:

GetYaw

l check it again, it seems that it is installed on the roborio correctly.

One of the board axes needs to be perpendicular to the earth. And if the board Z axis is not pointing up, then you'll need to run omnimount to calibrate the board to use that orientation.

What does this mean? If l install it just like the docs shows , is that correct? Do l need to calibrate again?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kauailabs/navxmxp/issues/102#issuecomment-930727022, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXLTCG5R2JFTOCHKQ6JEZ3UEPIF3ANCNFSM5E7CYRVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Scott Libert - Founder, Kauai Labs https://www.kauailabs.com

kauailabs commented 3 years ago

how to set the navx's yaw angle increase for counter clockwise

Multiplying the returned yaw value by -1 seems like a very simple, straightforward solution.

On Wed, Sep 29, 2021 at 5:10 PM mendax1234 @.***> wrote:

Besides, how to set the navx's yaw angle increase for counter clockwise

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kauailabs/navxmxp/issues/102#issuecomment-930728525, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXLTCFYSOYMBCUNI4UF5D3UEPII7ANCNFSM5E7CYRVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Scott Libert - Founder, Kauai Labs https://www.kauailabs.com

mendax1234 commented 3 years ago

Thanks very much, where can navxui be installed?

kauailabs commented 3 years ago

See instructions at bottom of navXUi page linked to in my last email.

On Sep 30, 2021, at 2:49 PM, mendax1234 @.***> wrote:

 Thanks very much, where can navxui be installed?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

mendax1234 commented 3 years ago

Thanks,l will soon dig into it.

mendax1234 commented 3 years ago

Really Thanks. After testing my navx, l have found where is the error. l instantiate the ahrs in a heading file , and this bring all strange bugs. After instantiating it in the "cc" file, everything goes well. Now the field-oriented is achieved.

Really thanks for you idea to debug. l first use navxUI to ensure that my navx is working well. Them , l dig into the code and find this really small but fatal bug!