set_joints
Signature:
BoosterRobot.set_joints(joint_commands: list[JointCommand]) -> None
Description:
Send batch joint control commands.
Parameters:
Parameter | Type | Default | Description |
|---|---|---|---|
|
| Required | List of joint control commands; joints are matched by |
JointCommand represents the control target and control parameters for a single joint, containing at minimum the joint name name and target position position; for position control it is recommended to explicitly set kp and kd. See "Joint-Related Data / JointCommand" for complete fields.
Returns:
None
Raises:
ValueError: The set of joint names does not equal all joints, nor does it equal the first 10 upper body joints.
RuntimeError: Joint control command failed to send.
Example:
import time
from boosteros.robots.booster import BoosterRobot
from boosteros.types import JointCommand
robot = BoosterRobot()
# K1 full-body joint example gains; T1 will insert a set of gains at the waist position.
kp_values = [
40.0, 40.0, # neck
20.0, 30.0, 10.0, 10.0, # left arm
20.0, 30.0, 10.0, 10.0, # right arm
250.0, 250.0, 150.0, 250.0, 120.0, 120.0, # left leg
250.0, 250.0, 150.0, 250.0, 120.0, 120.0, # right leg
]
kd_values = [
2.0, 2.0, # neck
1.5, 2.0, 0.5, 0.5, # left arm
1.5, 2.0, 0.5, 0.5, # right arm
15.0, 15.0, 8.0, 12.0, 8.0, 8.0, # left leg
15.0, 15.0, 8.0, 12.0, 8.0, 8.0, # right leg
]
try:
# First enter prepare and wait for posture to stabilize, then take over custom control using current posture.
robot.set_mode("prepare")
time.sleep(2.0)
joint_names = [joint.name for joint in robot.list_joints()]
if len(joint_names) == 23: # T1 waist joint
kp_values.insert(10, 100.0)
kd_values.insert(10, 8.0)
if len(joint_names) != len(kp_values):
raise RuntimeError(f"Unsupported joint count: {len(joint_names)}")
states = robot.get_joint_states()
state_map = {state.name: state.position for state in states.joints}
commands = []
for i, name in enumerate(joint_names):
position = state_map.get(name)
if position is None:
raise RuntimeError(f"Joint state is not ready: {name}")
commands.append(
JointCommand(
name=name,
position=position,
kp=kp_values[i],
kd=kd_values[i],
)
)
robot.set_mode("custom")
robot.set_joints(commands)
time.sleep(2.0)
finally:
robot.set_mode("prepare")