Skip to main content

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

header

Header

Joint state metadata header

Read-only attributes:

Property

Type

Description

joints

list[JointState]

List of joint states

timestamp

float

Timestamp in seconds, equivalent to header.timestamp

names

list[str]

All joint names, computed from joints

JointStates​

Signature:

JointStates(
joints: list[JointState] | Mapping[str, JointState],
header: Header | None = None,
)

Description:

Constructs a JointStates instance.

Parameters:

Parameter

Type

Required

Description

joints

list[JointState] | Mapping[str, JointState]

Yes

A frame of joint states; when passing a Mapping, values are converted to a list, keys are ignored

header

Header | None

No

Joint state metadata header; when not provided or None, a default Header is used

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

name

str

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 ...]