curobo.servo module¶
Joint-space servo utilities.
- class JointTargetServo(
- joint_limits,
- servo_dt_s=0.02,
- kp=8.0,
- kd=0.1,
Bases:
objectSmooth a joint-space target into limit-respecting fixed-rate commands.
This class is for a servo loop that tracks one current
curobo._src.state.state_joint.JointStatetarget. It is not a trajectory queue and does not use timestamps. Callset_targetwhenever a new target arrives, then callstepwith the measured robot state once per fixed control tick to generate the next command.All command, target, and measured states must use the same
joint_namesand tensor shape(batch, dof).batchis the number of independent command streams, anddofis the number of active joints injoint_limits.set_targetonly stores a target. The command state is initialized either byresetor by the firststep, which starts from the measured state.- Parameters:
Store active-joint limits and fixed-rate servo gains.
- Parameters:
- Raises:
ValueError – If
servo_dt_sor any symmetric motion limit is invalid.
- __init__(
- joint_limits,
- servo_dt_s=0.02,
- kp=8.0,
- kd=0.1,
Store active-joint limits and fixed-rate servo gains.
- Parameters:
joint_limits (curobo._src.robot.types.joint_limits.JointLimits) – Active-joint
JointLimitswith limit tensors of shape(2, dof).servo_dt_s (float) – Fixed servo tick duration in seconds.
kp (float) – Proportional gain applied to position error.
kd (float) – Damping gain applied to measured velocity.
- Raises:
ValueError – If
servo_dt_sor any symmetric motion limit is invalid.- Return type:
None
- property batch_size: int¶
Return the number of independent command streams.
- Returns:
Batch dimension of the initialized command state.
- Raises:
ValueError – If no command state has been initialized.
- reset(command_state)¶
Replace command state with a known joint position and optional velocity.
Use this when starting the servo from the robot’s current state, or after a discontinuity where the previous command state should no longer influence acceleration and jerk limits. The reset state also becomes the current target, so a following
stepholds that state untilset_targetis called.- Parameters:
command_state (curobo._src.state.state_joint.JointState) – Command state with position shape
(batch, dof)and joint names matchingjoint_limits. When velocity is omitted, command velocity is initialized to zero.- Raises:
TypeError – If
command_stateis not aJointStateor contains non-tensor fields.ValueError – If joint names, shape, dtype, device, or finite-value checks fail.
- Return type:
None
- set_target(
- target_state,
Replace the current target used by future
stepcalls.The servo stores only this target; it does not queue previous targets or initialize command state from the target.
- Parameters:
target_state (curobo._src.state.state_joint.JointState) – Target state with position shape
(batch, dof)and joint names matchingjoint_limits. When velocity is omitted, the servo treats the target as a position-only target and applies a stopping limit.- Raises:
TypeError – If
target_stateis not aJointStateor contains non-tensor fields.ValueError – If joint names, shape, dtype, device, or finite-value checks fail.
- Return type:
None
- command_state()¶
Return a copy of the current command state.
- Returns:
JointStatewith position, velocity, acceleration, and jerk tensors of shape(batch, dof)and active joint names fromjoint_limits.- Raises:
ValueError – If no command state has been initialized.
- Return type:
- step(measured_state)¶
Generate the next command for one fixed servo tick.
The method assumes it is called at a fixed rate matching
servo_dt_s. It applies a position feedback term from measured position, optional target velocity, and position/velocity/acceleration/jerk limits before updating the internal command state.- Parameters:
measured_state (curobo._src.state.state_joint.JointState) – Measured state with position and velocity tensors of shape
(batch, dof)and joint names matchingjoint_limits.- Returns:
New
JointStatecommand after applying all joint-space limits.- Raises:
TypeError – If
measured_stateis not aJointStateor contains non-tensor fields.ValueError – If no target has been set, measured velocity is missing, or joint names, shape, dtype, device, or finite-value checks fail.
- Return type: