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()
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
}
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.