MRPT  2.0.1
THypothesis.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/poses/CPose2D.h>
13 #include <mrpt/poses/CPose3D.h>
14 #include <cstdint>
15 
16 #include <iostream>
17 #include <sstream>
18 #include <string>
19 
20 namespace mrpt::graphs::detail
21 {
22 /**\brief An edge hypothesis between two nodeIDs.
23  *
24  * Struct practically provides a wrapper around the GRAPH_T::constraint_t
25  * instance. Represents a hypothesis for a potential, perhaps loop closing,
26  * edge (i.e. a graph constraint/edge), between two nodeIDs of the graph.
27  *
28  * \sa mrpt::deciders::CLoopCloserERD
29  * \ingroup mrpt_graphs_grp
30  */
31 template <class GRAPH_T>
33 {
34  /**\brief Handy typedefs */
35  /**\{*/
36  /**\brief type of graph constraints */
37  using constraint_t = typename GRAPH_T::constraint_t;
38  /**\brief type of underlying poses (2D/3D). */
39  using pose_t = typename constraint_t::type_value;
41  /**\}*/
42  /**\brief Constructor */
43  THypothesis();
44  /**\brief Destructor */
45  ~THypothesis();
46  /**\brief Return a string representation of the object at hand
47  *
48  */
49  /**\{*/
50  std::string getAsString(bool oneline = true) const;
51  void getAsString(std::string* str, bool oneline = true) const;
52  /**\}*/
53 
54  /**\brief Getter methods for the underlying edge
55  *
56  * \sa setEdge
57  */
58  /**\{*/
59  void getEdge(constraint_t* edge) const;
60  constraint_t getEdge() const;
61  /**\}*/
62 
63  /**\brief Setter method for the underlying edge
64  *
65  * \sa getEdge
66  */
67  void setEdge(const constraint_t& edge);
68 
69  /**\brief Getter methods for the inverse of the underlying edge */
70  /**\{*/
71  void getInverseEdge(constraint_t* edge) const;
73  /**\}*/
74 
75  /**\brief Reverse the hypothesis.
76  *
77  * Reversing implies, at least, changing order of from/to nodes and
78  * reversing
79  * the underlying edge
80  */
81  void inverseHypothesis();
82 
83  /**\brief ID of the current hypothesis */
84  size_t id;
85  /**\brief Starting node of the hypothesis */
87  /**\brief Ending node of the hypothesis */
89  /**\brief Field that specifies if the hypothesis is to be considered */
90  bool is_valid{true};
91  /**\brief Goodness value corresponding to the hypothesis edge
92  *
93  * \note For ICP edges this resolves to the CICP goodness measure for the
94  * alignment operation.
95  *
96  * \sa edge, mrpt::slam::CICP::goodness
97  */
98  double goodness{0};
99  /**\brief Compare the start and end nodes of two hypothesis
100  *
101  * \return True if ends match.
102  */
103  bool sameEndsWith(const self_t& other) const;
104  /**\brief Check if the start, end nodes are the ones given
105  *
106  * \return True if ends are the given ones
107  */
108  bool hasEnds(
110 
111  /**\brief Handy operator for using THypothesis in std::set
112  */
113  bool operator<(const self_t& other) const;
114 
115  inline friend std::ostream& operator<<(
116  std::ostream& o, const THypothesis<GRAPH_T>& h)
117  {
118  o << h.getAsString(/*oneline=*/true) << std::endl;
119  return o;
120  }
121 
122  private:
123  /**\brief Edge connecting the two nodes */
125 };
126 } // namespace mrpt::graphs::detail
127 #include "THypothesis_impl.h"
double goodness
Goodness value corresponding to the hypothesis edge.
Definition: THypothesis.h:98
void inverseHypothesis()
Reverse the hypothesis.
typename GRAPH_T::constraint_t constraint_t
Handy typedefs.
Definition: THypothesis.h:37
bool is_valid
Field that specifies if the hypothesis is to be considered.
Definition: THypothesis.h:90
Internal functions for MRPT.
typename constraint_t::type_value pose_t
type of underlying poses (2D/3D).
Definition: THypothesis.h:39
mrpt::graphs::TNodeID from
Starting node of the hypothesis.
Definition: THypothesis.h:86
bool operator<(const self_t &other) const
Handy operator for using THypothesis in std::set.
bool hasEnds(const mrpt::graphs::TNodeID from, const mrpt::graphs::TNodeID to) const
Check if the start, end nodes are the ones given.
THypothesis< GRAPH_T > self_t
Definition: THypothesis.h:40
mrpt::graphs::TNodeID to
Ending node of the hypothesis.
Definition: THypothesis.h:88
void setEdge(const constraint_t &edge)
Setter method for the underlying edge.
uint64_t TNodeID
A generic numeric type for unique IDs of nodes or entities.
Definition: TNodeID.h:16
friend std::ostream & operator<<(std::ostream &o, const THypothesis< GRAPH_T > &h)
Definition: THypothesis.h:115
constraint_t getInverseEdge() const
size_t id
ID of the current hypothesis.
Definition: THypothesis.h:84
An edge hypothesis between two nodeIDs.
Definition: THypothesis.h:32
bool sameEndsWith(const self_t &other) const
Compare the start and end nodes of two hypothesis.
constraint_t edge
Edge connecting the two nodes.
Definition: THypothesis.h:124
std::string getAsString(bool oneline=true) const
Return a string representation of the object at hand.



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020