Main MRPT website > C++ reference for MRPT 1.9.9
CObservation6DFeatures.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 "obs-precomp.h" // Precompiled headers
11 
12 #include <mrpt/utils/CStream.h>
14 #include <mrpt/system/os.h>
16 
17 using namespace mrpt::obs;
18 using namespace mrpt::utils;
19 using namespace mrpt::poses;
20 
21 // This must be added to any CSerializable class implementation file.
23 
24 /** Default constructor */
26  : minSensorDistance(0), maxSensorDistance(1e6f)
27 {
28 }
29 
31 {
32 }
33 
34 /*---------------------------------------------------------------
35  Implements the writing to a CStream capability of CSerializable objects
36  ---------------------------------------------------------------*/
38  mrpt::utils::CStream& out, int* version) const
39 {
40  if (version)
41  *version = 0;
42  else
43  {
45 
46  const uint32_t n = sensedFeatures.size();
47  out << n;
48  for (uint32_t i = 0; i < n; i++)
49  {
50  const TMeasurement& m = sensedFeatures[i];
51  out << m.pose << m.id << m.inf_matrix;
52  }
53 
54  out << sensorLabel << timestamp;
55  }
56 }
57 
58 /*---------------------------------------------------------------
59  Implements the reading from a CStream capability of CSerializable objects
60  ---------------------------------------------------------------*/
62  mrpt::utils::CStream& in, int version)
63 {
64  switch (version)
65  {
66  case 0:
67  {
69 
70  uint32_t n;
71  in >> n;
72  sensedFeatures.clear();
73  sensedFeatures.resize(n);
74  for (uint32_t i = 0; i < n; i++)
75  {
77  in >> m.pose >> m.id >> m.inf_matrix;
78  }
79 
80  in >> sensorLabel >> timestamp;
81  }
82  break;
83  default:
85  };
86 }
87 
89 {
90  out_sensorPose = sensorPose;
91 }
92 
94 {
95  sensorPose = newSensorPose;
96 }
97 
99 {
100  using namespace std;
102 
103  o << "Sensor pose: " << sensorPose << endl;
104  o << "Min range : " << minSensorDistance << endl;
105  o << "Max range : " << maxSensorDistance << endl << endl;
106 
107  o << "Observation count : " << sensedFeatures.size() << endl << endl;
108 
109  for (size_t k = 0; k < sensedFeatures.size(); k++)
110  {
112  o << "#" << k << ": ID=" << m.id << "; value=" << m.pose
113  << "; inf=" << m.inf_matrix.inMatlabFormat() << endl;
114  }
115 }
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
GLenum GLsizei n
Definition: glext.h:5074
mrpt::poses::CPose3D sensorPose
The pose of the sensor on the robot/vehicle.
float minSensorDistance
Information about the sensor.
STL namespace.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
mrpt::poses::CPose3D pose
The observed feature SE(3) pose with respect to the sensor.
This namespace contains representation of robot actions and observations.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
Definition: CObservation.h:60
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
Definition: CObservation.h:58
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...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
An observation of one or more "features" or "objects", possibly identified with a unique ID...
This file implements matrix/vector text and binary serialization.
GLuint id
Definition: glext.h:3909
mrpt::math::CMatrixDouble66 inf_matrix
The inverse of the observation covariance matrix (default:all zeros)
GLuint in
Definition: glext.h:7274
#define INVALID_LANDMARK_ID
Used for CObservationBearingRange::TMeasurement::beaconID and others.
Definition: CObservation.h:25
int32_t id
The feature ID, or INVALID_LANDMARK_ID if unidentified (default)
mrpt::aligned_containers< TMeasurement >::deque_t sensedFeatures
The list of observed features.
unsigned __int32 uint32_t
Definition: rptypes.h:47
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
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 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019