Skip to content

Commit

Permalink
Merge pull request #5 from sarfata/ronzeiller/parse-attitude
Browse files Browse the repository at this point in the history
Ronzeiller/parse attitude
  • Loading branch information
ronzeiller authored Jan 4, 2018
2 parents c9e0489 + 6a0dddd commit e9b3c0c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 35 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ been possible!**

## Changelog

* 2017 12 28
* 2018 01 04
* Add support for parsing PGN127257 Attitude (roll/pitch/yaw)
* Also improved the output in NMEA and SignalK format when some attitude
values are unknown
* 2017 12 28
* KBox now supports a configuration file (`kbox-config.json`) on the sdcard.
* KBox supports sending data to NMEA outputs
* Generated NMEA sentences can be configured independently for each output
Expand Down
27 changes: 9 additions & 18 deletions src/common/signalk/SKNMEA2000Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,29 @@ const SKUpdate& SKNMEA2000Parser::parse(const SKSourceInput& input, const tN2kMs

switch (msg.PGN) {
case 126992L: // System Time / Date
return parse126992(input, msg, timestamp);
break;
return parse126992(input, msg, timestamp);
case 127245L: // Rudder
return parse127245(input, msg, timestamp);
break;
return parse127245(input, msg, timestamp);
case 127250L: // Vessel Heading
return parse127250(input, msg, timestamp);
break;
return parse127250(input, msg, timestamp);
//case 127251L: // Rate of Turn
case 127257L: // Attitude Yaw, Pitch, Roll
return parse127257(input, msg, timestamp);
break;
return parse127257(input, msg, timestamp);
//case 127258L: // Magnetic Variation
// return parse127258(input, msg, timestamp);
// break;
case 128259L: // Boat speed
return parse128259(input, msg, timestamp);
break;
return parse128259(input, msg, timestamp);
case 128267L: // Water depth
return parse128267(input, msg, timestamp);
break;
return parse128267(input, msg, timestamp);
//case 128275L: // Distance Log
case 129025L: // Position, Rapid Update Lat/Lon
return parse129025(input, msg, timestamp);
break;
return parse129025(input, msg, timestamp);
case 129026L: // COG SOG rapid
return parse129026(input, msg, timestamp);
break;
return parse129026(input, msg, timestamp);
//case 129301L: // Time to/from Mark
case 130306L: // Wind Speed
return parse130306(input, msg, timestamp);
break;
return parse130306(input, msg, timestamp);

//case 127488: // Engine parameters rapid
//case 127493: // Transmission parameters: dynamic
Expand Down
14 changes: 4 additions & 10 deletions src/common/signalk/SKNMEAConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,13 @@ void SKNMEAConverter::convert(const SKUpdate& update, SKNMEAOutput& output) {
output.write(sb.toNMEA());
}

if (_config.mwv &&
update.hasEnvironmentWindAngleApparent() &&
update.hasEnvironmentWindSpeedApparent() &&
update.getEnvironmentWindAngleApparent() != SKDoubleNAN &&
update.getEnvironmentWindSpeedApparent() != SKDoubleNAN) {
if (_config.mwv && update.hasEnvironmentWindAngleApparent()
&& update.hasEnvironmentWindSpeedApparent()) {
generateMWV(output, update.getEnvironmentWindAngleApparent(), update.getEnvironmentWindSpeedApparent(), true);
}

if (_config.mwv &&
update.hasEnvironmentWindAngleTrueWater() &&
update.hasEnvironmentWindSpeedTrue() &&
update.getEnvironmentWindAngleTrueWater() != SKDoubleNAN &&
update.getEnvironmentWindSpeedTrue() != SKDoubleNAN) {
if (_config.mwv && update.hasEnvironmentWindAngleTrueWater()
&& update.hasEnvironmentWindSpeedTrue()) {
generateMWV(output, update.getEnvironmentWindAngleTrueWater(), update.getEnvironmentWindSpeedTrue(), false);
}

Expand Down
4 changes: 3 additions & 1 deletion src/common/signalk/SKNMEAParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ const SKUpdate& SKNMEAParser::parseRMC(const SKSourceInput& input, NMEASentenceR
double cog = SKDegToRad(reader.getFieldAsDouble(8));

if (!isnan(latitude) && !isnan(longitude)) {
rmc->setValue(SKPathNavigationPosition, SKTypePosition(latitude, longitude, 0));
rmc->setValue(SKPathNavigationPosition, SKTypePosition(latitude,
longitude,
SKDoubleNAN));
}
if (!isnan(sog)) {
rmc->setValue(SKPathNavigationSpeedOverGround, sog);
Expand Down
4 changes: 2 additions & 2 deletions src/sktool/tests/rmc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
"nmea": "$GPRMC,004119.000,A,3751.3385,N,12227.4913,W,5.02,235.24,141116,,,D*75",
"expectedValues": [
{ "path": "navigation.position", "value": { "latitude": 37.85564166666666, "longitude": -122.45818833333334 } },
{ "path": "navigation.position",
"value": { "latitude": 37.85564167, "longitude": -122.4581883 } },
{ "path": "navigation.speedOverGround", "value": 2.582511111 },
{ "path": "navigation.courseOverGroundTrue", "value": 4.105712532 }
]
,"ignoreFail": true
}
]
4 changes: 2 additions & 2 deletions src/test/signalk/SKNMEA2000ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ TEST_CASE("SKNMEA2000Parser: Basic tests") {
CHECK( update.getNavigationAttitude().roll == Approx(SKDegToRad(3.2)).epsilon(0.0001) );
}

SECTION("127275: NavigationAttitude Heel, Pitch, Yaw = NaN = N2kDoubleNA = -1e9") {
SECTION("127275: NavigationAttitude Heel, Pitch, Yaw = SKDoubleNAN = N2kDoubleNA = -1e9") {
// SID, yaw, pitch, roll in radians
SetN2kAttitude(msg, 0, N2kDoubleNA, SKDegToRad(-2.3), SKDegToRad(3.2));
const SKUpdate &update = p.parse(SKSourceInputNMEA2000, msg, SKTime(0));
CHECK( update.getSize() == 1);
CHECK( update.getNavigationAttitude().yaw == -1e9 );
CHECK( update.getNavigationAttitude().yaw == SKDoubleNAN );
CHECK( update.getNavigationAttitude().pitch == Approx(SKDegToRad(-2.3)).epsilon(0.0001) );
CHECK( update.getNavigationAttitude().roll == Approx(SKDegToRad(3.2)).epsilon(0.0001) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/signalk/SKNMEAParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TEST_CASE("SKNMEAParser: RMC") {
CHECK( update.getNavigationCourseOverGroundTrue() == SKDegToRad(235.24) );
CHECK( update.getNavigationPosition().latitude == 37.85564166666666 );
CHECK( update.getNavigationPosition().longitude == -122.45818833333334 );
CHECK( update.getNavigationPosition().altitude == 0 );
CHECK( update.getNavigationPosition().altitude == SKDoubleNAN );
}

SECTION("RMC with invalid fix") {
Expand Down

0 comments on commit e9b3c0c

Please sign in to comment.