ROSaic
Public Member Functions | Static Public Attributes
GpgsaParser Class Reference

Derived class for parsing GSA messages. More...

#include <gpgsa.hpp>

Inheritance diagram for GpgsaParser:
Inheritance graph
[legend]
Collaboration diagram for GpgsaParser:
Collaboration graph
[legend]

Public Member Functions

 GpgsaParser ()
 Constructor of the class GpgsaParser. More...
 
const std::string getMessageID () const override
 Returns the ASCII message ID, here "$GPGSA". More...
 
rosaic::GpgsaPtr parseASCII (const NMEASentence &sentence) noexcept(false) override
 Parses one GSA message. More...
 
- Public Member Functions inherited from BaseParser< rosaic::GpgsaPtr >
 BaseParser ()=default
 Default constructor of the class BaseParser. More...
 
virtual ~BaseParser ()=default
 Default destructor of the class BaseParser. More...
 
rosaic::GpgsaPtr parseBinary (const SBFStructT &bin_msg) noexcept(false)
 Converts bin_msg into a ROS message pointer (e.g. nmea_msgs::GpggaPtr) and returns it. More...
 

Static Public Attributes

static const std::string MESSAGE_ID = "$GPGSA"
 Declares the string MESSAGE_ID. More...
 

Detailed Description

Derived class for parsing GSA messages.

Date
29/09/20

Definition at line 82 of file gpgsa.hpp.

Constructor & Destructor Documentation

◆ GpgsaParser()

GpgsaParser::GpgsaParser ( )
inline

Constructor of the class GpgsaParser.

Definition at line 89 of file gpgsa.hpp.

References getMessageID(), and parseASCII().

Here is the call graph for this function:

Member Function Documentation

◆ getMessageID()

const std::string GpgsaParser::getMessageID ( ) const
overridevirtual

Returns the ASCII message ID, here "$GPGSA".

Returns
The message ID

Implements BaseParser< rosaic::GpgsaPtr >.

Definition at line 41 of file gpgsa.cpp.

References MESSAGE_ID.

Referenced by GpgsaParser().

42 {
44 }
static const std::string MESSAGE_ID
Declares the string MESSAGE_ID.
Definition: gpgsa.hpp:107
Here is the caller graph for this function:

◆ parseASCII()

rosaic::GpgsaPtr GpgsaParser::parseASCII ( const NMEASentence sentence)
overridevirtualnoexcept

Parses one GSA message.

Parameters
[in]sentenceThe GSA message to be parsed
Returns
A ROS message pointer of ROS type rosaic::GpgsaPtr

Caution: Due to the occurrence of the throw keyword, this method ParseASCII should be called within a try / catch framework... Note: This method is called from within the read() method of the RxMessage class by including the checksum part in the argument "sentence" here, though the checksum is never parsed: It would be sentence.get_body()[18] if anybody ever needs it.

Reimplemented from BaseParser< rosaic::GpgsaPtr >.

Definition at line 51 of file gpgsa.cpp.

References g_frame_id, parsing_utilities::parseFloat(), and parsing_utilities::parseUInt8().

Referenced by GpgsaParser(), and io_comm_rx::RxMessage::read().

52 {
53 
54  // Checking the length first, it should be 19 elements
55  const size_t LENGTH = 19;
56  if (sentence.get_body().size() != LENGTH)
57  {
58  std::stringstream error;
59  error << "Expected GPGSA length is " << LENGTH
60  << ". The actual length is " << sentence.get_body().size();
61  throw ParseException(error.str());
62  }
63 
64  rosaic::GpgsaPtr msg = boost::make_shared<rosaic::Gpgsa>();
65  msg->header.frame_id = g_frame_id;
66  msg->message_id = sentence.get_body()[0];
67  msg->auto_manual_mode = sentence.get_body()[1];
68  parsing_utilities::parseUInt8(sentence.get_body()[2], msg->fix_mode);
69  // Words 3-14 of the sentence are SV PRNs. Copying only the non-null strings..
70  // 0 is the character needed to fill the new character space, in case 12 (first argument) is larger than sv_ids.
71  msg->sv_ids.resize(12, 0);
72  size_t n_svs = 0;
73  for (std::vector<std::string>::const_iterator id = sentence.get_body().begin()+3; id < sentence.get_body().begin()+15; ++id)
74  {
75  if (! id->empty())
76  {
77  parsing_utilities::parseUInt8(*id, msg->sv_ids[n_svs]);
78  ++n_svs;
79  }
80  }
81  msg->sv_ids.resize(n_svs);
82 
83  parsing_utilities::parseFloat(sentence.get_body()[15], msg->pdop);
84  parsing_utilities::parseFloat(sentence.get_body()[16], msg->hdop);
85  parsing_utilities::parseFloat(sentence.get_body()[17], msg->vdop);
86  return msg;
87 }
std::string g_frame_id
The frame ID used in the header of every published ROS message.
float parseFloat(const uint8_t *buffer)
Converts a 4-byte-buffer into a float.
std::vector< std::string > get_body() const
Class to declare error message format when parsing, derived from the public class "std::runtime_error...
bool parseUInt8(const std::string &string, uint8_t &value, int32_t base)
Interprets the contents of "string" as a unsigned integer number of type uint8_t. ...
Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ MESSAGE_ID

const std::string GpgsaParser::MESSAGE_ID = "$GPGSA"
static

Declares the string MESSAGE_ID.

Definition at line 107 of file gpgsa.hpp.

Referenced by getMessageID().


The documentation for this class was generated from the following files: