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 all 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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ to the authors of these libraries! Without them, this project would not have
been possible!**

## Changelog
* 2018 12 16 - v1.3.7
* added all variantions of positioning KBox to IMU Service, including
more meaningfull names in config
* Fixed bug in calculations of + or - values for pitch and roll
* on IMU Page datas shown in red now dependent of each calibration

* 2018 09 07 - v1.3.6
* Force ESP board definition to generic module w 1MB flash to avoid build
Expand Down Expand Up @@ -218,19 +223,19 @@ been possible!**
* 2018 07 06 - v1.3.3
* Fix a bug which forced us to use `program-esp` to update the wifi module.
It is now possible again to just use the following commands to update KBox:

platform run -e host -t upload
platformio run -e esp -t upload

* Change default esp upload speed to 921600 because 2000000 does not seem well
supported on Windows.
* Changed the 'end of programming' detection method to more reliably detect when
we are done programming and reboot KBox.
* Tested the official ESP uploader on Windows and OS X. Comment out the line
* Tested the official ESP uploader on Windows and OS X. Comment out the line
`tools/platformio_cfg_esp.py` in `platformio.ini` to use it.
It will be a little bit slower but might work better for some people.
* 2018 07 06 - v1.3.2
* Changes to the build configuration to improve compatibility with Windows
* Changes to the build configuration to improve compatibility with Windows
and address breaking changes in plaformio.
* Fix some issues that prevented the tests and sktool from compiling on Windows.
* Also added automatic builds on AppVeyor with Windows to hopefully detect
Expand Down
2 changes: 1 addition & 1 deletion extras/config/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"frequency": 20,
"enableHdg": true,
"enableHeelPitch": true,
"mounting": "verticalPortHull"
"mounting": "verticalRightSideToBow"
},
"barometer": {
"enabled": true,
Expand Down
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=*

27 changes: 20 additions & 7 deletions src/host/config/IMUConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,35 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* horizontal top (KBox or sensor)
__________________
/ o /|
/ / /
Left Side / BNO055 / / Right Side
/ vertical top / /
/_________________/ /
|________________ |/

horiz. bottom (KBox or sensor)
*/

#pragma once

enum IMUMounting {
VerticalStbHull,
VerticalPortHull,
VerticalTopToBow,
//VerticalTopToStern,
HorizontalLeftSideToBow,
//HorizontalRightSideToBow
verticalRightSideToBow, // KBox mounted on port hull
Copy link
Owner

Choose a reason for hiding this comment

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

Why have two options that are the same thing? It looks like verticalPortHull == verticalRightSideToBow? Or maybe I am missing something?

Copy link
Contributor Author

@ronzeiller ronzeiller Apr 24, 2018

Choose a reason for hiding this comment

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

Yes if I remember right, it is the same. verticalPortHull is the "deprecated" naming convention which I believe you have in your config. If you switch to the "more detailed naming convention" then we do not need it anymore.

If you like it in principle and if it is easy for you to change, please do so.
Otherwise I think the right way is to merge your new commits, add the [env:host36] and delete the verticalPortHull, verticalStbHull settings in this PR, right?

Copy link
Owner

Choose a reason for hiding this comment

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

I like the new naming and I think it's good to remove the old one to keep the more explicit one. 👍

verticalLeftSideToBow, // KBox mounted on stb. hull
verticalTopToBow, // KBox mounted on rear bulkhead
verticalBottomToBow, // KBox mounted on front bulkhead,
horizontalTopToBow,
horizontalLeftSideToBow,
horizontalBottomToBow,
horizontalRightSideToBow,
};

struct IMUConfig {
bool enabled;
int frequency;
bool enableHdg;
bool enableHeelPitch;
enum IMUMounting mounting = VerticalPortHull;
enum IMUMounting mounting = verticalRightSideToBow;
};
28 changes: 20 additions & 8 deletions src/host/config/KBoxConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void KBoxConfigParser::defaultConfig(KBoxConfig &config) {
config.imuConfig.enabled = true; // enable internal IMU sensor
config.imuConfig.enableHdg = true; // true if values taken from internal sensor
config.imuConfig.enableHeelPitch = true; // true if values taken from internal sensor
config.imuConfig.mounting = VerticalStbHull;
config.imuConfig.mounting = verticalRightSideToBow;

config.barometerConfig.enabled = true;
config.barometerConfig.frequency = 1;
Expand Down Expand Up @@ -209,18 +209,30 @@ enum SerialMode KBoxConfigParser::convertSerialMode(const String &s) {
}

enum IMUMounting KBoxConfigParser::convertIMUMounting(const String &s) {
if (s == "verticalPortHull") {
return VerticalPortHull;
if (s == "verticalRightSideToBow") {
return verticalRightSideToBow;
}
if (s == "verticalStarboardHull") {
return VerticalStbHull;
if (s == "verticalLeftSideToBow") {
return verticalLeftSideToBow;
}
if (s == "verticalTopToBow") {
return VerticalTopToBow;
return verticalTopToBow;
}
if (s == "verticalBottomToBow") {
return verticalBottomToBow;
}
if (s == "horizontalTopToBow") {
return horizontalTopToBow;
}
if (s == "horizontalLeftSideToBow") {
return HorizontalLeftSideToBow;
return horizontalLeftSideToBow;
}
if (s == "horizontalBottomToBow") {
return horizontalBottomToBow;
}
if (s == "horizontalRightSideToBow") {
return horizontalRightSideToBow;
}
// default
return VerticalPortHull;
return verticalRightSideToBow;
}
2 changes: 1 addition & 1 deletion src/host/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void setup() {
JsonObject &root =jsonBuffer.parseObject(configFile);

if (root.success()) {
DEBUG("Loading configuration from SDCard");
DEBUG("Loading configuration file %s from SDCard", configFilename);
configParser.parseKBoxConfig(root, config);
}
else {
Expand Down
15 changes: 13 additions & 2 deletions src/host/pages/IMUMonitorPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,24 @@ bool IMUMonitorPage::processEvent(const TickEvent &te){

// Always show Hdg from IMU-sensor, but if the value is not trusted (which means
// calibrationData below default setting, change color to red
// red color also means, that values are not sent as SKUpdate to SKHub
if ( ! _imuService.isMagCalibrated() || ! _imuService.isRollAndPitchCalibrated()) {
_hdgTL->setColor(ColorRed);
_calTL->setColor(ColorRed);
} else {
_hdgTL->setColor(ColorWhite);
_calTL->setColor(ColorWhite);
};
if ( ! _imuService.isMagCalibrated() ) {
_hdgTL->setColor(ColorRed);
} else {
_hdgTL->setColor(ColorWhite);
};
if ( ! _imuService.isRollAndPitchCalibrated()) {
_pitchTL->setColor(ColorRed);
_rollTL->setColor(ColorRed);
} else {
_pitchTL->setColor(ColorWhite);
_rollTL->setColor(ColorWhite);
};

return true;
}
Expand Down
Loading