27 std::swap(timestamp, o.timestamp);
28 std::swap(originalReceivedTimestamp, o.originalReceivedTimestamp);
29 std::swap(has_satellite_timestamp, o.has_satellite_timestamp);
30 std::swap(sensorLabel, o.sensorLabel);
31 std::swap(sensorPose, o.sensorPose);
32 messages.swap(o.messages);
35 uint8_t CObservationGPS::serializeGetVersion()
const {
return 11; }
38 out << timestamp << originalReceivedTimestamp << sensorLabel << sensorPose;
39 out << has_satellite_timestamp;
41 const uint32_t nMsgs = messages.size();
43 for (
const auto& message : messages) message.second->writeToStream(
out);
46 void CObservationGPS::serializeFrom(
56 in >> timestamp >> originalReceivedTimestamp >> sensorLabel >>
59 in >> has_satellite_timestamp;
61 has_satellite_timestamp =
62 (this->timestamp != this->originalReceivedTimestamp);
66 for (
unsigned i = 0; i < nMsgs; i++)
69 gnss::gnss_message::readAndBuildFromStream(in);
84 in.
ReadBuffer(&datum->fields,
sizeof(datum->fields));
93 in.
ReadBuffer(&datum->fields,
sizeof(datum->fields));
114 in >> has_GGA_datum_;
147 in >> has_RMC_datum_;
170 sensorPose.setFromValues(0, 0, 0, 0, 0, 0);
174 in >> has_PZS_datum_;
231 bool has_SATS_datum_;
232 in >> has_SATS_datum_;
236 "Reading TOPCON_SATS is broken: non-trivial POD data " 249 originalReceivedTimestamp = timestamp;
252 void CObservationGPS::dumpToStream(std::ostream&
out)
const 254 out <<
"\n------------- [CObservationGPS] Dump of " << messages.size()
255 <<
" messages --------------------\n";
256 for (
const auto& m : messages) m.second->dumpToStream(
out);
257 out <<
"-------------- [CObservationGPS] End of dump -----------------\n\n";
260 void CObservationGPS::dumpToConsole(std::ostream& o)
const 262 this->dumpToStream(o);
267 return originalReceivedTimestamp;
276 void CObservationGPS::getDescriptionAsText(std::ostream& o)
const 280 CObservation::getDescriptionAsText(o);
282 o <<
"Timestamp (UTC) of reception at the computer: " 284 o <<
" (as time_t): " << std::fixed << std::setprecision(5)
287 o <<
" (as TTimestamp): " << originalReceivedTimestamp << std::endl;
289 o <<
"Sensor position on the robot/vehicle: " << sensorPose << std::endl;
291 this->dumpToConsole(o);
296 return messages.find(type_id) != messages.end();
302 auto it = messages.find(type_id);
305 "[CObservationGPS::getMsgByType] Cannot find " 306 "any observation of type `%u`",
307 static_cast<unsigned int>(type_id)));
308 return it->second.get();
314 auto it = messages.find(type_id);
317 "[CObservationGPS::getMsgByType] Cannot find " 318 "any observation of type `%u`",
319 static_cast<unsigned int>(type_id)));
320 return it->second.get();
324 #define TIMECONV_JULIAN_DATE_START_OF_GPS_TIME (2444244.5) // [days] 326 const unsigned short gps_week,
const double gps_tow,
327 const unsigned int utc_offset,
double* julian_date)
329 if (gps_tow < 0.0 || gps_tow > 604800.0)
return false;
331 *julian_date = (gps_week + (gps_tow -
utc_offset) / 604800.0) * 7.0 +
338 bool is_a_leap_year =
false;
341 is_a_leap_year =
true;
342 if ((year % 100) == 0)
344 if ((year % 400) == 0)
345 is_a_leap_year =
true;
347 is_a_leap_year =
false;
350 return is_a_leap_year;
355 const unsigned short year,
357 const unsigned char month,
359 unsigned char* days_in_month)
361 unsigned char utmp = 0;
413 *days_in_month = utmp;
427 unsigned char minute;
428 unsigned char days_in_month = 0;
434 if (julian_date < 0.0)
return false;
436 a = lround(julian_date);
438 c = (int)(((
double)b - 122.1) / 365.25);
439 d = (int)(365.25 * c);
440 e = (int)(((
double)(b - d)) / 30.6001);
442 td = b - d - (int)(30.6001 * e) + fmod(julian_date + 0.5, 1.0);
443 day = (
unsigned char)td;
446 hour = (
unsigned char)td;
449 minute = (
unsigned char)td;
453 month = (
unsigned char)(e - 1 - 12 * (
int)(e / 14));
454 year = (
unsigned short)(c - 4715 - (
int)((7.0 + (double)month) / 10.0));
469 year, month, &days_in_month);
470 if (result ==
false)
return false;
471 if (day > days_in_month)
494 bool CObservationGPS::GPS_time_to_UTC(
495 uint16_t gps_week,
double gps_sec,
const int leap_seconds_count,
499 if (!GPS_time_to_UTC(gps_week, gps_sec, leap_seconds_count, tim))
505 bool CObservationGPS::GPS_time_to_UTC(
506 uint16_t gps_week,
double gps_sec,
const int leap_seconds_count,
509 double julian_date = 0.0;
510 if (gps_sec < 0.0 || gps_sec > 604800.0)
return false;
512 gps_week, gps_sec, leap_seconds_count, &julian_date))
double angle_transmitter
Vertical angle of N-beam.
uint8_t stats_rtk_fix_progress
[0,100] %, only in modes other than RTK FIXED.
uint8_t fix_quality
NMEA standard values: 0 = invalid, 1 = GPS fix (SPS), 2 = DGPS fix, 3 = PPS fix, 4 = Real Time Kinema...
double height_meters
ellipsoidal height from N-beam [m] perhaps weighted with regular gps
content_t fields
Message content, accesible by individual fields.
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
float PSigma
position SEP [m]
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
constexpr matrix_size_t size() const
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))
TopCon mmGPS devices: SATS, a generic structure for statistics about tracked satelites and their posi...
#define THROW_EXCEPTION(msg)
mrpt::math::CMatrixFloat44 vel_covariance
Only if hasPosCov is true.
std::string std::string format(std::string_view fmt, ARGS &&... args)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
gnss_message_type_t
List of all known GNSS message types.
mrpt::system::TTimeStamp buildTimestampFromParts(const mrpt::system::TTimeParts &p)
Builds a timestamp from the parts (Parts are in UTC)
uint32_t satellitesUsed
The number of satelites used to compute this estimation.
bool TIMECONV_GetJulianDateFromGPSTime(const unsigned short gps_week, const double gps_tow, const unsigned int utc_offset, double *julian_date)
bool TIMECONV_IsALeapYear(const unsigned short year)
GPS datum for TopCon's mmGPS devices: PZS.
int8_t validity_char
This will be: 'A'=OK or 'V'=void.
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
uint8_t nId
ID of the transmitter [1-4], 0 if none.
double orthometric_altitude
The measured orthometric altitude, in meters (A)+(B).
bool hasCartesianPosVel
system error indicator
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
double altitude_meters
The measured altitude, in meters (A).
bool thereis_HDOP
This states whether to take into account the value in the HDOP field.
This base provides a set of functions for maths stuff.
double corrected_orthometric_altitude
The corrected (only for TopCon mmGPS) orthometric altitude, in meters mmGPS(A+B). ...
#define MRPT_READ_POD(_STREAM, _VARIABLE)
mrpt::math::CMatrixFloat44 pos_covariance
Only if hasPosCov is true.
bool TIMECONV_GetNumberOfDaysInMonth(const unsigned short year, const unsigned char month, unsigned char *days_in_month)
uint8_t stats_GPS_sats_used
The parts of a date/time (it's like the standard 'tm' but with fractions of seconds).
uint8_t stats_GLONASS_sats_used
float HDOP
The HDOP (Horizontal Dilution of Precision) as returned by the sensor.
double timestampTotime_t(const mrpt::system::TTimeStamp t) noexcept
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)
This namespace contains representation of robot actions and observations.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
gnss_message_type_t message_type
Type of GNSS message.
uint8_t RXBattery
battery level on receiver
double second
Minute (0-59)
double cartesian_x
Only if hasCartesianPosVel is true.
double geoidal_distance
Undulation: Difference between the measured altitude and the geoid, in meters (B).
bool TIMECONV_GetUTCTimeFromJulianDate(const double julian_date, mrpt::system::TTimeParts &utc)
Number of days since noon Universal Time Jan 1, 4713 BCE (Julian calendar) [days].
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double speed_knots
Measured speed (in knots)
uint8_t minute
Hour (0-23)
Virtual base class for "archives": classes abstracting I/O streams.
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot's observation.
Pure virtual base for all message types.
std::string dateTimeToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
This file implements matrix/vector text and binary serialization.
double direction_degrees
Measured speed direction (in degrees)
content_t fields
Message content, accesible by individual fields.
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
double latitude_degrees
The measured latitude, in degrees (North:+ , South:-)
uint8_t Fix
1: GPS, 2: mmGPS
#define TIMECONV_JULIAN_DATE_START_OF_GPS_TIME
uint8_t TXBattery
battery level on transmitter
double cartesian_vx
Only if hasCartesianPosVel is true.
This class stores messages from GNSS or GNSS+IMU devices, from consumer-grade inexpensive GPS receive...
size_t ReadBufferFixEndianness(T *ptr, size_t ElementCount)
Reads a sequence of elemental datatypes, taking care of reordering their bytes from the MRPT stream s...
double RTK_height_meters
ellipsoidal height [m] without N-beam correction
void clear()
Clear the contents of this container.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
UTC_time UTCTime
The GPS sensor measured timestamp (in UTC time)
A smart pointer to a GNSS message.
double longitude_degrees
The measured longitude, in degrees (East:+ , West:-)