Python wrapper for the DSR Graph

Initialization

# import the module
import pydsr

# constants
AGENT_ID = 42                    # unique among agents
DSR_NAME = "example_dsr_graph"   # target DSR graph name

# retrieve the graph and the RT-edge API objects
g      = pydsr.DSRGraph(0, DSR_NAME, AGENT_ID)
rt_api = pydsr.rt_api(g)

Methods

Attribute

Attribute(v, t: int, agent_id: int) → Attribute

Attribute(v, agent_id: int) → Attribute

Constructor.

Attribute.agent_id

TODO

Attribute.timestamp

TODO

Attribute.value

TODO

Edge

Edge(to: int, from: int, type: str, agent_id: int) → Edge

Constructor.

Edge.type

TODO

Edge.origin

TODO

Edge.destination

TODO

Edge.agent_id

TODO

Edge.attrs

TODO

DSRGraph

DSRGraph.get_node(id: int) → Node

DSRGraph.get_node(name: str) → Node

Return the node with the id or name passed as parameter. Returns None if the node does not exist.

DSRGraph.delete_node(id: int) → bool

DSRGraph.delete_node(name: str) → bool

Delete the node with the given id. Returns a bool with the result o the operation.

DSRGraph.insert_node(node: Node) → int

Insert in the graph the new node passed as parameter. Returns the id of the node or None if the Node alredy exist in the map.

DSRGraph.update_node(node: Node) → bool

Update the node in the graph. Returns a bool indicating whether the operation was successful.

DSRGraph.get_edge(from: int, to: int, type: str) → Edge

DSRGraph.get_edge(from: str, to: str, type: str) → Edge

Return the edge with the parameters from, to, and type passed as parameter. Returns None if the edge does not exist.

DSRGraph.insert_or_assign_edge(edge: Edge) → bool

Insert or updates and edge. Returns a bool indicating whether the operation was successful.

DSRGraph.delete_edge(from: int, to: int, type: str) → bool

DSRGraph.delete_edge(from: str, to: str, type: str) → bool

Return the edge with the parameters from, to, and type passed as parameter. Returns a bool indicating whether the operation was successful.

DSRGraph.get_node_root() → Node

Return the root node.

DSRGraph.get_nodes_by_type(type: str) → [Node]

Return all the nodes with a given type.

DSRGraph.get_name_from_id(id: int) → str

Return the name of a node given its id.

DSRGraph.get_id_from_name(name: str) → int

Return the id from a node given its name.

DSRGraph.get_edges_by_type(type: str) → [Edge]

Return all the edges with a given type.

DSRGraph.get_edges_to_id(id: int) → [Edge]

Return all the edges that point to a node.

DSRGraph.write_to_json_file(file, skip_attrs: [str]) → [Edge]

Dump the graph to a JSON file, skipping the attributes in skip_attrs.

InnerEigenAPI

InnerEigenAPI.transform(orig: str, dest: str, timestamp: int) →

InnerEigenAPI.transform(orig: str, vector, dest: str, timestamp: int) →

TODO

InnerEigenAPI.transform(orig: str, dest: str, timestamp: int) →

InnerEigenAPI.transform(orig: str, vector, dest: str, timestamp: int) →

TODO

InnerEigenAPI.get_transformation_matrix(orig: str, dest: str, timestamp: int) →

TODO

InnerEigenAPI.get_rotation_matrix(orig: str, dest: str, timestamp: int) →

TODO

InnerEigenAPI.get_translation_vector(orig: str, dest: str, timestamp: int) →

TODO

InnerEigenAPI.get_euler_xyz_angles(orig: str, dest: str, timestamp: int) →

TODO

Node

Node(agent_id: int, type: str, name: str) → Node

Constructor.

Node.id

TODO

Node.name

TODO

Node.type

TODO

Node.agent_id

TODO

Node.attrs

TODO

Node.edges

TODO

RT_API

RT_API.insert_or_assign_edge_RT(node: Node, to: int, translation: [float], rotation_euler: [float]) →

TODO

RT_API.get_edge_RT(node: Node, to: int) →

TODO

RT_API.get_RT_pose_from_parent(node: Node) →

TODO

RT_API.get_edge_RT_as_rtmat(edge: Edge, t: int) →

TODO

RT_API.get_translation(id: int, to: int, timestamp: int) →

TODO

Signals

When the DSR graph is altered, a signal is fired. Handler functions can be connected to these signals so they are called when they are fired. The following signals are exposed through this API:

signals.UPDATE_NODE

Handler signature: int, str → None

signals.UPDATE_NODE_ATTR

Handler signature: int, [str] → None

signals.UPDATE_EDGE

Handler signature: int, int, str → None

signals.UPDATE_EDGE_ATTR

Handler signature: int, int, [str] → None

signals.DELETE_EDGE

Handler signature: int, int, str → None

An edge has been deleted.

signals.DELETE_NODE

Handler signature: [int] → None

A node has been deleted.