JointStates
A frame of joint state snapshot composed of multiple JointState objects, preserving joint order and providing lookup capability by name.
Attributes:
Property | Type | Description |
|---|---|---|
|
| Joint state metadata header |
Read-only attributes:
Property | Type | Description |
|---|---|---|
|
| List of joint states |
|
| Timestamp in seconds, equivalent to |
|
| All joint names, computed from |
JointStates
Signature:
JointStates(
joints: list[JointState] | Mapping[str, JointState],
header: Header | None = None,
)
Description:
Constructs a JointStates instance.
Parameters:
Parameter | Type | Required | Description |
|---|---|---|---|
|
| Yes | A frame of joint states; when passing a |
|
| No | Joint state metadata header; when not provided or |
Returns:
JointStates instance.
Raises:
None.
get_joint
Signature:
JointStates.get_joint(name: str) -> JointState | None
Description:
Linearly searches for a joint state by name; returns None if not found.
Parameters:
Parameter | Type | Required | Description |
|---|---|---|---|
|
| Yes | Joint name |
Returns:
JointState or None.
Raises:
None.
Example:
states = robot.get_joint_states()
joint_name = states.names[0]
joint = states.get_joint(joint_name)
same_joint = states[joint_name]
for joint in states:
print(joint.name, joint.position)
# Example output: AAHead_Yaw -2.3181339201983064e-05
to_numpy
Signature:
JointStates.to_numpy() -> dict[str, Any]
Description:
Returns a name list and numpy arrays for numerical fields. Only fields where all joints have values (position / velocity / effort / acceleration / temperature) will appear in the result.
Parameters:
No parameters.
Returns:
dict[str, Any]
name:list[str], list of joint names.position/velocity/effort/acceleration/temperature:np.ndarray(dtype=np.float64), only present when all joints have a value for this field.
Raises:
None.
Example:
arrays = states.to_numpy()
print(arrays["name"])
# Example output: ['AAHead_Yaw', 'Head_Pitch', 'ALeft_Shoulder_Pitch', ...]
if "position" in arrays:
print(arrays["position"])
# Example output: [-2.31813392e-05 5.19215362e-03 3.48944142e-02 ...]