10 #ifndef TUNCERTAINTYPATH_IMPL_H 11 #define TUNCERTAINTYPATH_IMPL_H 19 template <
class GRAPH_T>
24 template <
class GRAPH_T>
29 nodes_traversed.push_back(starting_node);
31 template <
class GRAPH_T>
37 nodes_traversed.push_back(starting_node);
38 this->addToPath(ending_node, edge);
41 template <
class GRAPH_T>
46 template <
class GRAPH_T>
55 nodes_traversed.clear();
58 curr_pose_pdf.mean =
pose_t();
63 init_path_mat *= 10000;
64 curr_pose_pdf.cov_inv = init_path_mat;
66 determinant_is_updated =
false;
67 determinant_cached = 0;
71 template <
class GRAPH_T>
77 template <
class GRAPH_T>
82 this->getSource() == from,
84 "\nnodeID %lu is not the source of the path\n%s\n\n",
85 static_cast<unsigned long>(from), this->getAsString().c_str()));
87 this->getDestination() == to,
89 "\nnodeID %lu is not the destination of the path\n%s\n\n",
90 static_cast<unsigned long>(to), this->getAsString().c_str()));
93 template <
class GRAPH_T>
105 "\"other\" instance must start from the nodeID that this " 106 "TUncertaintyPath has ended.");
109 "\"other\" instance doesn't have an initialized list of traversed " 112 this->nodes_traversed.size(),
113 "\"this\" instance doesn't have an initialized list of traversed " 126 this->nodes_traversed.insert(
137 determinant_is_updated =
false;
140 template <
class GRAPH_T>
143 using namespace mrpt;
154 template <
class GRAPH_T>
157 return !(*
this == other);
160 template <
class GRAPH_T>
165 curr_pose_pdf += edge;
168 nodes_traversed.push_back(node);
170 determinant_is_updated =
false;
173 template <
class GRAPH_T>
179 template <
class GRAPH_T>
183 out.
printf(
"%s\n", this->getAsString().c_str());
186 template <
class GRAPH_T>
189 using namespace mrpt;
196 string header_sep(30,
'=');
198 ss <<
"Path properties: " << endl;
199 ss << header_sep << endl << endl;
201 ss <<
"- CPosePDFGaussianInf: " 202 << (curr_pose_pdf.isInfType() ?
"TRUE" :
"FALSE") << endl;
207 ss << curr_pose_pdf << endl;
211 if (curr_pose_pdf.isInfType())
213 curr_pose_pdf.getInformationMatrix(mat);
217 curr_pose_pdf.getCovariance(mat);
219 ss <<
"Determinant: " << mat.det();
223 template <
class GRAPH_T>
227 this->getAsString(&
s);
231 template <
class GRAPH_T>
234 return nodes_traversed.at(0);
236 template <
class GRAPH_T>
239 return nodes_traversed.back();
242 template <
class GRAPH_T>
245 using namespace mrpt;
251 if (determinant_is_updated)
return determinant_cached;
255 if (curr_pose_pdf.isInfType())
257 curr_pose_pdf.getInformationMatrix(mat);
261 curr_pose_pdf.getCovariance(mat);
263 double determinant = mat.det();
265 determinant_cached = determinant;
266 determinant_is_updated =
true;
271 template <
class GRAPH_T>
273 const self_t& other)
const 275 using namespace mrpt;
281 (curr_pose_pdf.isInfType() && other.
curr_pose_pdf.isInfType()) ||
282 (!curr_pose_pdf.isInfType() && !other.
curr_pose_pdf.isInfType()),
284 "Constraints of given paths don't have the same " 285 "representation of uncertainty"));
290 bool has_lower =
false;
291 if (curr_pose_pdf.isInfType())
std::vector< mrpt::utils::TNodeID > nodes_traversed
Nodes that the Path comprises of.
std::string getAsString() const
Holds the data of an information path.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void addToPath(const mrpt::utils::TNodeID &node, const constraint_t &edge)
add a new link in the current path.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
std::string getSTLContainerAsString(const T &t)
Return a STL container in std::string form.
void clear()
Clear the contents of this container.
This class allows loading and storing values and vectors of different types from a configuration text...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
This base provides a set of functions for maths stuff.
uint64_t TNodeID
The type for node IDs in graphs of different types.
constraint_t curr_pose_pdf
Current path position + corresponding covariance.
constraint_t::type_value pose_t
type of underlying poses (2D/3D).
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
GLsizei const GLchar ** string
bool hasLowerUncertaintyThan(const self_t &other) const
Test if the current path has a lower uncertainty than the other path.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void assertIsBetweenNodeIDs(const mrpt::utils::TNodeID &from, const mrpt::utils::TNodeID &to) const
Assert that the current path is between the given nodeIDs.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion)
This method load the options from a ".ini"-like file or memory-stored string list.
bool operator==(const self_t &other) const
bool operator!=(const self_t &other) const
const mrpt::utils::TNodeID & getSource() const
Return the source node of this path.
GLsizei GLsizei GLchar * source
self_t & operator+=(const self_t &other)
GRAPH_T::constraint_t constraint_t
Handy typedefs.
#define ASSERTMSG_(f, __ERROR_MSG)
const mrpt::utils::TNodeID & getDestination() const
Return the Destination node of this path.
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.