tesseract_robotics.tesseract_scene_graph¶
Scene graph elements: links, joints, and kinematic tree.
SceneGraph¶
The kinematic tree structure.
from tesseract_robotics.tesseract_scene_graph import SceneGraph
graph = SceneGraph()
graph.setName("my_robot")
# Add elements
graph.addLink(link)
graph.addJoint(joint)
# Query structure
links = graph.getLinks()
joints = graph.getJoints()
root = graph.getRoot()
# Find elements
link = graph.getLink("base_link")
joint = graph.getJoint("joint_1")
# Kinematic queries
child_links = graph.getLinkChildrenNames("base_link")
moved_links = graph.getJointChildrenNames("joint_1") # links below joint_1
moved_links = graph.getJointChildrenNames(["joint_1", "joint_2"]) # union, sorted, no duplicates
path = graph.getShortestPath("base_link", "tool0")
root = graph.getRoot()
# Which listed link each link moves with: a listed link maps itself and every link
# below it, stopping at another listed link; an unknown name raises KeyError
graph.getAdjacencyMap(["link_2", "link_4"]) # {"link_2": "link_2", "link_3": "link_2", "link_4": "link_4", ...}
Allowed collision matrix¶
getAllowedCollisionMatrix() returns the graph's own matrix, and setAllowedCollisionMatrix(acm)
makes the graph keep acm itself, so later edits to acm show up in isCollisionAllowed.
setAllowedCollisionMatrix(None) raises TypeError and leaves the matrix in place: upstream would
store a null pointer that the next ACM call dereferences.
from tesseract_robotics.tesseract_common import AllowedCollisionMatrix
acm = AllowedCollisionMatrix()
acm.addAllowedCollision("link_1", "link_2", "adjacent")
graph.setAllowedCollisionMatrix(acm)
graph.isCollisionAllowed("link_1", "link_2") # True
Link¶
A rigid body in the kinematic tree.
from tesseract_robotics.tesseract_scene_graph import Link, Visual, Collision
from tesseract_robotics.tesseract_geometry import Box
from tesseract_robotics.tesseract_common import Isometry3d
# Create link
link = Link("my_link")
# Add visual geometry
visual = Visual()
visual.geometry = Box(0.1, 0.1, 0.1)
visual.origin = Isometry3d.Identity()
link.addVisual(visual) # Note: use addVisual(), not visual.append()
# Add collision geometry
collision = Collision()
collision.geometry = Box(0.1, 0.1, 0.1)
collision.origin = Isometry3d.Identity()
link.addCollision(collision)
# Access geometries
visuals = link.visual # list[Visual]
collisions = link.collision # list[Collision]
# Clear geometries
link.clearVisual()
link.clearCollision()
# Hide the link, or take it out of collision checking (both True by default)
link.visible = False
link.collision_enabled = False
clone() copies visible and collision_enabled, and == compares them. Link stays
unhashable: getHash() hashes only the name, while == compares more.
Visual¶
Visual representation of a link.
from tesseract_robotics.tesseract_scene_graph import Visual, Material
visual = Visual()
visual.name = "visual_0"
visual.geometry = geometry
visual.origin = transform
# Material (optional)
material = Material()
material.name = "red"
material.color = np.array([1.0, 0.0, 0.0, 1.0]) # RGBA
visual.material = material
Collision¶
Collision geometry of a link.
from tesseract_robotics.tesseract_scene_graph import Collision
collision = Collision()
collision.name = "collision_0"
collision.geometry = geometry
collision.origin = transform
Joint¶
Connection between two links.
from tesseract_robotics.tesseract_scene_graph import Joint, JointType
joint = Joint("joint_1")
joint.type = JointType.REVOLUTE
joint.parent_link_name = "link_0"
joint.child_link_name = "link_1"
joint.parent_to_joint_origin_transform = Isometry3d.Identity()
joint.axis = np.array([0, 0, 1]) # rotation axis
JointType¶
| Type | Description |
|---|---|
REVOLUTE |
Rotational with limits |
CONTINUOUS |
Rotational, no limits |
PRISMATIC |
Linear sliding |
FIXED |
No motion |
FLOATING |
6-DOF free motion |
PLANAR |
2D motion in a plane |
str() of a joint type is upstream's operator<<, so str(JointType.REVOLUTE) is "Revolute"
("Unknown" for UNKNOWN). .name ("REVOLUTE") and repr() ("JointType.REVOLUTE") are
unchanged.
Printing joint values and paths¶
JointDynamics, JointLimits, JointSafety, JointCalibration, JointMimic and ShortestPath
print with upstream's operator<<; the shorter repr() of JointDynamics and JointLimits stays.
from tesseract_robotics.tesseract_scene_graph import JointLimits
print(JointLimits(-1, 1, 10, 2, 3, 4))
# lower=-1 upper=1 effort=10 velocity=2 acceleration=3 jerk=4
print(graph.getShortestPath("base_link", "tool0"))
# Links:
# base_link
# ...
# Joints:
# ...
# Active Joints:
# ...
JointLimits¶
from tesseract_robotics.tesseract_scene_graph import JointLimits
limits = JointLimits()
limits.lower = -3.14
limits.upper = 3.14
limits.velocity = 2.0
limits.acceleration = 5.0
limits.effort = 100.0
joint.limits = limits
JointDynamics¶
from tesseract_robotics.tesseract_scene_graph import JointDynamics
dynamics = JointDynamics()
dynamics.damping = 0.1
dynamics.friction = 0.05
joint.dynamics = dynamics
JointMimic¶
from tesseract_robotics.tesseract_scene_graph import JointMimic
mimic = JointMimic()
mimic.joint_name = "joint_1" # joint to mimic
mimic.multiplier = 1.0
mimic.offset = 0.0
joint.mimic = mimic
Inertial¶
Mass and inertia properties.
from tesseract_robotics.tesseract_scene_graph import Inertial
inertial = Inertial()
inertial.origin = Isometry3d.Identity()
inertial.mass = 1.0
inertial.ixx = 0.01
inertial.iyy = 0.01
inertial.izz = 0.01
inertial.ixy = 0.0
inertial.ixz = 0.0
inertial.iyz = 0.0
link.inertial = inertial
SceneState¶
Current state of the scene graph. The class is bound in tesseract_state_solver;
tesseract_scene_graph.SceneState is the same object, imported on first access (the
state-solver extension imports this module's extension, so an eager re-export would be an
import cycle).
from tesseract_robotics.tesseract_scene_graph import SceneState
state = env.getState()
# Joint positions
positions = state.joints # dict[str, float]
# Link transforms
transforms = state.link_transforms # dict[str, Isometry3d]
tcp_pose = transforms["tool0"]
floating_joints, getFloatingJointValues and == are described with the state solver:
SceneState.
Auto-generated API Reference¶
tesseract_scene_graph Python bindings
JointType
¶
Bases: Enum
JointDynamics
¶
JointLimits
¶
JointSafety
¶
JointCalibration
¶
JointMimic
¶
Material
¶
Inertial
¶
Visual
¶
Collision
¶
Link
¶
collision_enabled
property
writable
¶
Whether the link takes part in collision checking (link.h:213)
ShortestPath
¶
SceneGraph
¶
changeJointPositionLimits
¶
changeJointAccelerationLimits
¶
addAllowedCollision
¶
getAllowedCollisionMatrix
¶
getAllowedCollisionMatrix() -> tesseract_robotics.tesseract_common._tesseract_common.AllowedCollisionMatrix
Get the allowed collision matrix
setAllowedCollisionMatrix
¶
Replace the allowed collision matrix. The graph keeps this object: later edits to acm are edits to the graph's matrix, as with getAllowedCollisionMatrix.
getAdjacencyMap
¶
Map each link that moves with one of link_names to that link name (graph.h:486). Each listed link maps itself and every link below it, stopping at another listed link. An unknown name raises KeyError.