Main MRPT website > C++ reference for MRPT 1.5.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 
22 
24 
25 // Initialization:
26 CLandmark::TLandmarkID CLandmark::m_counterIDs= static_cast<CLandmark::TLandmarkID>(0);
27 
28 /*---------------------------------------------------------------
29  Default constructor
30  ---------------------------------------------------------------*/
32  features(),
33  pose_mean(),
34  normal(),
35  pose_cov_11(),pose_cov_22(),pose_cov_33(),pose_cov_12(),pose_cov_13(),pose_cov_23(),
36  ID( INVALID_LANDMARK_ID ),
37  timestampLastSeen( INVALID_TIMESTAMP ),
38  seenTimesCount(0)
39 {
40 }
41 
42 /*---------------------------------------------------------------
43  Destructor
44  ---------------------------------------------------------------*/
46 {
47 
48 }
49 
50 /*---------------------------------------------------------------
51  Destructor
52  ---------------------------------------------------------------*/
54 {
55  pose.mean.x( pose_mean.x);
56  pose.mean.y( pose_mean.y);
57  pose.mean.z( pose_mean.z);
58 
59  pose.cov(0,0) = pose_cov_11;
60  pose.cov(1,1) = pose_cov_22;
61  pose.cov(2,2) = pose_cov_33;
62 
63  pose.cov(0,1) = pose.cov(1,0) = pose_cov_12;
64  pose.cov(0,2) = pose.cov(2,0) = pose_cov_13;
65 
66  pose.cov(1,2) = pose.cov(2,1) = pose_cov_23;
67 }
68 
69 /*---------------------------------------------------------------
70  Destructor
71  ---------------------------------------------------------------*/
73 {
74  pose_mean.x = pose.mean.x();
75  pose_mean.y = pose.mean.y();
76  pose_mean.z = pose.mean.z();
77 
78  pose_cov_11 = pose.cov(0,0);
79  pose_cov_22 = pose.cov(1,1);
80  pose_cov_33 = pose.cov(2,2);
81  pose_cov_12 = pose.cov(0,1);
82  pose_cov_13 = pose.cov(0,2);
83  pose_cov_23 = pose.cov(1,2);
84 }
85 
86 /*---------------------------------------------------------------
87  writeToStream
88  Implements the writing to a CStream capability of
89  CSerializable objects
90  ---------------------------------------------------------------*/
92 {
93  if (version)
94  *version = 4;
95  else
96  {
97  out << features
98  << pose_mean
99  << normal
102  << ID
104  << seenTimesCount;
105  }
106 }
107 
108 /*---------------------------------------------------------------
109  readFromStream
110  Implements the reading from a CStream capability of
111  CSerializable objects
112  ---------------------------------------------------------------*/
114 {
115  switch(version)
116  {
117  case 0:
118  case 1:
119  case 2:
120  case 3:
121  THROW_EXCEPTION("Importing from this old version is not implemented");
122  break;
123  case 4:
124  {
125  in >> features
126  >> pose_mean
127  >> normal
130  >> ID
132  >> seenTimesCount;
133  } break;
134  default:
136  };
137 }
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:113
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
mrpt::maps::CLandmark CLandmark
Backward compatible typedef.
CPoint3D mean
The mean value.
#define THROW_EXCEPTION(msg)
double z
X,Y,Z coordinates.
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
int64_t TLandmarkID
The type for the IDs of landmarks.
std::vector< mrpt::vision::CFeaturePtr > features
The set of features from which the landmark comes.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
void setPose(const mrpt::poses::CPointPDFGaussian &p)
Sets the pose from an object:
Definition: CLandmark.cpp:72
#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.
void getPose(mrpt::poses::CPointPDFGaussian &p) const
Returns the pose as an object:
Definition: CLandmark.cpp:53
int version
Definition: mrpt_jpeglib.h:898
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.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:17
The class for storing "landmarks" (visual or laser-scan-extracted features,...)
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CLandmark.cpp:113
virtual ~CLandmark()
Virtual destructor.
Definition: CLandmark.cpp:45
mrpt::math::TPoint3D normal
The "normal" to the landmark, i.e. a unitary 3D vector towards the viewing direction, or a null vector if not applicable.
GLuint in
Definition: glext.h:6301
#define INVALID_LANDMARK_ID
Used for CObservationBearingRange::TMeasurement::beaconID and others.
mrpt::math::TPoint3D pose_mean
The mean of the landmark 3D position.
uint32_t seenTimesCount
The number of times that this landmark has been seen.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CLandmark.cpp:91
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...



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020