Skip to content

Commit

Permalink
config: now all horizontal positions, vars changed to lower case letters
Browse files Browse the repository at this point in the history
  • Loading branch information
ronzeiller committed Jan 15, 2018
1 parent c9febf0 commit e0a5e21
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
16 changes: 9 additions & 7 deletions src/host/config/IMUConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@
#pragma once

enum IMUMounting {
VerticalStbHull,
VerticalPortHull,
VerticalTopToBow,
//VerticalTopToStern,
HorizontalLeftSideToBow,
//HorizontalRightSideToBow
verticalStbHull,
verticalPortHull,
verticalTopToBow,
//verticalTopToStern,
horizontalTopToBow, // Bosch P0
horizontalLeftSideToBow, // Bosch P1 (default)
horizontalBottomToBow, // Bosch P2
horizontalRightSideToBow // Bosch P3
};

struct IMUConfig {
bool enabled;
int frequency;
bool enableHdg;
bool enableHeelPitch;
enum IMUMounting mounting = VerticalPortHull;
enum IMUMounting mounting = verticalPortHull;
};
23 changes: 16 additions & 7 deletions src/host/config/KBoxConfigParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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 = verticalStbHull;

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

enum IMUMounting KBoxConfigParser::convertIMUMounting(const String &s) {
if (s == "verticalPortHull") {
return VerticalPortHull;
return verticalPortHull;
}
if (s == "verticalStarboardHull") {
return VerticalStbHull;
return verticalStbHull;
}
if (s == "verticalTopToBow") {
return VerticalTopToBow;
return verticalTopToBow;
}
if (s == "horizontalLeftSideToBow") {
return HorizontalLeftSideToBow;
if (s == "horizontalTopToBow") { // Bosch P0
return horizontalTopToBow;
}
if (s == "horizontalLeftSideToBow") { // Bosch P1 (default)
return horizontalLeftSideToBow;
}
if (s == "horizontaBottomToBow") { // Bosch P2
return horizontalBottomToBow;
}
if (s == "horizontaRightSideToBow") { // Bosch P3
return horizontalRightSideToBow;
}
// default
return VerticalPortHull;
return verticalPortHull;
}
2 changes: 1 addition & 1 deletion src/host/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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
31 changes: 23 additions & 8 deletions src/host/services/IMUService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,25 @@ void IMUService::setup() {
// Where each can be 00:X, 01: Y, 10:Z
// Sign is the 3 lsb: 00000xyz
switch (_config.mounting) {
case HorizontalLeftSideToBow:
case horizontalTopToBow: // Bosch P0
_axisConfig = 0b00100001;
_signConfig = 0b00000100;
break;
case horizontalLeftSideToBow: // Bosch P1 (default)
_axisConfig = 0b00100100;
_signConfig = 0b00000000;
break;
case VerticalTopToBow:
case VerticalStbHull:
case VerticalPortHull:
case horizontalBottomToBow: // Bosch P2
_axisConfig = 0b00100100;
_signConfig = 0b00000110;
break;
case horizontalRightSideToBow: // Bosch P3
_axisConfig = 0b00100001;
_signConfig = 0b00000010;
break;
case verticalTopToBow:
case verticalStbHull:
case verticalPortHull:
_axisConfig = 0b00001001;
_signConfig = 0b00000000;
}
Expand All @@ -73,22 +85,25 @@ void IMUService::loop() {
// roll: Vessel roll, +ve is list to starboard
// pitch: Pitch, +ve is bow up
switch (_config.mounting) {
case VerticalPortHull:
case verticalPortHull:
_roll = SKDegToRad(eulerAngles.z());
_pitch = SKDegToRad(eulerAngles.y());
_heading = SKDegToRad(fmod(eulerAngles.x() + 270, 360));
break;
case VerticalStbHull:
case verticalStbHull:
_roll = SKDegToRad(eulerAngles.z())*(-1);
_pitch = SKDegToRad(eulerAngles.y())*(-1);
_heading = SKDegToRad(eulerAngles.x());
break;
case VerticalTopToBow:
case verticalTopToBow:
_roll = SKDegToRad(eulerAngles.y());
_pitch = SKDegToRad(eulerAngles.z());
_heading = SKDegToRad(fmod(eulerAngles.x() + 180, 360));
break;
case HorizontalLeftSideToBow:
case horizontalTopToBow: // Bosch P0
case horizontalLeftSideToBow: // Bosch P1 (default)
case horizontalBottomToBow: // Bosch P2
case horizontalRightSideToBow: // Bosch P3
_roll = SKDegToRad(eulerAngles.y());
_pitch = SKDegToRad(eulerAngles.z()) * (-1);
_heading = SKDegToRad(eulerAngles.x());
Expand Down
2 changes: 1 addition & 1 deletion src/test/config/KBoxConfigParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ TEST_CASE("KBoxConfigParser") {

CHECK( ! config.imuConfig.enabled );
CHECK( config.imuConfig.frequency == 5 );
CHECK( config.imuConfig.mounting == HorizontalLeftSideToBow );
CHECK( config.imuConfig.mounting == horizontalLeftSideToBow );
}

SECTION("NMEA Converter Config") {
Expand Down

0 comments on commit e0a5e21

Please sign in to comment.