Remapping BNO055 to be vertical

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
joaep2
 
Posts: 1
Joined: Sun Nov 14, 2021 4:44 pm

Remapping BNO055 to be vertical

Post by joaep2 »

Hello,

I've recently been trying to re-map the BNO055 so that it can be mounted vertically like this:

new Z, (up) [old X]
^
|
|
|||
||| --> new X (right) [old Z]
|||
|
|

and Y would be going into the screen. (The vertical lines are the bottom of the board it's mounted on, the triple "|||" is the thin and short face of the chip. The dot on the chip is on top, closer to you, facing out to the right. We use a particular pre-made breakout board to mount it, and we needed to save space by having the breakout board be vertical.)

I found the forum answers on this to not be very clear about how to use the remapping bits, so I thought I would post my solution here. All the following code goes in the setup() function. After beginning Serial process and using

Code: Select all

if !bno.begin()
, the core code is:

Code: Select all

  if (vertical_orientation){
    bno.setAxisRemap(Adafruit_BNO055::REMAP_CONFIG_P8); 
    bno.setAxisSign(Adafruit_BNO055::REMAP_SIGN_P0);
  } else{
    bno.setAxisRemap(Adafruit_BNO055::REMAP_CONFIG_P1); // default
    bno.setAxisSign(Adafruit_BNO055::REMAP_SIGN_P1); // default
  }
where I've added a valueto the typedef adafruit_bno055_axis_remap_config_t:

Code: Select all

REMAP_CONFIG_P8 = 0x06
.

This comes from following the BNO055 datasheet on pg 24 (https://cdn-shop.adafruit.com/datasheet ... 000_12.pdf), remapping Z --> X, X--> Z, and Y-->Y (00 00 01 10 --> 0x06). That particular remap wasn't in the Adafruit library so I just added it in Adafruit_BNO055.h. Further I had to flip the X sign so that pitch upwards was positive (00000 1 0 0 --> 0x04 --> REMAP_SIGN_P0).

The issue with the Euler angle math being inaccurate only seems to come into play with rolls of close to 90 degrees, and I don't expect to have rolls greater than 45 deg or so.

Hope this saves someone time in the future! Please let me know if you think I'm missing anything.

User avatar
gammaburst
 
Posts: 1015
Joined: Thu Dec 31, 2015 12:06 pm

Re: Remapping BNO055 to be vertical

Post by gammaburst »

Your BNO055 datasheet rev 1.2 is obsolete. Current rev is 1.7:
https://www.bosch-sensortec.com/product ... #documents

The BNO055 Euler angles go bad with only moderate tilt. For example, when I tilt the BNO so its quaternion indicates the equivalent of (roll=+30 pitch=+30 heading=0) degrees, its Euler angles indicate about (roll=+25 pitch=+34 heading=-8). At high tilt angles the Euler error becomes outrageous.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”