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

Adafruit bno055 update + added position configs #124

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c1c0723
changed cal offsets to signed ints
ronzeiller Jan 11, 2018
735c0b3
Minor cal cleanup (better comments, etc.) Update to V1.1.6
ronzeiller Jan 11, 2018
7b522a1
Update to 1.1.6
ronzeiller Jan 11, 2018
e01a593
changed calibrationdata from uint_8 to int
ronzeiller Jan 11, 2018
ccb22b8
back to uint16_t for calibrationData[22]
ronzeiller Jan 12, 2018
c9febf0
corrected comment
ronzeiller Jan 14, 2018
e0a5e21
config: now all horizontal positions, vars changed to lower case letters
ronzeiller Jan 15, 2018
69b2545
added kbox-config.json as individual user's config file
ronzeiller Jan 16, 2018
53b8147
change to more generic wording of mounting positions (KBox+free Sensor)
ronzeiller Jan 17, 2018
89bdb3e
verticalPortHull, verticalStbHull added, heel +/-ve corrected
ronzeiller Jan 17, 2018
9c57dc2
updated comments for IMU-sensor/KBox positioning
ronzeiller Jan 17, 2018
6d2e3e1
Merge remote-tracking branch 'upstream/master' into adafruit_bno055_u…
ronzeiller Mar 5, 2018
2ce4d1d
Color of displayed values now correspond to if values are sent
ronzeiller Mar 5, 2018
a96150d
deleted deprecated mounting positions
ronzeiller Apr 28, 2018
702b57d
added individual user's config file
ronzeiller Apr 28, 2018
63b8c44
added [env:teensy3.6]
ronzeiller Apr 28, 2018
4e0d1bf
added BOARD_ronzei (Teensy 3.6 based KBox development prototype)
ronzeiller Apr 29, 2018
4cc5d12
Merge remote-tracking branch 'upstream/master' into adafruit_bno055_u…
ronzeiller May 19, 2018
420e11a
Merge remote-tracking branch 'upstream/master' into adafruit_bno055_u…
ronzeiller Dec 9, 2018
1f9dde7
corrected bug in inverting angles
ronzeiller Dec 10, 2018
89028f8
back to uptodate master branch
ronzeiller Dec 10, 2018
5bf933f
doc: changelog for v1.3.7
ronzeiller Dec 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 54 additions & 23 deletions lib/Adafruit_BNO055/Adafruit_BNO055.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,19 +442,35 @@ bool Adafruit_BNO055::getSensorOffsets(adafruit_bno055_offsets_t &offsets_type)
setMode(OPERATION_MODE_CONFIG);
delay(25);

/* Accel offset range depends on the G-range:
+/-2g = +/- 2000 mg
+/-4g = +/- 4000 mg
+/-8g = +/- 8000 mg
+/-1§g = +/- 16000 mg */
offsets_type.accel_offset_x = (read8(ACCEL_OFFSET_X_MSB_ADDR) << 8) | (read8(ACCEL_OFFSET_X_LSB_ADDR));
offsets_type.accel_offset_y = (read8(ACCEL_OFFSET_Y_MSB_ADDR) << 8) | (read8(ACCEL_OFFSET_Y_LSB_ADDR));
offsets_type.accel_offset_z = (read8(ACCEL_OFFSET_Z_MSB_ADDR) << 8) | (read8(ACCEL_OFFSET_Z_LSB_ADDR));

offsets_type.gyro_offset_x = (read8(GYRO_OFFSET_X_MSB_ADDR) << 8) | (read8(GYRO_OFFSET_X_LSB_ADDR));
offsets_type.gyro_offset_y = (read8(GYRO_OFFSET_Y_MSB_ADDR) << 8) | (read8(GYRO_OFFSET_Y_LSB_ADDR));
offsets_type.gyro_offset_z = (read8(GYRO_OFFSET_Z_MSB_ADDR) << 8) | (read8(GYRO_OFFSET_Z_LSB_ADDR));

