Skip to content

tesseract_robotics.tesseract_state_solver

Forward kinematics of a whole scene graph: joint values in, SceneState (joint values and every link and joint transform) out. OFKTStateSolver is the mutable solver an Environment uses; KDLStateSolver is built on a KDL tree. Both take the SceneGraph in their constructor.

Python
import numpy as np
from tesseract_robotics.tesseract_state_solver import OFKTStateSolver

solver = OFKTStateSolver(scene_graph)
names = solver.getActiveJointNames()

solver.setState(np.zeros(len(names)))           # every active joint, in getActiveJointNames() order
solver.setState({names[0]: 0.3})                # by name
solver.setState(names[:1], np.array([0.3]))     # names and values
state = solver.getState()                       # current SceneState
probe = solver.getState({names[0]: 0.5})        # a state for other values; the solver is unchanged
jac = solver.getJacobian({names[0]: 0.5}, "tool0")
transforms = solver.getLinkTransforms(names, np.zeros(len(names)))  # dict[str, Isometry3d]

Overloads and validation

setState, getState and getJacobian take the joint values as a vector over the active joints, a dict by name, or names plus values, each with an optional floating_joint_values (dict[str, Isometry3d]). setState(floating_joint_values) and getState(floating_joint_values) set only floating joints. A dict of floats selects the joint-value form and a dict of Isometry3d the floating form; an empty {} is the joint-value form.

Every overload checks its input before calling the solver and raises ValueError for a joint name that is not an active joint, a floating name that is not a floating joint, names and values of different lengths, or a vector whose length is not the number of active joints. An unknown link in getJacobian raises KeyError. Upstream OFKTStateSolver dereferences a null node for an unknown joint name (the GH #43 crash), so this validation is what keeps the process alive.

setStateByMap and setStateByNamesAndValues are Python-only aliases of setState, bound to the same functions, so they validate the same way.

Note

KDLStateSolver ignores floating_joint_values, and setState(floating_joint_values) / getState(floating_joint_values) raise RuntimeError (upstream: "not supported").

SceneState

joints is a dict[str, float]; floating_joints, link_transforms and joint_transforms are dict[str, Isometry3d]. Each transform map is a copy on read and is assigned as a whole, so state.link_transforms["tool0"] = tf changes nothing.

Python
solver.setState({"joint_f": Isometry3d.Identity()})
state = solver.getState()
state.floating_joints                         # {"joint_f": Isometry3d}
state.getFloatingJointValues(["joint_f"])     # KeyError for a name that is not a floating joint
state.getJointValues(names)                   # NDArray, in the given order
state == solver.getState()                    # True

== and != are upstream's comparison: exact joint values, and every transform within isApprox(1e-5), Eigen's relative test on the 4×4 matrix. SceneState is mutable and unhashable.

Inserting a scene graph

MutableStateSolver.insertSceneGraph(scene_graph, joint, prefix="") attaches another graph with joint, whose parent is a link of the solver and whose child is the inserted graph's root (with prefix already applied). It returns False, as upstream, when a link is missing or the joint name exists.

tesseract_robotics.tesseract_state_solver

tesseract_state_solver Python bindings (nanobind)

__all__ module-attribute

Python
__all__ = ['SceneState', 'StateSolver', 'MutableStateSolver', 'KDLStateSolver', 'OFKTStateSolver']

SceneState

joints property writable
Python
joints: dict[str, float]
floating_joints property writable
Python
floating_joints: dict[str, Isometry3d]
Python
link_transforms: dict[str, Isometry3d]
joint_transforms property writable
Python
joint_transforms: dict[str, Isometry3d]
__hash__ class-attribute instance-attribute
Python
__hash__: None = None
__init__
Python
__init__() -> None
getJointValues
Python
getJointValues(joint_names: Sequence[str]) -> Annotated[NDArray[numpy.float64], dict(shape=(None,), order=C)]
getFloatingJointValues
Python
getFloatingJointValues(joint_names: Sequence[str]) -> dict[str, tesseract_robotics.tesseract_common._tesseract_common.Isometry3d]
__eq__
Python
__eq__(arg: SceneState) -> bool
__ne__
Python
__ne__(arg: SceneState) -> bool

StateSolver

setStateByMap
Python
setStateByMap(joint_values: Mapping[str, float], floating_joint_values: Mapping[str, Isometry3d] = {}) -> None
setStateByNamesAndValues
Python
setStateByNamesAndValues(joint_names: Sequence[str], joint_values: Annotated[NDArray[float64], dict(shape=(None,), writable=False)] | Sequence[float], floating_joint_values: Mapping[str, Isometry3d] = {}) -> None
getRandomState
Python
getRandomState() -> SceneState
getJointNames
Python
getJointNames() -> list[str]
getFloatingJointNames
Python
getFloatingJointNames() -> list[str]
getActiveJointNames
Python
getActiveJointNames() -> list[str]
getBaseLinkName
Python
getBaseLinkName() -> str
getLinkNames
Python
getLinkNames() -> list[str]
getActiveLinkNames
Python
getActiveLinkNames() -> list[str]
getStaticLinkNames
Python
getStaticLinkNames() -> list[str]
isActiveLinkName
Python
isActiveLinkName(link_name: str) -> bool
hasLinkName
Python
hasLinkName(link_name: str) -> bool
getLinkTransform
Python
getLinkTransform(link_name: str) -> tesseract_robotics.tesseract_common._tesseract_common.Isometry3d
getRelativeLinkTransform
Python
getRelativeLinkTransform(from_link_name: str, to_link_name: str) -> tesseract_robotics.tesseract_common._tesseract_common.Isometry3d
getLimits
Python
getLimits() -> tesseract_robotics.tesseract_common._tesseract_common.KinematicLimits
clone
Python
clone() -> StateSolver

MutableStateSolver

Bases: StateSolver

setRevision
Python
setRevision(revision: int) -> None
getRevision
Python
getRevision() -> int
Python
addLink(link: Link, joint: Joint) -> bool
Python
moveLink(joint: Joint) -> bool
Python
removeLink(name: str) -> bool
replaceJoint
Python
replaceJoint(joint: Joint) -> bool
removeJoint
Python
removeJoint(name: str) -> bool
moveJoint
Python
moveJoint(name: str, parent_link: str) -> bool
changeJointOrigin
Python
changeJointOrigin(name: str, new_origin: Isometry3d) -> bool
changeJointPositionLimits
Python
changeJointPositionLimits(name: str, lower: float, upper: float) -> bool
changeJointVelocityLimits
Python
changeJointVelocityLimits(name: str, limit: float) -> bool
changeJointAccelerationLimits
Python
changeJointAccelerationLimits(name: str, limit: float) -> bool
changeJointJerkLimits
Python
changeJointJerkLimits(name: str, limit: float) -> bool
insertSceneGraph
Python
insertSceneGraph(scene_graph: SceneGraph, joint: Joint, prefix: str = '') -> bool

KDLStateSolver

Bases: StateSolver

State solver on a KDL tree. Floating joint values are ignored, and setState / getState with only floating_joint_values raise RuntimeError (upstream: not supported).

__init__
Python
__init__(scene_graph: SceneGraph) -> None
clone
Python
clone() -> StateSolver

OFKTStateSolver

Bases: MutableStateSolver

clone
Python
clone() -> StateSolver