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 19 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
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=*

36 changes: 36 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ extra_scripts = tools/platformio_cfg_gitversion.py
# To disable size optimization
#build_unflags = -Os

[env:host-teensy36]
src_filter = +<common/*>,+<host/*>
build_flags =
${common.build_flags} -Isrc/common -Isrc/host
-DSERIAL1_RX_BUFFER_SIZE=512 -DSERIAL1_TX_BUFFER_SIZE=512
-DSERIAL2_RX_BUFFER_SIZE=256 -DSERIAL2_TX_BUFFER_SIZE=256
-DSERIAL3_RX_BUFFER_SIZE=256 -DSERIAL3_TX_BUFFER_SIZE=256
platform = teensy
framework = arduino
board = teensy36
lib_deps =
${common.lib_deps_common}
${common.lib_deps_teensy}
extra_scripts = tools/platformio_cfg_gitversion.py
Copy link
Owner

Choose a reason for hiding this comment

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

I think you may need to add lib_ignore = ${common.incompatible_libs_teensy} when you merge. Not sure ... Please give it a try. I have added it for env:host.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am afraid I did some mistake on the last merge of your updates, because
[env:host-teensy36] [env:program-esp] [env:program-esp-teensy36]
are already updated in your uptodate master branch.
It was doubled in the PR by mistake.

did a
git checkout upstream/master platformio.ini
now


# This configuration builds a very simple firmware for the host that allows to upload
# a firmware to the ESP8266 module.
[env:program-esp]
Expand All @@ -82,6 +97,17 @@ lib_deps =
${common.lib_deps_teensy}
lib_ignore = ${common.incompatible_libs_teensy}

[env:program-esp-teensy36]
src_filter = +<common/*>, +<program-esp/*>, +<host/esp-programmer/>
build_flags = ${common.build_flags} -Isrc/common
platform = teensy
framework = arduino
board = teensy36
lib_ldf_mode = deep
lib_deps =
${common.lib_deps_common}
${common.lib_deps_teensy}

[env:esp]
src_filter = +<common/*>,+<esp/*>
# no-strict-aliasing required here due to ESP+NMEA2000 incompatibilities
Expand Down Expand Up @@ -115,6 +141,16 @@ lib_deps =
${common.lib_deps_teensy}
lib_ignore = ${common.incompatible_libs_teensy}

[env:mfg-teensy36]
src_filter = +<common/*>, +<mfg/*>, +<host/drivers/ILI9341GC.cpp>
build_flags = ${common.build_flags} -Isrc/common
platform = teensy
framework = arduino
board = teensy36
lib_deps =
${common.lib_deps_common}
${common.lib_deps_teensy}

[env:test]
src_filter =
+<common/comms/*>, +<common/nmea/*>, +<common/signalk/*>, +<common/time/*>, +<common/util/*>,
Expand Down
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