/* Magnetometer offset range = +/- 6400 LSB where 1uT = 16 LSB */
offsets_type.mag_offset_x = (read8(MAG_OFFSET_X_MSB_ADDR) << 8) | (read8(MAG_OFFSET_X_LSB_ADDR));
offsets_type.mag_offset_y = (read8(MAG_OFFSET_Y_MSB_ADDR) << 8) | (read8(MAG_OFFSET_Y_LSB_ADDR));
offsets_type.mag_offset_z = (read8(MAG_OFFSET_Z_MSB_ADDR) << 8) | (read8(MAG_OFFSET_Z_LSB_ADDR));

/* Gyro offset range depends on the DPS range:
2000 dps = +/- 32000 LSB
1000 dps = +/- 16000 LSB
500 dps = +/- 8000 LSB
250 dps = +/- 4000 LSB
125 dps = +/- 2000 LSB
... where 1 DPS = 16 LSB */
offsets_type.gyro_offset_x = (read8(GYRO_OFFSET_X_MSB_ADDR) << 8) | (read8(GYRO_OFFSET_X_LSB_ADDR));
offsets_type.gyro_offset_y = (read8(GYRO_OFFSET_Y_MSB_ADDR) << 8) | (read8(GYRO_OFFSET_Y_LSB_ADDR));
offsets_type.gyro_offset_z = (read8(GYRO_OFFSET_Z_MSB_ADDR) << 8) | (read8(GYRO_OFFSET_Z_LSB_ADDR));

/* Accelerometer radius = +/- 1000 LSB */
offsets_type.accel_radius = (read8(ACCEL_RADIUS_MSB_ADDR) << 8) | (read8(ACCEL_RADIUS_LSB_ADDR));

/* Magnetometer radius = +/- 960 LSB */
offsets_type.mag_radius = (read8(MAG_RADIUS_MSB_ADDR) << 8) | (read8(MAG_RADIUS_LSB_ADDR));

setMode(lastMode);
Expand All @@ -475,6 +491,11 @@ void Adafruit_BNO055::setSensorOffsets(const uint8_t* calibData)
setMode(OPERATION_MODE_CONFIG);
delay(25);

/* Note: Configuration will take place only when user writes to the last
byte of each config data pair (ex. ACCEL_OFFSET_Z_MSB_ADDR, etc.).
Therefore the last byte must be written whenever the user wants to
changes the configuration. */

/* A writeLen() would make this much cleaner */
write8(ACCEL_OFFSET_X_LSB_ADDR, calibData[0]);
write8(ACCEL_OFFSET_X_MSB_ADDR, calibData[1]);
Expand All @@ -483,19 +504,19 @@ void Adafruit_BNO055::setSensorOffsets(const uint8_t* calibData)
write8(ACCEL_OFFSET_Z_LSB_ADDR, calibData[4]);
write8(ACCEL_OFFSET_Z_MSB_ADDR, calibData[5]);

write8(GYRO_OFFSET_X_LSB_ADDR, calibData[6]);
write8(GYRO_OFFSET_X_MSB_ADDR, calibData[7]);
write8(GYRO_OFFSET_Y_LSB_ADDR, calibData[8]);
write8(GYRO_OFFSET_Y_MSB_ADDR, calibData[9]);
write8(GYRO_OFFSET_Z_LSB_ADDR, calibData[10]);
write8(GYRO_OFFSET_Z_MSB_ADDR, calibData[11]);
write8(MAG_OFFSET_X_LSB_ADDR, calibData[6]);
write8(MAG_OFFSET_X_MSB_ADDR, calibData[7]);
write8(MAG_OFFSET_Y_LSB_ADDR, calibData[8]);
write8(MAG_OFFSET_Y_MSB_ADDR, calibData[9]);
write8(MAG_OFFSET_Z_LSB_ADDR, calibData[10]);
write8(MAG_OFFSET_Z_MSB_ADDR, calibData[11]);

