Main MRPT website > C++ reference for MRPT 1.4.0
List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions
mrpt::obs::CObservationGPS Class Reference

Detailed Description

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:

Note that this object has two timestamp fields:

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

Example access to GPS datum:

//...
//gga.fields.XXX ...
}
This class stores messages from GNSS or GNSS+IMU devices, from consumer-grade inexpensive GPS receive...
bool hasMsgClass() const
Like hasMsgType() but allows querying for message classes, from any of those derived from mrpt::obs::...
Note
[API changed in MRPT 1.4.0] mrpt::obs::CObservationGPS now stores message objects in a more flexible way. API clean-up and extended so the number of GNSS message types is larger and more scalable.
Porting old code: For example, replace observation.GGA_datum.XXX with observation.getMsgByClass<gnss::Message_NMEA_GGA>().fields.XXX, etc.
See also
CObservation

Definition at line 60 of file obs/CObservationGPS.h.

#include <mrpt/obs/CObservationGPS.h>

Inheritance diagram for mrpt::obs::CObservationGPS:
Inheritance graph

Classes

struct  internal_msg_test_proxy
 Proxy class for type-based testing existence of data inside CObservationGPS::messages. More...
 

Public Types

typedef std::map< gnss::gnss_message_type_t, gnss::gnss_message_ptrmessage_list_t
 

Public Member Functions

 CObservationGPS ()
 ctor
 
template<class METRICMAP >
bool insertObservationInto (METRICMAP *theMap, const mrpt::poses::CPose3D *robotPose=NULL) const
 This method is equivalent to:
 
void getSensorPose (mrpt::math::TPose3D &out_sensorPose) const
 A general method to retrieve the sensor pose on the robot.
 
void setSensorPose (const mrpt::math::TPose3D &newSensorPose)
 A general method to change the sensor pose on the robot.
 
Main API to access to the data fields
template<class MSG_CLASS >
void setMsg (const MSG_CLASS &msg)
 Stores a message in the list messages, making a copy of the passed object.
 
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 >
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_messagegetMsgByType (const gnss::gnss_message_type_t type_id)
 Returns a pointer to the message in the list CObservationGPS::messages of the requested type.
 
