Main MRPT website > C++ reference for MRPT 1.9.9
CLandmark.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "vision-precomp.h" // Precompiled headers
11 
12 #include <mrpt/utils/CStream.h>
13 #include <mrpt/maps/CLandmark.h>
14 #include <mrpt/obs/CObservation.h>
16 
17 using namespace mrpt::obs;
18 using namespace mrpt::maps;
19 using namespace mrpt::utils;
20 using namespace mrpt::poses;
21 
23 
24 // Initialization:
25 CLandmark::TLandmarkID CLandmark::m_counterIDs =
26  static_cast<CLandmark::TLandmarkID>(0);
27 
28 /*---------------------------------------------------------------
29  Default constructor
30  ---------------------------------------------------------------*/
31 CLandmark::CLandmark()
32  : features(),
33  pose_mean(),
34  normal(),
35  pose_cov_11(),
36  pose_cov_22(),
37  pose_cov_33(),
38  pose_cov_12(),
39  pose_cov_13(),
40  pose_cov_23(),
42  timestampLastSeen(INVALID_TIMESTAMP),
43  seenTimesCount(0)
44 {
45 }
46 
47 /*---------------------------------------------------------------
48  Destructor
49  ---------------------------------------------------------------*/
51 /*---------------------------------------------------------------
52  Destructor
53  ---------------------------------------------------------------*/
55 {
56  pose.mean.x(pose_mean.x);
57  pose.mean.y(pose_mean.y);
58  pose.mean.z(pose_mean.z);
59 
60  pose.cov(0, 0) = pose_cov_11;
61  pose.cov(1, 1) = pose_cov_22;
62  pose.cov(2, 2) = pose_cov_33;
63 
64  pose.cov(0, 1) = pose.cov(1, 0) = pose_cov_12;
65  pose.cov(0, 2) = pose.cov(2, 0) = pose_cov_13;
66 
67  pose.cov(1, 2) = pose.cov(2, 1) = pose_cov_23;
68 }
69 
70 /*---------------------------------------------------------------
71  Destructor
72  ---------------------------------------------------------------*/
74 {
75  pose_mean.x = pose.mean.x();
76  pose_mean.y = pose.mean.y();
77  pose_mean.z = pose.mean.z();
78 
79  pose_cov_11 = pose.cov(0, 0);
80  pose_cov_22 = pose.cov(1, 1);
81  pose_cov_33 = pose.cov(2, 2);
82  pose_cov_12 = pose.cov(0, 1);
83  pose_cov_13 = pose.cov(0, 2);
84  pose_cov_23 = pose.cov(1, 2);
85 }
86 
87 /*---------------------------------------------------------------
88  writeToStream
89  Implements the writing to a CStream capability of
90  CSerializable objects
91  ---------------------------------------------------------------*/
92 void CLandmark::writeToStream(mrpt::utils::CStream& out, int* version) const
93 {
94  if (version)
95  *version = 4;
96  else
97  {
101  }
102 }
103 
104 /*---------------------------------------------------------------
105  readFromStream
106  Implements the reading from a CStream capability of
107  CSerializable objects
108  ---------------------------------------------------------------*/
110 {
111  switch (version)
112  {
113  case 0:
114  case 1:
115  case 2:
116  case 3:
118  "Importing from this old version is not implemented");
119  break;
120  case 4:
121  {
122  in >> features >> pose_mean >> normal >> pose_cov_11 >>
125  }
126  break;
127  default:
129  };
130 }
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:135
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::vector< mrpt::vision::CFeature::Ptr > features
The set of features from which the landmark comes.
Definition: CLandmark.h:44
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CPoint3D mean
The mean value.
#define THROW_EXCEPTION(msg)
int64_t TLandmarkID
The type for the IDs of landmarks.
Definition: CLandmark.h:41
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CLandmark.cpp:109
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
void setPose(const mrpt::poses::CPointPDFGaussian &p)
Sets the pose from an object:
Definition: CLandmark.cpp:73
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
This namespace contains representation of robot actions and observations.
double x
X,Y,Z coordinates.
void getPose(mrpt::poses::CPointPDFGaussian &p) const
Returns the pose as an object:
Definition: CLandmark.cpp:54
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
mrpt::system::TTimeStamp timestampLastSeen
The last time that this landmark was observed.
Definition: CLandmark.h:77
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:16
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CLandmark.cpp:92
The class for storing "landmarks" (visual or laser-scan-extracted features,...)
Definition: CLandmark.h:35
virtual ~CLandmark()
Virtual destructor.
Definition: CLandmark.cpp:50
mrpt::math::TPoint3D normal
The "normal" to the landmark, i.e.
Definition: CLandmark.h:50
GLuint in
Definition: glext.h:7274
#define INVALID_LANDMARK_ID
Used for CObservationBearingRange::TMeasurement::beaconID and others.
Definition: CObservation.h:25
mrpt::math::TPoint3D pose_mean
The mean of the landmark 3D position.
Definition: CLandmark.h:47
uint32_t seenTimesCount
The number of times that this landmark has been seen.
Definition: CLandmark.h:79
A gaussian distribution for 3D points.
TLandmarkID ID
An ID for the landmark (see details next...) This ID was introduced in the version 3 of this class (2...
Definition: CLandmark.h:75



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019