write8(MAG_OFFSET_X_LSB_ADDR, calibData[12]);
write8(MAG_OFFSET_X_MSB_ADDR, calibData[13]);
write8(MAG_OFFSET_Y_LSB_ADDR, calibData[14]);
write8(MAG_OFFSET_Y_MSB_ADDR, calibData[15]);
write8(MAG_OFFSET_Z_LSB_ADDR, calibData[16]);
write8(MAG_OFFSET_Z_MSB_ADDR, calibData[17]);
write8(GYRO_OFFSET_X_LSB_ADDR, calibData[12]);
write8(GYRO_OFFSET_X_MSB_ADDR, calibData[13]);
write8(GYRO_OFFSET_Y_LSB_ADDR, calibData[14]);
write8(GYRO_OFFSET_Y_MSB_ADDR, calibData[15]);
write8(GYRO_OFFSET_Z_LSB_ADDR, calibData[16]);
write8(GYRO_OFFSET_Z_MSB_ADDR, calibData[17]);

write8(ACCEL_RADIUS_LSB_ADDR, calibData[18]);
write8(ACCEL_RADIUS_MSB_ADDR, calibData[19]);
Expand All @@ -517,27 +538,32 @@ void Adafruit_BNO055::setSensorOffsets(const adafruit_bno055_offsets_t &offsets_
setMode(OPERATION_MODE_CONFIG);
delay(25);

/* Note: Configuration will take place only when user writes to the last
byte of each config data pair (ex. ACCEL_OFFSET_Z_MSB_ADDR, etc.).
Therefore the last byte must be written whenever the user wants to
changes the configuration. */

write8(ACCEL_OFFSET_X_LSB_ADDR, (offsets_type.accel_offset_x) & 0x0FF);
write8(ACCEL_OFFSET_X_MSB_ADDR, (offsets_type.accel_offset_x >> 8) & 0x0FF);
write8(ACCEL_OFFSET_Y_LSB_ADDR, (offsets_type.accel_offset_y) & 0x0FF);
write8(ACCEL_OFFSET_Y_MSB_ADDR, (offsets_type.accel_offset_y >> 8) & 0x0FF);
write8(ACCEL_OFFSET_Z_LSB_ADDR, (offsets_type.accel_offset_z) & 0x0FF);
write8(ACCEL_OFFSET_Z_MSB_ADDR, (offsets_type.accel_offset_z >> 8) & 0x0FF);

write8(GYRO_OFFSET_X_LSB_ADDR, (offsets_type.gyro_offset_x) & 0x0FF);
write8(GYRO_OFFSET_X_MSB_ADDR, (offsets_type.gyro_offset_x >> 8) & 0x0FF);
write8(GYRO_OFFSET_Y_LSB_ADDR, (offsets_type.gyro_offset_y) & 0x0FF);
write8(GYRO_OFFSET_Y_MSB_ADDR, (offsets_type.gyro_offset_y >> 8) & 0x0FF);
write8(GYRO_OFFSET_Z_LSB_ADDR, (offsets_type.gyro_offset_z) & 0x0FF);
write8(GYRO_OFFSET_Z_MSB_ADDR, (offsets_type.gyro_offset_z >> 8) & 0x0FF);

write8(MAG_OFFSET_X_LSB_ADDR, (offsets_type.mag_offset_x) & 0x0FF);
write8(MAG_OFFSET_X_MSB_ADDR, (offsets_type.mag_offset_x >> 8) & 0x0FF);
write8(MAG_OFFSET_Y_LSB_ADDR, (offsets_type.mag_offset_y) & 0x0FF);
write8(MAG_OFFSET_Y_MSB_ADDR, (offsets_type.mag_offset_y >> 8) & 0x0FF);
write8(MAG_OFFSET_Z_LSB_ADDR, (offsets_type.mag_offset_z) & 0x0FF);
write8(MAG_OFFSET_Z_MSB_ADDR, (offsets_type.mag_offset_z >> 8) & 0x0FF);

write8(GYRO_OFFSET_X_LSB_ADDR, (offsets_type.gyro_offset_x) & 0x0FF);
write8(GYRO_OFFSET_X_MSB_ADDR, (offsets_type.gyro_offset_x >> 8) & 0x0FF);
write8(GYRO_OFFSET_Y_LSB_ADDR, (offsets_type.gyro_offset_y) & 0x0FF);
write8(GYRO_OFFSET_Y_MSB_ADDR, (offsets_type.gyro_offset_y >> 8) & 0x0FF);
write8(GYRO_OFFSET_Z_LSB_ADDR, (offsets_type.gyro_offset_z) & 0x0FF);
write8(GYRO_OFFSET_Z_MSB_ADDR, (offsets_type.gyro_offset_z >> 8) & 0x0FF);

write8(ACCEL_RADIUS_LSB_ADDR, (offsets_type.accel_radius) & 0x0FF);
write8(ACCEL_RADIUS_MSB_ADDR, (offsets_type.accel_radius >> 8) & 0x0FF);

Expand All @@ -547,6 +573,11 @@ void Adafruit_BNO055::setSensorOffsets(const adafruit_bno055_offsets_t &offsets_
setMode(lastMode);
}

/**************************************************************************/
/*!
@brief Checks of all cal status values are set to 3 (fully calibrated)
*/
/**************************************************************************/
bool Adafruit_BNO055::isFullyCalibrated(void)
{
uint8_t system, gyro, accel, mag;
Expand Down
24 changes: 12 additions & 12 deletions lib/Adafruit_BNO055/Adafruit_BNO055.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@

typedef struct
{
uint16_t accel_offset_x;
uint16_t accel_offset_y;
uint16_t accel_offset_z;
uint16_t gyro_offset_x;
uint16_t gyro_offset_y;
uint16_t gyro_offset_z;
uint16_t mag_offset_x;
uint16_t mag_offset_y;
uint16_t mag_offset_z;

uint16_t accel_radius;
uint16_t mag_radius;
int16_t accel_offset_x;
int16_t accel_offset_y;
int16_t accel_offset_z;
int16_t mag_offset_x;
int16_t mag_offset_y;
int16_t mag_offset_z;
int16_t gyro_offset_x;
int16_t gyro_offset_y;
int16_t gyro_offset_z;

int16_t accel_radius;
int16_t mag_radius;
} adafruit_bno055_offsets_t;

class Adafruit_BNO055 : public Adafruit_Sensor
Expand Down
3 changes: 1 addition & 2 deletions lib/Adafruit_BNO055/library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name=Adafruit BNO055
version=1.0.6
version=1.1.6
author=Adafruit <[email protected]>
maintainer=Adafruit <[email protected]>
sentence=Library for the Adafruit BNO055 Absolute Orientation Sensor.
paragraph=Designed specifically to work with the Adafruit BNO055 Breakout, and is based on Adafruit's Unified Sensor Library.
category=Sensors
url=https://github.com/adafruit/Adafruit_BNO055
architectures=*

2 changes: 1 addition & 1 deletion src/host/util/PersistentStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PersistentStorage {

struct IMUCalibration {
uint8_t mountingPosition;
uint8_t calibrationData[22]; // NUM_BNO055_OFFSET_REGISTERS
int calibrationData[22]; // NUM_BNO055_OFFSET_REGISTERS
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why int? it's an int16_t, no?

That is a huge bug - and it was all me! Definitely explains some of the weird results we were seeing. Thanks a lot for finding that - and sorry for screwing up your code ;)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there is no bug.

We are using the function getSensorOffsets(uint8_t* calibData) which reads the register as an array and writes them back as an array so the changes Adafruit did will not impact us. And we are reading the correct size: 22 registers of 8bits each.

So I do not think this PR will improve anything unfortunately.

We can merge the Adafruit update to stay current but that will not change anything for us.

int16_t offsetRoll;
int16_t offsetPitch;
};
Expand Down