sparkfun / SparkFun_BNO080_Arduino_Library

An Arduino Library for the BNO080 IMU combination triple axis accelerometer/gyro/magnetometer packaged with an ARM Cortex M0+ running powerful algorithms.
Other
77 stars 62 forks source link

Feature Request: Please could you implement the TARE function? Thank you! #83

Closed michroz2 closed 1 year ago

michroz2 commented 3 years ago

Please could you implement the TARE function? Thank you!

The BNO08X have Tare function described in the "SH-2 Reference Manual Document Number: 1000-3625" and "1000-4045 - App Note BNO080/BNO085 Tare Function Usage Guide" I find this feature useful for the cases of BNO08X installations independent of the ground level. I actually implemented this function for me, but for my specific case of Game Vector and XYZ axes only, while for the public library it probably should feature all possible bells and whistles.

Your workbench

*irrelevant

Steps to reproduce

irrelevant

Expected behavior

The BNO08X should "Tare", i.e. re-orient their vectors according to the current actual position of the local G and M vectors.

Actual behavior

No such function in the library

Below is my humble implementation of the Tare (based on version 1.1.9)

.h file: void sendCommand(uint8_t command); void sendTareGameXYZCommand(); //MR> I added this command to this library for my project - by example. void sendCalibrateCommand(uint8_t thingToCalibrate); .cpp file: //MR> This tells the BNO080 to Tare //MR> See page 45 of reference manual void BNO080::sendTareGameXYZCommand() { /Setting the shtpData[] byte Name Description 3 P0 0x00 – Subcommand: Perform Tare now 4 P1 Bitmap of axes to tare: Bit 0= X, Bit 1= Y, Bit 2= Z MR> 7 = X,Y,Z 5 P2 Rotation Vector to use as basis for tare. 0: Rotation Vector 1: Gaming Rotation Vector MR> This! 2: Geomagnetic Rotation Vector 3: Gyro-Integrated Rotation Vector 4: ARVR-Stabilized Rotation Vector 5: ARVR-Stabilized Game Rotation Vector 6 P3 Reserved 7 P4 Reserved 8 P5 Reserved 9 P6 Reserved 10 P7 Reserved 11 P8 Reserved /

for (uint8_t x = 3; x < 12; x++) //Clear this section of the shtpData array
    shtpData[x] = 0;

shtpData[4] = 7; //all axes
shtpData[5] = 1; //game rotation vector

//Using this shtpData packet, send a command 0x03
sendCommand(COMMAND_TARE);

}

//This tells the BNO080 to begin calibrating //See page 50 of reference manual and the 1000-4044 calibration doc void BNO080::sendCalibrateCommand(uint8_t thingToCalibrate) { ...

PaulZC commented 3 years ago

Hi Michael (@michroz2 ), This is a reasonable request, but we will not be able to implement it any time soon. If you want to send us a Pull Request, that would be great. Best wishes, Paul

michroz2 commented 3 years ago

Thanks Paul! Maybe I will. I am just a hobbyist programmer though. Best to you, Mich

On Thu, Apr 8, 2021 at 10:45 AM Paul @.***> wrote:

Hi Michael @.*** https://github.com/michroz2 ), This is a reasonable request, but we will not be able to implement it any time soon. If you want to send us a Pull Request, that would be great. Best wishes, Paul

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/issues/83#issuecomment-815533869, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKJS6APGMC5GZAHY5GPM2SLTHVNI3ANCNFSM42SJLWKA .

sofian commented 2 years ago

I have implemented it and would be happy to provide a pull request. What would be the preferred API? Tare has a number of options, namely:

How about something like this:

void tare(bool zAxis=false); // <-- tare now

Or:

void tareNow(bool zAxis=false); // <-- tare now

Or:

void tareZ(); // <-- tare now according to z-axis
void tareAll(); // <-- tare now according to all axis

For the "persist" I would suggest:

void saveTare(); // <-- tare persist
michroz2 commented 2 years ago

My vote is for the second option. Thank you!

On Wed, Mar 2, 2022 at 12:36 AM Sofian Audry @.***> wrote:

I have implemented it and would be happy to provide a pull request. What would be the preferred API? Tare has a number of options, namely:

  • "tare now" with options for "z axis only" or "all axis"
  • "tare persist" which makes the tare persistent

How about something like this:

void tare(bool zAxis=false); // <-- tare now

Or:

void tareNow(bool zAxis=false); // <-- tare now

Or:

void tareZ(); // <-- tare now according to z-axisvoid tareAll(); // <-- tare now according to all axis

For the "persist" I would suggest:

void saveTare(); // <-- tare persist

— Reply to this email directly, view it on GitHub https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/issues/83#issuecomment-1055927555, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKJS6AM6SNKOCUA25M3JRV3U52LVVANCNFSM42SJLWKA . 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.

You are receiving this because you were mentioned.Message ID: @.***>

sofian commented 2 years ago

Just did it, let me know what you think.

michroz2 commented 2 years ago

I will, but I'm only able at the next update of my project, happening, hopefully this year. Did you use this function in your project or what was your incentive for doing this update? Best and Thank You!

On Thu, Mar 3, 2022 at 4:27 AM Sofian Audry @.***> wrote:

Just did it, let me know what you think.

— Reply to this email directly, view it on GitHub https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/issues/83#issuecomment-1057603069, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKJS6AORFY3RK2BMSSXENF3U6APSHANCNFSM42SJLWKA . 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.

You are receiving this because you were mentioned.Message ID: @.***>

sofian commented 2 years ago

I needed it for one of my own projects. No problem about the update, just happy to contribute.

PaulZC commented 1 year ago

Hi Michael (@michroz2 ),

Apologies for the very slow reply. I have merged @sofian 's code. I will up-issue the library once I have tested it.

Closed by #99 .

Best wishes, Paul

michroz2 commented 1 year ago

Thank you Paul!

On Mon, Jan 23, 2023 at 1:28 PM Paul @.***> wrote:

Hi Michael @.*** https://github.com/michroz2 ),

Apologies for the very slow reply. I have merged @sofian https://github.com/sofian 's code. I will up-issue the library once I have tested it.

Closed by #99 https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/pull/99 .

Best wishes, Paul

— Reply to this email directly, view it on GitHub https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/issues/83#issuecomment-1400192833, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKJS6ALOLDFBEIZR4KF23CTWTZTMLANCNFSM42SJLWKA . You are receiving this because you were mentioned.Message ID: @.***>