Class CObservationGPS

Inheritance Relationships

Base Type

Class Documentation

class CObservationGPS : public mrpt::obs::CObservation

This class stores messages from GNSS or GNSS+IMU devices, from consumer-grade inexpensive GPS receivers to Novatel/Topcon/… advanced RTK solutions.

See mrpt::hwdrivers::CGPSInterface for a class capable of reading from a serial port or any input stream and parsing the ASCII/binary stream into indivual messages stored in mrpt::obs::CObservationGPS objects.

Supported message types are:

  • NMEA 0183 (ASCII): GGA, RMC, etc.

  • Topcon GRIL (Binary): PZS, SATS

  • Novatel GNSS/SPAN OEM6 (Binary): See list of log packets under namespace mrpt::obs::gnss and in enum type mrpt::obs::gnss::gnss_message_type_t

Note that this object has two timestamp fields:

Normally, users read and write messages by means of these methods:

There is also a CObservationGPS::fix_type field with information about the source of corrections (SBAS, GBAS, standalone,…) and CObservationGPS::gnss_service_mask to identify the satellite network used in the solution.

Example access to GPS datum:

mrpt::obs::CObservationGPS obs;
//...
if (obs.hasMsgClass<mrpt::obs::gnss::Message_NMEA_GGA>()) {
  const mrpt::obs::gnss::Message_NMEA_GGA &gga =
o.getMsgByClass<mrpt::obs::gnss::Message_NMEA_GGA>();
  //gga.fields.XXX ...
}

See also

CObservation

Note

Since MRPT 2.11.12 there is an optional field for ENU covariance for easier compatibility with ROS messages.

GNSS (GPS) data fields

mrpt::poses::CPose3D sensorPose = {}

The sensor pose on the robot/vehicle

mrpt::system::TTimeStamp originalReceivedTimestamp = {INVALID_TIMESTAMP}

The local computer-based timestamp based on the reception of the message in the computer.

See also

CObservation::timestamp in the base class, which should contain the accurate satellite-based UTC timestamp.

bool has_satellite_timestamp = {false}

If true, CObservation::timestamp has been generated from accurate satellite clock. Otherwise, no GPS data is available and timestamps are based on the local computer clock.

message_list_t messages

The main piece of data in this class: a list of GNSS messages. Normally users might prefer to access the list via the methods CObservationGPS::getMsgByClass() and CObservationGPS::setMsg() Typically only one message, may be multiple if all have the same timestamp.

std::optional<mrpt::math::CMatrixDouble33> covariance_enu

If present, it defines the ENU position uncertainty.

GnssFixType fix_type = GnssFixType::UNKNOWN

Richer fix type. Complements (not replaces) fix_quality in GGA. Set to UNKNOWN if the originating driver/bridge does not populate it.

GnssService gnss_service_mask = GnssService::NONE

Bitmask of active GNSS constellations. Zero means unknown. Example: GnssService::GPS | GnssService::GALILEO

Main API to access to the data fields

template<class MSG_CLASS>
inline void setMsg(const MSG_CLASS &msg)

Stores a message in the list messages, making a copy of the passed object. Valid message classes are those derived from mrpt::obs::gnss::gnss_message. If another message of the same type exists, it is overwritten.

bool hasMsgType(const gnss::gnss_message_type_t type_id) const

Returns true if the list CObservationGPS::messages contains one of the requested type.

template<class MSG_CLASS>
inline bool hasMsgClass() const

Like hasMsgType() but allows querying for message classes, from any of those derived from mrpt::obs::gnss::gnss_message

mrpt::obs::gnss::gnss_message *getMsgByType(const gnss::gnss_message_type_t type_id)

Returns a pointer to the message in the list CObservationGPS::messages of the requested type. Users normally would prefer using CObservationGPS::getMsgByClass() to avoid having to perform a dynamic_cast<>() on the returned pointer.

Throws:

std::runtime_error – If there is no such a message in the list. Please, check existence before calling this method with CObservationGPS::hasMsgType()

const mrpt::obs::gnss::gnss_message *getMsgByType(const gnss::gnss_message_type_t type_id) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class MSG_CLASS>
inline MSG_CLASS &getMsgByClass()

Returns a reference to the message in the list CObservationGPS::messages of the requested class.

Throws:

std::runtime_error – If there is no such a message in the list. Please, check existence before calling this method with CObservationGPS::hasMsgClass()

template<class MSG_CLASS>
inline const MSG_CLASS &getMsgByClass() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class MSG_CLASS>
inline MSG_CLASS *getMsgByClassPtr()

Like CObservationGPS::getMsgByClass() but returns a nullptr pointer if message is not found, instead of launching an exception

template<class MSG_CLASS>
inline const MSG_CLASS *getMsgByClassPtr() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void dumpToStream(std::ostream &out) const

Dumps the contents of the observation in a human-readable form to a given output stream

void dumpToConsole(std::ostream &o) const

Dumps the contents of the observation in a human-readable form to an std::ostream (use std::cout to print to console)

void clear()

Empties this observation, clearing the container messages

inline virtual void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override

A general method to retrieve the sensor pose on the robot. Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.

See also

setSensorPose

inline virtual void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override

A general method to change the sensor pose on the robot. Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.

See also

getSensorPose

virtual void getDescriptionAsText(std::ostream &o) const override

Build a detailed, multi-line textual description of the observation contents and dump it to the output stream.

Note

If overried by derived classes, call base CObservation::getDescriptionAsText() first to show common information.

Note

This is the text that appears in RawLogViewer when selecting an object in the dataset

virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const override

By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accurate UTC timing of readings, this contains the computer-based timestamp of reception, which may be slightly different than timestamp

See also

getTimeStamp()

inline GnssFixType getBestFixType() const

Returns fix_type if set, otherwise infers it from GGA fix_quality.

static inline GnssFixType inferFixTypeFromGgaQuality(uint8_t fix_quality)

Returns a best-effort GnssFixType inferred from GGA fix_quality alone. Use fix_type directly when available; this is the fallback for legacy observations where fix_type == UNKNOWN.

Utilities

static bool GPS_time_to_UTC(uint16_t gps_week, double gps_sec, const int leap_seconds_count, mrpt::system::TTimeStamp &utc_out)
Parameters:
  • leap_seconds_count – [in] GPS to UTC time number of leap seconds (normally grabbed from satellital live data)

  • utc_out – Return false on invalid input data [out] UTC timestamp

static bool GPS_time_to_UTC(uint16_t gps_week, double gps_sec, const int leap_seconds_count, mrpt::system::TTimeParts &utc_out)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Public Types

using message_list_t = std::map<gnss::gnss_message_type_t, gnss::gnss_message_ptr>

Public Functions

inline bool has_GGA_datum() const

true if the corresponding field exists in messages.

inline bool has_RMC_datum() const

true if the corresponding field exists in messages.