MRPT  2.0.0
CObservation.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "obs-precomp.h" // Precompiled headers
11 
12 #include <mrpt/obs/CObservation.h>
13 #include <mrpt/poses/CPose3D.h>
15 #include <mrpt/system/os.h>
16 #include <iomanip>
17 
18 using namespace mrpt::obs;
19 using namespace mrpt::poses;
20 using namespace mrpt::math;
21 
23 
24 void CObservation::getSensorPose(mrpt::math::TPose3D& out_sensorPose) const
25 {
26  CPose3D p;
27  getSensorPose(p);
28  out_sensorPose = p.asTPose();
29 }
30 
32 {
33  setSensorPose(CPose3D(newSensorPose));
34 }
35 
37 {
38  std::swap(timestamp, o.timestamp);
39  std::swap(sensorLabel, o.sensorLabel);
40 }
41 
42 void CObservation::getDescriptionAsText(std::ostream& o) const
43 {
44  using namespace mrpt::system; // for the TTimeStamp << op
45 
46  o << mrpt::format(
47  "Timestamp (UTC): %s\n"
48  " (as time_t): %.09f\n",
49  mrpt::system::dateTimeToString(timestamp).c_str(),
50  mrpt::Clock::toDouble(timestamp));
51 
52  o << " (as TTimestamp): " << timestamp
53  << "\n"
54  "Sensor label: '"
55  << sensorLabel << "'"
56  << "\n\n";
57 }
58 
60 {
61  std::stringstream ss;
62  getDescriptionAsText(ss);
63  return ss.str();
64 }
static double toDouble(const time_point t) noexcept
Converts a timestamp to a UNIX time_t-like number, with fractional part.
Definition: Clock.cpp:106
#define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class, NS)
This must be inserted as implementation of some required members for virtual CSerializable classes: ...
mrpt::math::TPose3D asTPose() const
Definition: CPose3D.cpp:759
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
void swap(CObservation &o)
Swap with another observation, ONLY the data defined here in the base class CObservation.
This base provides a set of functions for maths stuff.
virtual void setSensorPose(const mrpt::poses::CPose3D &newSensorPose)=0
A general method to change the sensor pose on the robot.
This namespace contains representation of robot actions and observations.
std::string getDescriptionAsTextValue() const
Return by value version of getDescriptionAsText(std::ostream&)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
Definition: CObservation.h:62
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
Definition: CObservation.h:60
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
std::string dateTimeToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
Definition: datetime.cpp:154
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020