Main MRPT website > C++ reference for MRPT 1.9.9
CIncrementalNodeRegistrationDecider_impl.h
Go to the documentation of this file.
1 #ifndef CINCREMENTALNODEREGISTRATIONDECIDER_IMPL_H_UQKZGLEM
2 #define CINCREMENTALNODEREGISTRATIONDECIDER_IMPL_H_UQKZGLEM
3 
4 namespace mrpt
5 {
6 namespace graphslam
7 {
8 namespace deciders
9 {
10 template <class GRAPH_T>
11 CIncrementalNodeRegistrationDecider<
13 {
14 }
15 
16 template <class GRAPH_T>
18  GRAPH_T>::~CIncrementalNodeRegistrationDecider()
19 {
20 }
21 
22 template <class GRAPH_T>
24 {
25  MRPT_START;
26 
27  // check that a node has already been registered - if not, default to
28  // (0,0,0)
29  pose_t last_pose_inserted =
30  this->m_prev_registered_nodeID != INVALID_NODEID
31  ? this->m_graph->nodes.at(this->m_prev_registered_nodeID)
32  : pose_t();
33 
34  // odometry criterion
35  bool registered = false;
36 
37  if (this->checkRegistrationConditionPose(
38  last_pose_inserted, this->getCurrentRobotPosEstimation()))
39  {
40  registered = this->registerNewNodeAtEnd();
41  }
42 
43  return registered;
44  MRPT_END;
45 } // end of checkRegistrationCondition
46 
47 template <class GRAPH_T>
50  const mrpt::poses::CPose2D& p1, const mrpt::poses::CPose2D& p2) const
51 {
52  using namespace mrpt::math;
53 
54  bool res = false;
55  if ((p1.distanceTo(p2) > params.registration_max_distance) ||
56  (fabs(wrapToPi(p1.phi() - p2.phi())) > params.registration_max_angle))
57  {
58  res = true;
59  }
60 
61  return res;
62 } // end of checkRegistrationConditionPose
63 
64 template <class GRAPH_T>
67  const mrpt::poses::CPose3D& p1, const mrpt::poses::CPose3D& p2) const
68 {
69  using namespace mrpt::math;
70 
71  std::cout << "In checkRegistrationConditionPose:\np1: " << p1.asString()
72  << "\np2: " << p1.asString() << std::endl;
73 
74  bool res = false;
75  if ((p1.distanceTo(p2) > params.registration_max_distance) ||
76  (fabs(wrapToPi(p1.roll() - p2.roll())) >
77  params.registration_max_angle) ||
78  (fabs(wrapToPi(p1.pitch() - p2.pitch())) >
79  params.registration_max_angle) ||
80  (fabs(wrapToPi(p1.yaw() - p2.yaw())) > params.registration_max_angle))
81  {
82  res = true;
83  }
84 
85  return res;
86 } // end of checkRegistrationConditionPose
87 
88 template <class GRAPH_T>
90  const std::string& source_fname)
91 {
92  MRPT_START;
93  using namespace mrpt::utils;
94  parent_t::loadParams(source_fname);
95 
96  params.loadFromConfigFileName(
97  source_fname, "NodeRegistrationDeciderParameters");
98 
99  MRPT_END;
100 }
101 
102 template <class GRAPH_T>
104 {
105  MRPT_START;
106  parent_t::printParams();
107  params.dumpToConsole();
108 
109  MRPT_END;
110 }
111 
112 template <class GRAPH_T>
114  std::string* report_str) const
115 {
116  MRPT_START;
117  using namespace std;
118 
119  *report_str += params.getAsString();
120  *report_str += this->report_sep;
121 
122  MRPT_END;
123 }
124 
125 ///////////////////////////////////////////////////////////////////////////////
126 // TParams
127 
128 template <class GRAPH_T>
130 {
131 }
132 
133 template <class GRAPH_T>
135 {
136 }
137 
138 template <class GRAPH_T>
140  mrpt::utils::CStream& out) const
141 {
142  MRPT_START;
143  out.printf("%s", this->getAsString().c_str());
144  MRPT_END;
145 }
146 
147 template <class GRAPH_T>
149  const mrpt::utils::CConfigFileBase& source, const std::string& section)
150 {
151  MRPT_START;
152  using namespace mrpt::math;
153  using namespace mrpt::utils;
154 
155  registration_max_distance = source.read_double(
156  section, "registration_max_distance", 0.5 /* meter */, false);
157  registration_max_angle = source.read_double(
158  section, "registration_max_angle", 15 /* degrees */, false);
159  registration_max_angle = DEG2RAD(registration_max_angle);
160 
161  MRPT_END;
162 }
163 
164 template <class GRAPH_T>
166  std::string* params_out) const
167 {
168  MRPT_START;
169  using namespace mrpt::math;
170  using namespace mrpt::utils;
171 
172  double max_angle_deg = RAD2DEG(registration_max_angle);
173  params_out->clear();
174 
175  *params_out +=
176  "------------------[ Fixed Intervals Incremental Node Registration "
177  "]------------------\n";
178  *params_out += mrpt::format(
179  "Max distance for registration = %.2f m\n", registration_max_distance);
180  *params_out += mrpt::format(
181  "Max angle for registration = %.2f deg\n", max_angle_deg);
182 
183  MRPT_END;
184 }
185 
186 template <class GRAPH_T>
188  const
189 {
190  MRPT_START;
191 
192  std::string str;
193  this->getAsString(&str);
194  return str;
195 
196  MRPT_END;
197 }
198 }
199 }
200 } // end of namespaces
201 
202 #endif /* end of include guard: \
203  CINCREMENTALNODEREGISTRATIONDECIDER_IMPL_H_UQKZGLEM */
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
virtual void printParams() const
Print the problem parameters - relevant to the decider/optimizer to the screen in a unified/compact w...
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double distanceTo(const CPoseOrPoint< OTHERCLASS > &b) const
Returns the Euclidean distance to another pose/point:
Definition: CPoseOrPoint.h:206
void dumpToTextStream(mrpt::utils::CStream &out) const
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
#define INVALID_NODEID
double pitch() const
Get the PITCH angle (in radians)
Definition: CPose3D.h:539
virtual void getDescriptiveReport(std::string *report_str) const
Fill the provided string with a detailed report of the decider/optimizer state.
double yaw() const
Get the YAW angle (in radians)
Definition: CPose3D.h:533
STL namespace.
This class allows loading and storing values and vectors of different types from a configuration text...
virtual bool checkRegistrationConditionPose(const mrpt::poses::CPose2D &p1, const mrpt::poses::CPose2D &p2) const
GRAPH_T::constraint_t::type_value pose_t
type of underlying poses (2D/3D).
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_END
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section)
This method load the options from a ".ini"-like file or memory-stored string list.
#define DEG2RAD
GLsizei const GLchar ** string
Definition: glext.h:4101
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
Definition: wrap2pi.h:53
double roll() const
Get the ROLL angle (in radians)
Definition: CPose3D.h:545
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y z yaw pitch roll]"...
Definition: CPose3D.h:607
#define MRPT_START
#define RAD2DEG
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
const double & phi() const
Get the phi angle of the 2D pose (in radians)
Definition: CPose2D.h:91
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
virtual bool checkRegistrationCondition()
If estimated position surpasses the registration max values since the previous registered node...
GLuint res
Definition: glext.h:7268
GLenum const GLfloat * params
Definition: glext.h:3534
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Definition: CStream.cpp:597
virtual void loadParams(const std::string &source_fname)
Load the necessary for the decider/optimizer configuration parameters.



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