const mrpt::obs::gnss::gnss_messagegetMsgByType (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.
 
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 NULL 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 (mrpt::utils::CStream &out) const
 Dumps the contents of the observation in a human-readable form to a given output stream.
 
void dumpToConsole (std::ostream &o=std::cout) const
 Dumps the contents of the observation in a human-readable form to an std::ostream (default=console)
 
void clear ()
 Empties this observation, clearing the container messages.
 
void swap (CObservationGPS &o)
 
void getSensorPose (mrpt::poses::CPose3D &out_sensorPose) const MRPT_OVERRIDE
 A general method to retrieve the sensor pose on the robot.
 
void setSensorPose (const mrpt::poses::CPose3D &newSensorPose) MRPT_OVERRIDE
 A general method to change the sensor pose on the robot.
 
void getDescriptionAsText (std::ostream &o) const MRPT_OVERRIDE
 Build a detailed, multi-line textual description of the observation contents and dump it to the output stream.
 
mrpt::system::TTimeStamp getOriginalReceivedTimeStamp () const MRPT_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.
 
Delayed-load manual control methods.
virtual void load () const
 Makes sure all images and other fields which may be externally stored are loaded in memory.
 
virtual void unload ()
 Unload all images, for the case they being delayed-load images stored in external files (othewise, has no effect).
 

Static Public Member Functions

Utilities
static bool GPS_time_to_UTC (uint16_t gps_week, double gps_sec, const int leap_seconds_count, mrpt::system::TTimeStamp &utc_out)
 Return false on invalid input data.
 
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 Attributes

GNSS (GPS) data fields
mrpt::poses::CPose3D sensorPose
 The sensor pose on the robot/vehicle.
 
mrpt::system::TTimeStamp originalReceivedTimestamp
 The local computer-based timestamp based on the reception of the message in the computer.
 
bool has_satellite_timestamp
 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.
 

Static Public Attributes

RTTI stuff <br>
static const mrpt::utils::TRuntimeClassId classCObservation
 

Protected Member Functions

void swap (CObservation &o)
 Swap with another observation, ONLY the data defined here in the base class CObservation. It's protected since it'll be only called from child classes that should know what else to swap appart from these common data.
 
CSerializable virtual methods
void writeToStream (mrpt::utils::CStream &out, int *getVersion) const MRPT_OVERRIDE
 
void readFromStream (mrpt::utils::CStream &in, int version) MRPT_OVERRIDE
 

RTTI stuff <br>

typedef CObservationGPSPtr SmartPtr
 
static mrpt::utils::CLASSINIT _init_CObservationGPS
 
static mrpt::utils::TRuntimeClassId classCObservationGPS
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const MRPT_OVERRIDE
 
virtual mrpt::utils::CObjectduplicate () const MRPT_OVERRIDE
 
static mrpt::utils::CObjectCreateObject ()
 
static CObservationGPSPtr Create ()
 

Deprecated, backwards compatible (MRPT <1.4.0) data and types

typedef gnss::UTC_time TUTCTime
 Deprecated, kept for backwards compatibility.
 
typedef gnss::Message_TOPCON_PZS TGPSDatum_PZS
 Deprecated, kept for backwards compatibility.
 
typedef gnss::Message_TOPCON_SATS TGPSDatum_SATS
 Deprecated, kept for backwards compatibility.
 
typedef gnss::Message_NMEA_GGA TGPSDatum_GGA
 Deprecated, kept for backwards compatibility.
 
typedef gnss::Message_NMEA_RMC TGPSDatum_RMC
 Deprecated, kept for backwards compatibility.
 
internal_msg_test_proxy< gnss::NMEA_GGAhas_GGA_datum
 Evaluates as a bool; true if the corresponding field exists in messages.
 
internal_msg_test_proxy< gnss::NMEA_RMChas_RMC_datum
 Evaluates as a bool; true if the corresponding field exists in messages.
 
internal_msg_test_proxy< gnss::TOPCON_PZShas_PZS_datum
 Evaluates as a bool; true if the corresponding field exists in messages.
 
internal_msg_test_proxy< gnss::TOPCON_SATShas_SATS_datum
 Evaluates as a bool; true if the corresponding field exists in messages.
 

Data common to any observation

mrpt::system::TTimeStamp timestamp
 The associated UTC time-stamp. Where available, this should contain the accurate satellite-based timestamp of the sensor reading.
 
std::string sensorLabel
 An arbitrary label that can be used to identify the sensor.
 
mrpt::system::TTimeStamp getTimeStamp () const
 Returns CObservation::timestamp for all kind of observations.
 

Member Typedef Documentation

◆ message_list_t

Definition at line 66 of file obs/CObservationGPS.h.

◆ SmartPtr

A typedef for the associated smart pointer

Definition at line 63 of file obs/CObservationGPS.h.

◆ TGPSDatum_GGA

Deprecated, kept for backwards compatibility.

Definition at line 150 of file obs/CObservationGPS.h.

◆ TGPSDatum_PZS

Deprecated, kept for backwards compatibility.

Definition at line 148 of file obs/CObservationGPS.h.

◆ TGPSDatum_RMC

Deprecated, kept for backwards compatibility.

Definition at line 151 of file obs/CObservationGPS.h.

◆ TGPSDatum_SATS

Deprecated, kept for backwards compatibility.

Definition at line 149 of file obs/CObservationGPS.h.

◆ TUTCTime

Deprecated, kept for backwards compatibility.

Definition at line 147 of file obs/CObservationGPS.h.

Constructor & Destructor Documentation

◆ CObservationGPS()

mrpt::obs::CObservationGPS::CObservationGPS ( )

ctor

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId * mrpt::obs::CObservationGPS::_GetBaseClass ( )
staticprotected

◆ clear()

void mrpt::obs::CObservationGPS::clear ( )

Empties this observation, clearing the container messages.

◆ Create()

static CObservationGPSPtr mrpt::obs::CObservationGPS::Create ( )
static

◆ CreateObject()

static mrpt::utils::CObject * mrpt::obs::CObservationGPS::CreateObject ( )
static

◆ dumpToConsole()

void mrpt::obs::CObservationGPS::dumpToConsole ( std::ostream &  o = std::cout) const

Dumps the contents of the observation in a human-readable form to an std::ostream (default=console)

◆ dumpToStream()

void mrpt::obs::CObservationGPS::dumpToStream ( mrpt::utils::CStream out) const

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

See also
dumpToConsole(), getDescriptionAsText()

◆ duplicate()

virtual mrpt::utils::CObject * mrpt::obs::CObservationGPS::duplicate ( ) const
virtual

◆ getDescriptionAsText()

void mrpt::obs::CObservationGPS::getDescriptionAsText ( std::ostream &  o) const
virtual

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.
This is the text that appears in RawLogViewer when selecting an object in the dataset

Reimplemented from mrpt::obs::CObservation.

◆ getMsgByClass() [1/2]

template<class MSG_CLASS >
MSG_CLASS & mrpt::obs::CObservationGPS::getMsgByClass ( )
inline

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

Exceptions
std::runtime_errorIf 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()

Definition at line 105 of file obs/CObservationGPS.h.

References ASSERT_, ASSERTMSG_, and mrpt::format().

◆ getMsgByClass() [2/2]

template<class MSG_CLASS >
const MSG_CLASS & mrpt::obs::CObservationGPS::getMsgByClass ( ) const
inline

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

Definition at line 113 of file obs/CObservationGPS.h.

References ASSERT_, ASSERTMSG_, and mrpt::format().

◆ getMsgByClassPtr() [1/2]

template<class MSG_CLASS >
MSG_CLASS * mrpt::obs::CObservationGPS::getMsgByClassPtr ( )
inline

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

Definition at line 122 of file obs/CObservationGPS.h.

◆ getMsgByClassPtr() [2/2]

template<class MSG_CLASS >
const MSG_CLASS * mrpt::obs::CObservationGPS::getMsgByClassPtr ( ) const
inline

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

Definition at line 128 of file obs/CObservationGPS.h.

◆ getMsgByType() [1/2]

mrpt::obs::gnss::gnss_message * mrpt::obs::CObservationGPS::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.

Exceptions
std::runtime_errorIf 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()

◆ getMsgByType() [2/2]

const mrpt::obs::gnss::gnss_message * mrpt::obs::CObservationGPS::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.

◆ getOriginalReceivedTimeStamp()

mrpt::system::TTimeStamp mrpt::obs::CObservationGPS::getOriginalReceivedTimeStamp ( ) const
virtual

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()

Reimplemented from mrpt::obs::CObservation.

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId * mrpt::obs::CObservationGPS::GetRuntimeClass ( ) const
virtual

Reimplemented from mrpt::obs::CObservation.

◆ getSensorPose() [1/2]

void mrpt::obs::CObservation::getSensorPose ( mrpt::math::TPose3D out_sensorPose) const
inherited

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

◆ getSensorPose() [2/2]

void mrpt::obs::CObservationGPS::getSensorPose ( mrpt::poses::CPose3D out_sensorPose) const
inlinevirtual

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

Implements mrpt::obs::CObservation.

Definition at line 138 of file obs/CObservationGPS.h.

◆ getTimeStamp()

mrpt::system::TTimeStamp mrpt::obs::CObservation::getTimeStamp ( ) const
inlineinherited

Returns CObservation::timestamp for all kind of observations.

See also
getOriginalReceivedTimeStamp()

Definition at line 63 of file obs/CObservation.h.

◆ GPS_time_to_UTC() [1/2]

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

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

◆ GPS_time_to_UTC() [2/2]

static bool mrpt::obs::CObservationGPS::GPS_time_to_UTC ( uint16_t  gps_week,
double  gps_sec,
const int  leap_seconds_count,
mrpt::system::TTimeStamp utc_out 
)
static

Return false on invalid input data.

Parameters
[in]leap_seconds_countGPS to UTC time number of leap seconds (normally grabbed from satellital live data)
[out]utc_outUTC timestamp

◆ hasMsgClass()

template<class MSG_CLASS >
bool mrpt::obs::CObservationGPS::hasMsgClass ( ) const
inline

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

See also
CObservationGPS::hasMsgType(),

Definition at line 92 of file obs/CObservationGPS.h.

◆ hasMsgType()

bool mrpt::obs::CObservationGPS::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()

◆ insertObservationInto()

template<class METRICMAP >
bool mrpt::obs::CObservation::insertObservationInto ( METRICMAP *  theMap,
const mrpt::poses::CPose3D robotPose = NULL 
) const
inlineinherited

This method is equivalent to:

map->insertObservation(this, robotPose)
Parameters
theMapThe map where this observation is to be inserted: the map will be updated.
robotPoseThe pose of the robot base for this observation, relative to the target metric map. Set to NULL (default) to use (0,0,0deg)
Returns
Returns true if the map has been updated, or false if this observations has nothing to do with a metric map (for example, a sound observation).
See also
CMetricMap, CMetricMap::insertObservation

Definition at line 83 of file obs/CObservation.h.

◆ load()

virtual void mrpt::obs::CObservation::load ( ) const
inlinevirtualinherited

Makes sure all images and other fields which may be externally stored are loaded in memory.

Note that for all CImages, calling load() is not required since the images will be automatically loaded upon first access, so load() shouldn't be needed to be called in normal cases by the user. If all the data were alredy loaded or this object has no externally stored data fields, calling this method has no effects.

See also
unload

Reimplemented in mrpt::obs::CObservation3DRangeScan.

Definition at line 125 of file obs/CObservation.h.

◆ readFromStream()

void mrpt::obs::CObservationGPS::readFromStream ( mrpt::utils::CStream in,
int  version 
)
protected

◆ setMsg()

template<class MSG_CLASS >
void mrpt::obs::CObservationGPS::setMsg ( const MSG_CLASS &  msg)
inline

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.

Definition at line 86 of file obs/CObservationGPS.h.

◆ setSensorPose() [1/2]

void mrpt::obs::CObservation::setSensorPose ( const mrpt::math::TPose3D newSensorPose)
inherited

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

◆ setSensorPose() [2/2]

void mrpt::obs::CObservationGPS::setSensorPose ( const mrpt::poses::CPose3D newSensorPose)
inlinevirtual

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

Implements mrpt::obs::CObservation.

Definition at line 139 of file obs/CObservationGPS.h.

◆ swap() [1/2]

void mrpt::obs::CObservation::swap ( CObservation o)
protectedinherited

Swap with another observation, ONLY the data defined here in the base class CObservation. It's protected since it'll be only called from child classes that should know what else to swap appart from these common data.

◆ swap() [2/2]

void mrpt::obs::CObservationGPS::swap ( CObservationGPS o)

◆ unload()

virtual void mrpt::obs::CObservation::unload ( )
inlinevirtualinherited

Unload all images, for the case they being delayed-load images stored in external files (othewise, has no effect).

See also
load

Reimplemented in mrpt::obs::CObservation3DRangeScan.

Definition at line 129 of file obs/CObservation.h.

◆ writeToStream()

void mrpt::obs::CObservationGPS::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const
protected

Member Data Documentation

◆ _init_CObservationGPS

mrpt::utils::CLASSINIT mrpt::obs::CObservationGPS::_init_CObservationGPS
staticprotected

Definition at line 63 of file obs/CObservationGPS.h.

◆ classCObservation

const mrpt::utils::TRuntimeClassId mrpt::obs::CObservation::classCObservation
staticinherited

Definition at line 50 of file obs/CObservation.h.

◆ classCObservationGPS

mrpt::utils::TRuntimeClassId mrpt::obs::CObservationGPS::classCObservationGPS
static

Definition at line 63 of file obs/CObservationGPS.h.

◆ classinfo

const mrpt::utils::TRuntimeClassId* mrpt::obs::CObservationGPS::classinfo
static

Definition at line 63 of file obs/CObservationGPS.h.

◆ has_GGA_datum

internal_msg_test_proxy<gnss::NMEA_GGA> mrpt::obs::CObservationGPS::has_GGA_datum

Evaluates as a bool; true if the corresponding field exists in messages.

Definition at line 164 of file obs/CObservationGPS.h.

◆ has_PZS_datum

internal_msg_test_proxy<gnss::TOPCON_PZS> mrpt::obs::CObservationGPS::has_PZS_datum

Evaluates as a bool; true if the corresponding field exists in messages.

Definition at line 166 of file obs/CObservationGPS.h.

◆ has_RMC_datum

internal_msg_test_proxy<gnss::NMEA_RMC> mrpt::obs::CObservationGPS::has_RMC_datum

Evaluates as a bool; true if the corresponding field exists in messages.

Definition at line 165 of file obs/CObservationGPS.h.

◆ has_satellite_timestamp

bool mrpt::obs::CObservationGPS::has_satellite_timestamp

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.

Definition at line 74 of file obs/CObservationGPS.h.

◆ has_SATS_datum

internal_msg_test_proxy<gnss::TOPCON_SATS> mrpt::obs::CObservationGPS::has_SATS_datum

Evaluates as a bool; true if the corresponding field exists in messages.

Definition at line 167 of file obs/CObservationGPS.h.

◆ messages

message_list_t mrpt::obs::CObservationGPS::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.

Definition at line 78 of file obs/CObservationGPS.h.

◆ originalReceivedTimestamp

mrpt::system::TTimeStamp mrpt::obs::CObservationGPS::originalReceivedTimestamp

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.

Definition at line 73 of file obs/CObservationGPS.h.

◆ sensorLabel

std::string mrpt::obs::CObservation::sensorLabel
inherited

An arbitrary label that can be used to identify the sensor.

Definition at line 60 of file obs/CObservation.h.

◆ sensorPose

mrpt::poses::CPose3D mrpt::obs::CObservationGPS::sensorPose

The sensor pose on the robot/vehicle.

Definition at line 72 of file obs/CObservationGPS.h.

◆ timestamp

mrpt::system::TTimeStamp mrpt::obs::CObservation::timestamp
inherited

The associated UTC time-stamp. Where available, this should contain the accurate satellite-based timestamp of the sensor reading.

See also
getOriginalReceivedTimeStamp(), getTimeStamp()

Definition at line 59 of file obs/CObservation.h.




Page generated by Doxygen 1.9.8 for MRPT 1.4.0 SVN: at Thu Dec 14 16:54:58 UTC 2023