mrpt.graphs

mrpt.graphs — Pose graph types and graph algorithms.

Provides:
  • CNetworkOfPoses2D : 2D pose graph (CPose2D edges)

  • CNetworkOfPoses3D : 3D pose graph (CPose3D edges)

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
property root: int

Root node ID (default: 0)

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

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
nodeCount() → int

Number of nodes in the graph

saveToTextFile(fileName: str) → None
setNodePose(node_id: int, pose: mrpt.poses.CPose2D) → None

Set the estimated pose for a node

class mrpt.graphs.CNetworkOfPoses3D
property root: int

Root node ID (default: 0)

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

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
nodeCount() → int

Number of nodes in the graph

saveToTextFile(fileName: str) → None
setNodePose(node_id: int, pose: mrpt.poses.CPose3D) → None

Set the estimated pose for a node