-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added 'compile_commands.json' to gitignore * Added EPE message support * release: 3.4.11 * clean up + formatting --------- Co-authored-by: Axel Sundelin <axel.sundelin@ercisson.com>
- Loading branch information
Showing
10 changed files
with
204 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ bin | |
build | ||
output.txt | ||
generated_files | ||
.vscode | ||
.vscode | ||
compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <receiver/nmea/epe.hpp> | ||
#include "helper.hpp" | ||
|
||
namespace receiver { | ||
namespace nmea { | ||
|
||
static bool parse_double_opt(std::string const& token, double& value) { | ||
try { | ||
value = std::stod(token); | ||
return true; | ||
} catch (...) { | ||
value = 0; | ||
return true; | ||
} | ||
} | ||
|
||
EpeMessage::EpeMessage(std::string prefix, std::string payload, std::string checksum) NMEA_NOEXCEPT | ||
: Message{prefix, payload, checksum}, | ||
mMsgVer{0.0}, | ||
mNorth{0.0}, | ||
mEast{0.0}, | ||
mDown{0.0}, | ||
m2D{0.0}, | ||
m3D{0.0} {} | ||
|
||
void EpeMessage::print() const NMEA_NOEXCEPT { | ||
printf("[%5s]\n", prefix().c_str()); | ||
printf(" message version: %f\n", mMsgVer); | ||
printf(" north error: %f\n", mNorth); | ||
printf(" east error: %f\n", mEast); | ||
printf(" down error: %f\n", mDown); | ||
printf(" 2D error: %f\n", m2D); | ||
printf(" 3D error: %f\n", m3D); | ||
} | ||
|
||
std::unique_ptr<Message> EpeMessage::parse(std::string prefix, std::string const& payload, | ||
std::string checksum) { | ||
// split payload by ',' | ||
auto tokens = split(payload, ','); | ||
|
||
// check number of tokens | ||
if (tokens.size() < 6) { | ||
#if RECEIVER_NMEA_DEBUG | ||
printf("[--EPE] invalid number of tokens: %zu\n", tokens.size()); | ||
#endif | ||
return nullptr; | ||
} | ||
|
||
// parse | ||
auto message = new EpeMessage(prefix, payload, checksum); | ||
auto success = true; | ||
success &= parse_double_opt(tokens[0], message->mMsgVer); | ||
success &= parse_double_opt(tokens[1], message->mNorth); | ||
success &= parse_double_opt(tokens[2], message->mEast); | ||
success &= parse_double_opt(tokens[3], message->mDown); | ||
success &= parse_double_opt(tokens[4], message->m2D); | ||
success &= parse_double_opt(tokens[5], message->m3D); | ||
|
||
if (success) { | ||
return std::unique_ptr<EpeMessage>(message); | ||
} else { | ||
#if RECEIVER_NMEA_DEBUG | ||
printf("[--EPE] failed to parse message\n"); | ||
#endif | ||
delete message; | ||
return nullptr; | ||
} | ||
} | ||
|
||
} // namespace nmea | ||
} // namespace receiver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#pragma once | ||
#include <receiver/nmea/message.hpp> | ||
#include <receiver/nmea/types.hpp> | ||
|
||
#include <cmath> | ||
#include <memory> | ||
#include <utility/time.h> | ||
|
||
namespace receiver { | ||
namespace nmea { | ||
|
||
// Message specification | ||
// $PQTMEPE,<MsgVer>,<EPE_North>,<EPE_East>,<EPE_Down>,<EPE_2D>,<EPE_3D>*<Checksum> | ||
class EpeMessage final : public Message { | ||
public: | ||
~EpeMessage() override = default; | ||
|
||
EpeMessage(EpeMessage const& other) | ||
: Message(other), mMsgVer(other.mMsgVer), mNorth(other.mNorth), mEast(other.mEast), | ||
mDown(other.mDown), m2D(other.m2D), m3D(other.m3D) {} | ||
EpeMessage(EpeMessage&&) = delete; | ||
EpeMessage& operator=(EpeMessage const&) = delete; | ||
EpeMessage& operator=(EpeMessage&&) = delete; | ||
|
||
void print() const NMEA_NOEXCEPT override; | ||
|
||
/// ----- EPE source messages ----- | ||
|
||
/// Get the estimated north error | ||
NMEA_NODISCARD double north() const NMEA_NOEXCEPT { return mNorth; } | ||
|
||
/// Get the estimated east error | ||
NMEA_NODISCARD double east() const NMEA_NOEXCEPT { return mEast; } | ||
|
||
/// Get the estimated down error | ||
NMEA_NODISCARD double down() const NMEA_NOEXCEPT { return mDown; } | ||
|
||
/// Get the estimated 2D position error | ||
NMEA_NODISCARD double epe_2d() const NMEA_NOEXCEPT { return m2D; } | ||
|
||
/// Get the estimated 3D position error | ||
NMEA_NODISCARD double epe_3d() const NMEA_NOEXCEPT { return m3D; } | ||
|
||
/// ----- GST conversions ----- | ||
|
||
/// Get the horizontal position error. | ||
NMEA_NODISCARD double horizontal_position_error() const NMEA_NOEXCEPT { return m2D; } | ||
|
||
/// Get semi-major axis. | ||
NMEA_NODISCARD double semi_major() const NMEA_NOEXCEPT { return m2D / sqrt(2); } | ||
|
||
/// Get semi-minor axis. | ||
NMEA_NODISCARD double semi_minor() const NMEA_NOEXCEPT { return m2D / sqrt(2); } | ||
|
||
/// Get the orientation of the semi-major axis. | ||
NMEA_NODISCARD double orientation() const NMEA_NOEXCEPT { return 0; } | ||
|
||
/// Get the vertical position error. | ||
NMEA_NODISCARD double vertical_position_error() const NMEA_NOEXCEPT { | ||
return sqrt((m3D * m3D) - (m2D * m2D)); | ||
} | ||
|
||
// TODO(ehedpon) Implement conversion from north, east and down error to latitude and longitude. | ||
// Also unclear if vertical error is sigma_v or if it needs to be converted from down | ||
|
||
NMEA_NODISCARD static std::unique_ptr<Message> | ||
parse(std::string prefix, std::string const& payload, std::string checksum); | ||
|
||
private: | ||
NMEA_EXPLICIT EpeMessage(std::string prefix, std::string payload, | ||
std::string checksum) NMEA_NOEXCEPT; | ||
|
||
double mMsgVer; | ||
double mNorth; | ||
double mEast; | ||
double mDown; | ||
double m2D; | ||
double m3D; | ||
}; | ||
|
||
} // namespace nmea | ||
} // namespace receiver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters