class mrpt::obs::CObservationGPS
Overview
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:
The standard CObservation::timestamp field in the base class, which should contain the accurate satellite-based UTC timestamp, and
the field CObservationGPS::originalReceivedTimestamp, with the local computer-based timestamp based on the reception of the message in the computer.
Normally, users read and write messages by means of these methods:
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 ... }
Since MRPT 2.11.12 there is an optional field for ENU covariance for easier compatibility with ROS messages.
See also:
#include <mrpt/obs/CObservationGPS.h> class CObservationGPS: public mrpt::obs::CObservation { public: // typedefs typedef std::map<gnss::gnss_message_type_t, gnss::gnss_message_ptr> message_list_t; // fields mrpt::poses::CPose3D sensorPose {}; mrpt::system::TTimeStamp originalReceivedTimestamp {INVALID_TIMESTAMP}; bool has_satellite_timestamp {false}; message_list_t messages; std::optional<mrpt::math::CMatrixDouble33> covariance_enu; // methods template <class MSG_CLASS> void setMsg(const MSG_CLASS& msg); bool hasMsgType(const gnss::gnss_message_type_t type_id) const; template <class MSG_CLASS> bool hasMsgClass() const; mrpt::obs::gnss::gnss_message* getMsgByType(const gnss::gnss_message_type_t type_id); const mrpt::obs::gnss::gnss_message* getMsgByType(const gnss::gnss_message_type_t type_id) const; template <class MSG_CLASS> MSG_CLASS& getMsgByClass(); template <class MSG_CLASS> const MSG_CLASS& getMsgByClass() const; template <class MSG_CLASS> MSG_CLASS* getMsgByClassPtr(); template <class MSG_CLASS> const MSG_CLASS* getMsgByClassPtr() const; void dumpToStream(std::ostream& out) const; void dumpToConsole(std::ostream& o) const; void clear(); virtual void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const; virtual void setSensorPose(const mrpt::poses::CPose3D& newSensorPose); virtual void getDescriptionAsText(std::ostream& o) const; virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const; static bool GPS_time_to_UTC( uint16_t gps_week, double gps_sec, const int leap_seconds_count, mrpt::system::TTimeStamp& utc_out ); static bool GPS_time_to_UTC( uint16_t gps_week, double gps_sec, const int leap_seconds_count, mrpt::system::TTimeParts& utc_out ); bool has_GGA_datum() const; bool has_RMC_datum() const; };
Inherited Members
public: // fields mrpt::system::TTimeStamp timestamp {mrpt::Clock::now()}; std::string sensorLabel; // methods mrpt::system::TTimeStamp getTimeStamp() const; virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const; void load() const; virtual void unload() const; virtual bool exportTxtSupported() const; virtual std::string exportTxtHeader() const; virtual std::string exportTxtDataRow() const; template <class METRICMAP> bool insertObservationInto( METRICMAP& theMap, const std::optional<const mrpt::poses::CPose3D>& robotPose = std::nullopt ) const; virtual void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const = 0; void getSensorPose(mrpt::math::TPose3D& out_sensorPose) const; mrpt::math::TPose3D sensorPose() const; virtual void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) = 0; void setSensorPose(const mrpt::math::TPose3D& newSensorPose); virtual void getDescriptionAsText(std::ostream& o) const; virtual std::string asString() const;
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 GNNS 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.
Methods
template <class MSG_CLASS> 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.
See also:
mrpt::obs::gnss::gnss_message_type_t, CObservationGPS::getMsgByType()
template <class MSG_CLASS> bool hasMsgClass() const
Like hasMsgType() but allows querying for message classes, from any of those derived from mrpt::obs::gnss::gnss_message.
See also:
CObservationGPS::hasMsgType(),
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.
Parameters:
std::runtime_error |
If there is no such a message in the list. Please, check existence before calling this method with CObservationGPS::hasMsgType() |
See also:
mrpt::obs::gnss::gnss_message_type_t, CObservationGPS::getMsgByClass(), 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> MSG_CLASS& getMsgByClass()
Returns a reference to the message in the list CObservationGPS::messages of the requested class.
Parameters:
std::runtime_error |
If there is no such a message in the list. Please, check existence before calling this method with CObservationGPS::hasMsgClass() |
See also:
mrpt::obs::gnss::gnss_message_type_t, CObservationGPS::getMsgByType(), CObservationGPS::hasMsgType()
template <class MSG_CLASS> 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> 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> 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.
See also:
dumpToConsole(), getDescriptionAsText()
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.
virtual void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const
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:
virtual void setSensorPose(const mrpt::poses::CPose3D& newSensorPose)
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:
virtual void getDescriptionAsText(std::ostream& o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the output stream.
If overried by derived classes, call base CObservation::getDescriptionAsText() first to show common information.
This is the text that appears in RawLogViewer when selecting an object in the dataset
virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const
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:
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.
bool has_GGA_datum() const
true if the corresponding field exists in messages.
bool has_RMC_datum() const
true if the corresponding field exists in messages.