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 
5 {
6 template <class GRAPH_T>
7 CIncrementalNodeRegistrationDecider<
9 {
10 }
11 
12 template <class GRAPH_T>
14  GRAPH_T>::~CIncrementalNodeRegistrationDecider()
15 {
16 }
17 
18 template <class GRAPH_T>
20 {
21  MRPT_START;
22 
23  // check that a node has already been registered - if not, default to
24  // (0,0,0)
25  pose_t last_pose_inserted =
26  this->m_prev_registered_nodeID != INVALID_NODEID
27  ? this->m_graph->nodes.at(this->m_prev_registered_nodeID)
28  : pose_t();
29 
30  // odometry criterion
31  bool registered = false;
32 
33  if (this->checkRegistrationConditionPose(
34  last_pose_inserted, this->getCurrentRobotPosEstimation()))
35  {
36  registered = this->registerNewNodeAtEnd();
37  }
38 
39  return registered;
40  MRPT_END;
41 } // end of checkRegistrationCondition
42 
43 template <class GRAPH_T>
46  const mrpt::poses::CPose2D& p1, const mrpt::poses::CPose2D& p2) const
47 {
48  using namespace mrpt::math;
49 
50  bool res = false;
51  if ((p1.distanceTo(p2) > params.registration_max_distance) ||
52  (fabs(wrapToPi(p1.phi() - p2.phi())) > params.registration_max_angle))
53  {
54  res = true;
55  }
56 
57  return res;
58 } // end of checkRegistrationConditionPose
59 
60 template <class GRAPH_T>
63  const mrpt::poses::CPose3D& p1, const mrpt::poses::CPose3D& p2) const
64 {
65  using namespace mrpt::math;
66 
67  std::cout << "In checkRegistrationConditionPose:\np1: " << p1.asString()
68  << "\np2: " << p1.asString() << std::endl;
69 
70  bool res = false;
71  if ((p1.distanceTo(p2) > params.registration_max_distance) ||
72  (fabs(wrapToPi(p1.roll() - p2.roll())) >
73  params.registration_max_angle) ||
74  (fabs(wrapToPi(p1.pitch() - p2.pitch())) >
75  params.registration_max_angle) ||
76  (fabs(wrapToPi(p1.yaw() - p2.yaw())) > params.registration_max_angle))
77  {
78  res = true;
79  }
80 
81  return res;
82 } // end of checkRegistrationConditionPose
83 
84 template <class GRAPH_T>
86  const std::string& source_fname)
87 {
88  MRPT_START;
89  parent_t::loadParams(source_fname);
90 
91  params.loadFromConfigFileName(
92  source_fname, "NodeRegistrationDeciderParameters");
93 
94  MRPT_END;
95 }
96 
97 template <class GRAPH_T>
99 {
100  MRPT_START;
101  parent_t::printParams();
102  params.dumpToConsole();
103 
104  MRPT_END;
105 }
106 
107 template <class GRAPH_T>
109  std::string* report_str) const
110 {
111  MRPT_START;
112  using namespace std;
113 
114  *report_str += params.getAsString();
115  *report_str += this->report_sep;
116 
117  MRPT_END;
118 }
119 
120 ///////////////////////////////////////////////////////////////////////////////
121 // TParams
122 
123 template <class GRAPH_T>
125 {
126 }
127 
128 template <class GRAPH_T>
130 {
131 }
132 
133 template <class GRAPH_T>
135  std::ostream& out) const
136 {
137  MRPT_START;
138  out << mrpt::format("%s", this->getAsString().c_str());
139  MRPT_END;
140 }
141 
142 template <class GRAPH_T>
144  const mrpt::config::CConfigFileBase& source, const std::string& section)
145 {
146  MRPT_START;
147  using namespace mrpt::math;
148 
149  registration_max_distance = source.read_double(
150  section, "registration_max_distance", 0.5 /* meter */, false);
151  registration_max_angle = source.read_double(
152  section, "registration_max_angle", 15 /* degrees */, false);
153  registration_max_angle = DEG2RAD(registration_max_angle);
154 
155  MRPT_END;
156 }
157 
158 template <class GRAPH_T>
160  std::string* params_out) const
161 {
162  MRPT_START;
163  using namespace mrpt::math;
164 
165  double max_angle_deg = RAD2DEG(registration_max_angle);
166  params_out->clear();
167 
168  *params_out +=
169  "------------------[ Fixed Intervals Incremental Node Registration "
170  "]------------------\n";
171  *params_out += mrpt::format(
172  "Max distance for registration = %.2f m\n", registration_max_distance);
173  *params_out += mrpt::format(
174  "Max angle for registration = %.2f deg\n", max_angle_deg);
175 
176  MRPT_END;
177 }
178 
179 template <class GRAPH_T>
181  const
182 {
183  MRPT_START;
184 
185  std::string str;
186  this->getAsString(&str);
187  return str;
188 
189  MRPT_END;
190 }
191 } // end of namespaces
192 
193 #endif /* end of include guard: \
194  CINCREMENTALNODEREGISTRATIONDECIDER_IMPL_H_UQKZGLEM */
195 
196 
#define MRPT_START
Definition: exceptions.h:262
virtual void printParams() const
Print the problem parameters - relevant to the decider/optimizer to the screen in a unified/compact w...
double RAD2DEG(const double x)
Radians to degrees.
double distanceTo(const CPoseOrPoint< OTHERCLASS > &b) const
Returns the Euclidean distance to another pose/point:
Definition: CPoseOrPoint.h:211
double DEG2RAD(const double x)
Degrees to radians.
double pitch() const
Get the PITCH angle (in radians)
Definition: CPose3D.h:532
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:526
STL namespace.
virtual bool checkRegistrationConditionPose(const mrpt::poses::CPose2D &p1, const mrpt::poses::CPose2D &p2) const
This class allows loading and storing values and vectors of different types from a configuration text...
This base provides a set of functions for maths stuff.
void dumpToTextStream(std::ostream &out) const
This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.
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:51
double roll() const
Get the ROLL angle (in radians)
Definition: CPose3D.h:538
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:600
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:38
typename GRAPH_T::constraint_t::type_value pose_t
type of underlying poses (2D/3D).
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
const double & phi() const
Get the phi angle of the 2D pose (in radians)
Definition: CPose2D.h:80
#define MRPT_END
Definition: exceptions.h:266
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section)
This method load the options from a ".ini"-like file or memory-stored string list.
virtual bool checkRegistrationCondition()
If estimated position surpasses the registration max values since the previous registered node...
#define INVALID_NODEID
Definition: TNodeID.h:19
GLuint res
Definition: glext.h:7268
GLenum const GLfloat * params
Definition: glext.h:3534
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020