Template Class CNetworkOfPoses
Defined in File CNetworkOfPoses.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public mrpt::graphs::CDirectedGraph< CPOSE, mrpt::graphs::detail::edge_annotations_empty >(Template Class CDirectedGraph)
Class Documentation
-
template<class CPOSE, class MAPS_IMPLEMENTATION = mrpt::containers::map_traits_stdmap, class NODE_ANNOTATIONS = mrpt::graphs::detail::TNodeAnnotationsEmpty, class EDGE_ANNOTATIONS = mrpt::graphs::detail::edge_annotations_empty>
class CNetworkOfPoses : public mrpt::graphs::CDirectedGraph<CPOSE, mrpt::graphs::detail::edge_annotations_empty> A directed graph of pose constraints, with edges being the relative poses between pairs of nodes identified by their numeric IDs (of type mrpt::graphs::TNodeID). A link or edge between two nodes “i” and “j”, that is, the pose \( p_{ij} \), holds the relative position of “j” with respect to “i”. These poses are stored in the edges in the format specified by the template argument CPOSE. Users should employ the following derived classes depending on the desired representation of edges:
mrpt::graphs::CNetworkOfPoses2D: 2D edges as a simple CPose2D (x y phi)
mrpt::graphs::CNetworkOfPoses3D : 3D edges as a simple mrpt::poses::CPose3D (x y z yaw pitch roll)
mrpt::graphs::CNetworkOfPoses2DInf : 2D edges as a Gaussian PDF with information matrix (CPosePDFGaussianInf)
mrpt::graphs::CNetworkOfPoses3DInf : 3D edges as a Gaussian PDF with information matrix (CPose3DPDFGaussianInf)
mrpt::graphs::CNetworkOfPoses2DCov : 2D edges as a Gaussian PDF with covariance matrix (CPosePDFGaussian). It’s more efficient to use the information matrix version instead!
mrpt::graphs::CNetworkOfPoses3DCov : 3D edges as a Gaussian PDF with covariance matrix (CPose3DPDFGaussian). It’s more efficient to use the information matrix version instead!
Two main members store all the information in this class:
edges (in the base class mrpt::graphs::CDirectedGraph::edges): A map from pairs of node ID -> pose constraints.
nodes : A map from node ID -> estimated pose of that node (actually, read below on the template argument MAPS_IMPLEMENTATION).
Graphs can be loaded and saved to text file in the format used by TORO & HoG-man (more on the format here), using loadFromTextFile and saveToTextFile.
This class is the base for representing networks of poses, which are the main data type of a series of SLAM algorithms implemented in the library mrpt-slam, in the namespace mrpt::graphslam.
The template arguments are:
CPOSE: The type of the edges, which hold a relative pose (2D/3D, just a value or a Gaussian, etc.)
MAPS_IMPLEMENTATION: Can be either mrpt::containers::map_traits_stdmap or mrpt::containers::map_traits_map_as_vector. Determines the type of the list of global poses (member nodes).
See also
mrpt::graphslam
Typedef’s
-
using BASE = mrpt::graphs::CDirectedGraph<CPOSE, EDGE_ANNOTATIONS>
The base class “CDirectedGraph<CPOSE,EDGE_ANNOTATIONS>”
-
using self_t = CNetworkOfPoses<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS, EDGE_ANNOTATIONS>
My own type
-
using constraint_t = CPOSE
The type of PDF poses in the contraints (edges) (=CPOSE template argument)
-
using node_annotations_t = NODE_ANNOTATIONS
The extra annotations in nodes, apart from a constraint_no_pdf_t
-
using edge_annotations_t = EDGE_ANNOTATIONS
The extra annotations in edges, apart from a constraint_t
-
using maps_implementation_t = MAPS_IMPLEMENTATION
The type of map’s implementation (=MAPS_IMPLEMENTATION template argument)
-
using constraint_no_pdf_t = typename CPOSE::type_value
The type of edges or their means if they are PDFs (that is, a simple “edge” value)
-
using global_poses_pdf_t = typename MAPS_IMPLEMENTATION::template map<mrpt::graphs::TNodeID, CPOSE>
A map from pose IDs to their global coordinate estimates, with uncertainty
-
using global_poses_t = typename MAPS_IMPLEMENTATION::template map<mrpt::graphs::TNodeID, global_pose_t>
A map from pose IDs to their global coordinate estimates, without uncertainty (the “most-likely value”)
-
static inline constexpr auto getClassName()
Data members
-
global_poses_t nodes
The nodes (vertices) of the graph, with their estimated “global” (with respect to root) position, without an associated covariance.
See also
-
mrpt::graphs::TNodeID root = {0}
The ID of the node that is the origin of coordinates, used as reference by all coordinates in nodes. By default, root is the ID “0”.
-
bool edges_store_inverse_poses = {false}
False (default) if an edge i->j stores the normal relative pose of j as seen from i: \( \Delta_i^j = j \ominus i \) True if an edge i->j stores the inverse relateive pose, that is, i as seen from j: \( \Delta_i^j = i \ominus j \)
Utility methods
-
static inline void connectGraphPartitions(self_t *sub_graph, const std::set<TNodeID> &groupA, const std::set<TNodeID> &groupB)
Add an edge between the last node of the group with the lower nodeIDs and the first node of the higher nodeIDs.
Given groups of nodes should only contain consecutive nodeIDs and there should be no overlapping between them
Note
It is assumed that the sets of nodes are already in ascending order (default std::set behavior.
-
inline void getAs3DObject(mrpt::viz::CSetOfObjects::Ptr object, const mrpt::containers::yaml &viz_params) const
Return 3D Visual Representation of the edges and nodes in the network of poses.
Method makes the call to the corresponding method of the CVisualizer class instance.
-
inline void dijkstra_nodes_estimate(std::optional<std::reference_wrapper<std::map<TNodeID, size_t>>> topological_distances = std::nullopt)
Spanning tree computation of a simple estimation of the global coordinates of each node just from the information in all edges, sorted in a Dijkstra tree based on the current “root” node.
See also
node, root
Note
The “global” coordinates are with respect to the node with the ID specified in root.
Note
This method takes into account the value of edges_store_inverse_poses
-
inline size_t collapseDuplicatedEdges()
Look for duplicated edges (even in opposite directions) between all pairs of nodes and fuse them. Upon return, only one edge remains between each pair of nodes with the mean & covariance (or information matrix) corresponding to the Bayesian fusion of all the Gaussians.
- Returns:
Overall number of removed edges.
-
inline double chi2() const
Returns the total chi-squared error of the graph. Shortcut for getGlobalSquareError(false).
-
inline double getGlobalSquareError(bool ignoreCovariances = true) const
Evaluates the graph total square error (ignoreCovariances=true) or chi2 (ignoreCovariances=false) from all the pose constraints (edges) with respect to the global poses in nodes.
See also
- Throws:
std::exception – On global poses not in nodes
-
inline void extractSubGraph(const std::set<TNodeID> &node_IDs, self_t *sub_graph, const TNodeID root_node_in = INVALID_NODEID, bool auto_expand_set = true) const
Find the edges between the nodes in the node_IDs set and fill given graph pointer accordingly.
- Parameters:
node_IDs – [in] Set of nodes, between which, edges should be found and inserted in the given sub_graph pointer
root_node_in – [in] Node ID to be used as the root node of sub_graph. If this is not given, the lowest nodeID is to be used.
CNetworkOfPoses – pointer that is to be filled.
auto_expand_set – [in] If true and in case the node_IDs set contains non-consecutive nodes the returned set is expanded with the in-between nodes. This makes sure that the final graph is always connected. If auto_expand_set is false but there exist non-consecutive nodes, virtual edges are inserted in the parts that the graph is not connected
-
inline double getEdgeSquareError(const typename BASE::edges_map_t::const_iterator &itEdge, bool ignoreCovariances = true) const
Computes the square error of one pose constraints (edge) with respect to the global poses in nodes If ignoreCovariances is false, the squared Mahalanobis distance will be computed instead of the straight square error.
- Throws:
std::exception – On global poses not in nodes
-
inline double getEdgeSquareError(const mrpt::graphs::TNodeID from_id, const mrpt::graphs::TNodeID to_id, bool ignoreCovariances = true) const
Computes the square error of one pose constraints (edge) with respect to the global poses in nodes If ignoreCovariances is false, the squared Mahalanobis distance will be computed instead of the straight square error.
- Throws:
std::exception – On edge not existing or global poses not in nodes
-
inline void clear()
Empty all edges, nodes and set root to ID 0.
-
inline size_t nodeCount() const
Return number of nodes in the list nodes of global coordinates (may be different that all nodes appearing in edges)
I/O methods
-
inline void saveToTextFile(const std::string &fileName) const
Saves to a text file in the format used by TORO, HoG-man, G2O. See: https://www.mrpt.org/Graph-SLAM_maps
See also
saveToBinaryFile, loadFromTextFile, writeAsText
- Throws:
On – any error
-
inline void writeAsText(std::ostream &o) const
Writes as text in the format used by TORO, HoG-man, G2O. See: https://www.mrpt.org/Graph-SLAM_maps
See also
saveToBinaryFile, loadFromTextFile, saveToTextFile, readAsText
- Throws:
On – any error
-
inline void loadFromTextFile(const std::string &fileName, bool collapse_dup_edges = true)
Loads from a text file in the format used by TORO & HoG-man (more on the format here) Recognized line entries are: VERTEX2, VERTEX3, EDGE2, EDGE3, EQUIV. If an unknown entry is found, a warning is dumped to std::cerr (only once for each unknown keyword). An exception will be raised if trying to load a 3D graph into a 2D class (in the opposite case, missing 3D data will default to zero).
See also
loadFromBinaryFile, saveToTextFile
- Parameters:
fileName – [in] The file to load.
collapse_dup_edges – [in] If true, collapseDuplicatedEdges will be called automatically after loading (note that this operation may take significant time for very large graphs).
- Throws:
On – any error, as a malformed line or loading a 3D graph in a 2D graph.
-
inline void readAsText(std::istream &i)
Reads as text in the format used by TORO, HoG-man, G2O. See: https://www.mrpt.org/Graph-SLAM_maps
See also
saveToBinaryFile, loadFromTextFile, saveToTextFile
- Throws:
On – any error
-
struct global_pose_t : public constraint_no_pdf_t, public NODE_ANNOTATIONS
The type of each global pose in nodes: an extension of the constraint_no_pdf_t pose with any optional user-defined data
Unnamed Group
-
global_pose_t() = default
Potential class constructors.
Public Types
-
using self_t = typename CNetworkOfPoses<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS, EDGE_ANNOTATIONS>::global_pose_t
Public Functions
-
inline bool operator==(const global_pose_t &other) const
-
inline bool operator!=(const global_pose_t &other) const
Public Static Functions
-
static inline constexpr auto getClassName()
-
global_pose_t() = default