10 #ifndef TUNCERTAINTYPATH_IMPL_H 11 #define TUNCERTAINTYPATH_IMPL_H 15 namespace mrpt {
namespace graphslam {
17 template<
class GRAPH_T>
21 template<
class GRAPH_T>
25 nodes_traversed.push_back(starting_node);
27 template<
class GRAPH_T>
33 nodes_traversed.push_back(starting_node);
34 this->addToPath(ending_node, edge);
37 template<
class GRAPH_T>
40 template<
class GRAPH_T>
48 nodes_traversed.clear();
51 curr_pose_pdf.mean =
pose_t();
55 init_path_mat *= 10000;
56 curr_pose_pdf.cov_inv = init_path_mat;
58 determinant_is_updated =
false;
59 determinant_cached = 0;
63 template<
class GRAPH_T>
68 template<
class GRAPH_T>
73 format(
"\nnodeID %lu is not the source of the path\n%s\n\n",
74 static_cast<unsigned long>(from),
75 this->getAsString().c_str()));
77 format(
"\nnodeID %lu is not the destination of the path\n%s\n\n",
78 static_cast<unsigned long>(to),
79 this->getAsString().c_str()));
82 template<
class GRAPH_T>
93 this->nodes_traversed.rbegin()[0],
94 "\"other\" instance must start from the nodeID that this " 95 "TUncertaintyPath has ended.");
97 "\"other\" instance doesn't have an initialized list of traversed nodes");
99 "\"this\" instance doesn't have an initialized list of traversed nodes");
111 this->nodes_traversed.insert(
112 this->nodes_traversed.end(),
123 determinant_is_updated =
false;
127 template<
class GRAPH_T>
129 const self_t& other)
const {
130 using namespace mrpt;
142 template<
class GRAPH_T>
144 const self_t& other)
const {
146 return !(*
this == other);
149 template<
class GRAPH_T>
155 curr_pose_pdf += edge;
158 nodes_traversed.push_back(node);
160 determinant_is_updated =
false;
163 template<
class GRAPH_T>
168 template<
class GRAPH_T>
172 out.
printf(
"%s\n", this->getAsString().c_str());
176 template<
class GRAPH_T>
178 using namespace mrpt;
185 string header_sep(30,
'=');
187 ss <<
"Path properties: " << endl;
188 ss << header_sep << endl << endl;
190 ss <<
"- CPosePDFGaussianInf: " 191 << (curr_pose_pdf.isInfType()?
"TRUE" :
"FALSE") << endl;
192 ss <<
"- Nodes list: \n\t< " <<
197 ss << curr_pose_pdf << endl;
201 if (curr_pose_pdf.isInfType()) {
202 curr_pose_pdf.getInformationMatrix(mat);
205 curr_pose_pdf.getCovariance(mat);
207 ss <<
"Determinant: " << mat.det();
211 template<
class GRAPH_T>
214 this->getAsString(&
s);
218 template<
class GRAPH_T>
221 return nodes_traversed.at(0);
223 template<
class GRAPH_T>
226 return nodes_traversed.back();
229 template<
class GRAPH_T>
231 using namespace mrpt;
237 if (determinant_is_updated)
return determinant_cached;
241 if (curr_pose_pdf.isInfType()) {
242 curr_pose_pdf.getInformationMatrix(mat);
245 curr_pose_pdf.getCovariance(mat);
247 double determinant = mat.det();
249 determinant_cached = determinant;
250 determinant_is_updated =
true;
257 template<
class GRAPH_T>
259 const self_t& other)
const {
260 using namespace mrpt;
266 (curr_pose_pdf.isInfType() && other.
curr_pose_pdf.isInfType()) ||
267 (!curr_pose_pdf.isInfType() && !other.
curr_pose_pdf.isInfType()),
269 "Constraints of given paths don't have the same representation of uncertainty"));
274 bool has_lower =
false;
275 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 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 BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
std::string BASE_IMPEXP 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.