mrpt.graphs
mrpt.graphs — Pose graph types and graph algorithms.
- Provides:
CNetworkOfPoses2D : 2D pose graph (CPose2D edges)
CNetworkOfPoses3D : 3D pose graph (CPose3D edges)
CNetworkOfPoses2DCov, CNetworkOfPoses3DCov : pose graphs with Gaussian edges
CNetworkOfPoses2DInf, CNetworkOfPoses3DInf : pose graphs with edges in information form
Example:
import mrpt.graphs as graphs
import mrpt.poses as poses
g = graphs.CNetworkOfPoses2D()
g.setNodePose(0, poses.CPose2D(0, 0, 0))
g.setNodePose(1, poses.CPose2D(1, 0, 0))
g.insertEdge(0, 1, poses.CPose2D(1, 0, 0))
print(g)
Package Contents
- class mrpt.graphs.CNetworkOfPoses2D
A graph of 2D poses (nodes) and relative pose constraints (edges).
- property root: int
Root node ID (default: 0)
- clearEdges() None
Erases all the edges.
- dijkstra_nodes_estimate() None
Recomputes all node poses by composing edges along the shortest-path spanning tree from the root node
- dijkstra_path(source: int, target: int) list[int]
Shortest path (fewest edges) between two nodes as a list of node IDs, from source to target, ignoring edge directions. Raises ValueError if target is unreachable.
- edgeCount() int
Number of edges in the graph
- edgeExists(from_id: int, to_id: int) bool
Returns true if the directed edge from_id -> to_id exists.
- eraseEdge(from_id: int, to_id: int) None
Erases all the edges from_id -> to_id (nothing happens if none exists).
- getEdge(from_id: int, to_id: int) mrpt.poses.CPose2D
Returns a copy of the edge from_id -> to_id (the first one, if there are several). Raises KeyError if it does not exist.
- getEdges() list[tuple]
Returns all the edges as a list of tuples (from_id, to_id, edge), sorted by node IDs.
- getNeighborsOf(node_id: int) set[int]
IDs of the nodes connected to the given one by an edge (in any direction)
- getNodeDistances(source: int) dict[int, float]
Topological distance (number of edges) from source to every reachable node
- getNodeIDs() list[int]
Return a list of all node IDs
- getNodePose(node_id: int) mrpt.poses.CPose2D
Get the estimated pose for a node
- hasNode(node_id: int) bool
True if a node with the given ID exists
- insertEdge(from_id: int, to_id: int, edge: mrpt.poses.CPose2D) None
Insert a directed edge from → to
- loadFromTextFile(fileName: str, collapse_dup_edges: bool = True) None
Loads the graph from a text file in the TORO / g2o format.
- nodeCount() int
Number of nodes in the graph
- saveToTextFile(fileName: str) None
Saves the graph to a text file in the TORO / g2o format.
- setNodePose(node_id: int, pose: mrpt.poses.CPose2D) None
Set the estimated pose for a node
- class mrpt.graphs.CNetworkOfPoses2DCov
A graph of 2D poses (nodes, CPose2D) and relative pose constraints with a covariance matrix (edges, CPosePDFGaussian).
- property root: int
Root node ID (default: 0)
- clearEdges() None
Erases all the edges.
- dijkstra_nodes_estimate() None
Recomputes all node poses by composing edges along the shortest-path spanning tree from the root node
- dijkstra_path(source: int, target: int) list[int]
Shortest path (fewest edges) between two nodes as a list of node IDs, from source to target, ignoring edge directions. Raises ValueError if target is unreachable.
- edgeCount() int
Number of edges in the graph
- edgeExists(from_id: int, to_id: int) bool
Returns true if the directed edge from_id -> to_id exists.
- eraseEdge(from_id: int, to_id: int) None
Erases all the edges from_id -> to_id (nothing happens if none exists).
- getEdge(from_id: int, to_id: int) mrpt.poses.CPosePDFGaussian
Returns a copy of the edge from_id -> to_id (the first one, if there are several). Raises KeyError if it does not exist.
- getEdges() list[tuple]
Returns all the edges as a list of tuples (from_id, to_id, edge), sorted by node IDs.
- getNeighborsOf(node_id: int) set[int]
IDs of the nodes connected to the given one by an edge (in any direction)
- getNodeDistances(source: int) dict[int, float]
Topological distance (number of edges) from source to every reachable node
- getNodeIDs() list[int]
Return a list of all node IDs
- getNodePose(node_id: int) mrpt.poses.CPose2D
Get the estimated pose for a node
- hasNode(node_id: int) bool
True if a node with the given ID exists
- insertEdge(from_id: int, to_id: int, edge: mrpt.poses.CPosePDFGaussian) None
Insert a directed edge from → to
- loadFromTextFile(fileName: str, collapse_dup_edges: bool = True) None
Loads the graph from a text file in the TORO / g2o format.
- nodeCount() int
Number of nodes in the graph
- saveToTextFile(fileName: str) None
Saves the graph to a text file in the TORO / g2o format.
- setNodePose(node_id: int, pose: mrpt.poses.CPose2D) None
Set the estimated pose for a node
- class mrpt.graphs.CNetworkOfPoses2DInf
A graph of 2D poses (nodes, CPose2D) and relative pose constraints with an information matrix (edges, CPosePDFGaussianInf).
- property root: int
Root node ID (default: 0)
- clearEdges() None
Erases all the edges.
- dijkstra_nodes_estimate() None
Recomputes all node poses by composing edges along the shortest-path spanning tree from the root node
- dijkstra_path(source: int, target: int) list[int]
Shortest path (fewest edges) between two nodes as a list of node IDs, from source to target, ignoring edge directions. Raises ValueError if target is unreachable.
- edgeCount() int
Number of edges in the graph
- edgeExists(from_id: int, to_id: int) bool
Returns true if the directed edge from_id -> to_id exists.
- eraseEdge(from_id: int, to_id: int) None
Erases all the edges from_id -> to_id (nothing happens if none exists).
- getEdge(from_id: int, to_id: int) mrpt.poses.CPosePDFGaussianInf
Returns a copy of the edge from_id -> to_id (the first one, if there are several). Raises KeyError if it does not exist.
- getEdges() list[tuple]
Returns all the edges as a list of tuples (from_id, to_id, edge), sorted by node IDs.
- getNeighborsOf(node_id: int) set[int]
IDs of the nodes connected to the given one by an edge (in any direction)
- getNodeDistances(source: int) dict[int, float]
Topological distance (number of edges) from source to every reachable node
- getNodeIDs() list[int]
Return a list of all node IDs
- getNodePose(node_id: int) mrpt.poses.CPose2D
Get the estimated pose for a node
- hasNode(node_id: int) bool
True if a node with the given ID exists
- insertEdge(from_id: int, to_id: int, edge: mrpt.poses.CPosePDFGaussianInf) None
Insert a directed edge from → to
- loadFromTextFile(fileName: str, collapse_dup_edges: bool = True) None
Loads the graph from a text file in the TORO / g2o format.
- nodeCount() int
Number of nodes in the graph
- saveToTextFile(fileName: str) None
Saves the graph to a text file in the TORO / g2o format.
- setNodePose(node_id: int, pose: mrpt.poses.CPose2D) None
Set the estimated pose for a node
- class mrpt.graphs.CNetworkOfPoses3D
A graph of 3D poses (nodes) and relative pose constraints (edges).
- property root: int
Root node ID (default: 0)
- clearEdges() None
Erases all the edges.
- dijkstra_nodes_estimate() None
Recomputes all node poses by composing edges along the shortest-path spanning tree from the root node
- dijkstra_path(source: int, target: int) list[int]
Shortest path (fewest edges) between two nodes as a list of node IDs, from source to target, ignoring edge directions. Raises ValueError if target is unreachable.
- edgeCount() int
Number of edges in the graph
- edgeExists(from_id: int, to_id: int) bool
Returns true if the directed edge from_id -> to_id exists.
- eraseEdge(from_id: int, to_id: int) None
Erases all the edges from_id -> to_id (nothing happens if none exists).
- getEdge(from_id: int, to_id: int) mrpt.poses.CPose3D
Returns a copy of the edge from_id -> to_id (the first one, if there are several). Raises KeyError if it does not exist.
- getEdges() list[tuple]
Returns all the edges as a list of tuples (from_id, to_id, edge), sorted by node IDs.
- getNeighborsOf(node_id: int) set[int]
IDs of the nodes connected to the given one by an edge (in any direction)
- getNodeDistances(source: int) dict[int, float]
Topological distance (number of edges) from source to every reachable node
- getNodeIDs() list[int]
Return a list of all node IDs
- getNodePose(node_id: int) mrpt.poses.CPose3D
Get the estimated pose for a node
- hasNode(node_id: int) bool
True if a node with the given ID exists
- insertEdge(from_id: int, to_id: int, edge: mrpt.poses.CPose3D) None
Insert a directed edge from → to
- loadFromTextFile(fileName: str, collapse_dup_edges: bool = True) None
Loads the graph from a text file in the TORO / g2o format.
- nodeCount() int
Number of nodes in the graph
- saveToTextFile(fileName: str) None
Saves the graph to a text file in the TORO / g2o format.
- setNodePose(node_id: int, pose: mrpt.poses.CPose3D) None
Set the estimated pose for a node
- class mrpt.graphs.CNetworkOfPoses3DCov
A graph of 3D poses (nodes, CPose3D) and relative pose constraints with a covariance matrix (edges, CPose3DPDFGaussian).
- property root: int
Root node ID (default: 0)
- clearEdges() None
Erases all the edges.
- dijkstra_nodes_estimate() None
Recomputes all node poses by composing edges along the shortest-path spanning tree from the root node
- dijkstra_path(source: int, target: int) list[int]
Shortest path (fewest edges) between two nodes as a list of node IDs, from source to target, ignoring edge directions. Raises ValueError if target is unreachable.
- edgeCount() int
Number of edges in the graph
- edgeExists(from_id: int, to_id: int) bool
Returns true if the directed edge from_id -> to_id exists.
- eraseEdge(from_id: int, to_id: int) None
Erases all the edges from_id -> to_id (nothing happens if none exists).
- getEdge(from_id: int, to_id: int) mrpt.poses.CPose3DPDFGaussian
Returns a copy of the edge from_id -> to_id (the first one, if there are several). Raises KeyError if it does not exist.
- getEdges() list[tuple]
Returns all the edges as a list of tuples (from_id, to_id, edge), sorted by node IDs.
- getNeighborsOf(node_id: int) set[int]
IDs of the nodes connected to the given one by an edge (in any direction)
- getNodeDistances(source: int) dict[int, float]
Topological distance (number of edges) from source to every reachable node
- getNodeIDs() list[int]
Return a list of all node IDs
- getNodePose(node_id: int) mrpt.poses.CPose3D
Get the estimated pose for a node
- hasNode(node_id: int) bool
True if a node with the given ID exists
- insertEdge(from_id: int, to_id: int, edge: mrpt.poses.CPose3DPDFGaussian) None
Insert a directed edge from → to
- loadFromTextFile(fileName: str, collapse_dup_edges: bool = True) None
Loads the graph from a text file in the TORO / g2o format.
- nodeCount() int
Number of nodes in the graph
- saveToTextFile(fileName: str) None
Saves the graph to a text file in the TORO / g2o format.
- setNodePose(node_id: int, pose: mrpt.poses.CPose3D) None
Set the estimated pose for a node
- class mrpt.graphs.CNetworkOfPoses3DInf
A graph of 3D poses (nodes, CPose3D) and relative pose constraints with an information matrix (edges, CPose3DPDFGaussianInf).
- property root: int
Root node ID (default: 0)
- clearEdges() None
Erases all the edges.
- dijkstra_nodes_estimate() None
Recomputes all node poses by composing edges along the shortest-path spanning tree from the root node
- dijkstra_path(source: int, target: int) list[int]
Shortest path (fewest edges) between two nodes as a list of node IDs, from source to target, ignoring edge directions. Raises ValueError if target is unreachable.
- edgeCount() int
Number of edges in the graph
- edgeExists(from_id: int, to_id: int) bool
Returns true if the directed edge from_id -> to_id exists.
- eraseEdge(from_id: int, to_id: int) None
Erases all the edges from_id -> to_id (nothing happens if none exists).
- getEdge(from_id: int, to_id: int) mrpt.poses.CPose3DPDFGaussianInf
Returns a copy of the edge from_id -> to_id (the first one, if there are several). Raises KeyError if it does not exist.
- getEdges() list[tuple]
Returns all the edges as a list of tuples (from_id, to_id, edge), sorted by node IDs.
- getNeighborsOf(node_id: int) set[int]
IDs of the nodes connected to the given one by an edge (in any direction)
- getNodeDistances(source: int) dict[int, float]
Topological distance (number of edges) from source to every reachable node
- getNodeIDs() list[int]
Return a list of all node IDs
- getNodePose(node_id: int) mrpt.poses.CPose3D
Get the estimated pose for a node
- hasNode(node_id: int) bool
True if a node with the given ID exists
- insertEdge(from_id: int, to_id: int, edge: mrpt.poses.CPose3DPDFGaussianInf) None
Insert a directed edge from → to
- loadFromTextFile(fileName: str, collapse_dup_edges: bool = True) None
Loads the graph from a text file in the TORO / g2o format.
- nodeCount() int
Number of nodes in the graph
- saveToTextFile(fileName: str) None
Saves the graph to a text file in the TORO / g2o format.
- setNodePose(node_id: int, pose: mrpt.poses.CPose3D) None
Set the estimated pose for a node