newton.controllers.ControllerJointImpedance#
- class newton.controllers.ControllerJointImpedance(builder, *, default_dof_indices, stiffness, damping, use_gravity_compensation=True, use_coriolis_compensation=True, use_inertia_decoupling=True, has_qdd_feedforward=False, joint_q_idx=None, joint_qd_idx=None, joint_q_des_idx=None, joint_qd_des_idx=None, joint_qdd_idx=None, joint_f_idx=None, device=None, requires_grad=False)[source]#
Bases:
ControllerBaseOne-step joint-space impedance controller for a batch of robots.
Has an identical input/output interface to
ControllerJointImpedanceModelFree— flat 1D sim arrays in, flat 1D torque array out — except that the dynamics terms (mass matrix, gravity force, Coriolis force) are computed internally from the Newton model rather than supplied by the caller.Supports heterogeneous robot fleets — robots in the batch may have different DOF counts. The
builderarticulations define the per-robot topology; the controller pads internal buffers tomodel.max_dofs_per_articulationand skips padding slots in all kernels.Only 1-DOF joints (Revolute, Prismatic) and zero-DOF Fixed joints are supported. The PD error term
q_des - qis only valid for scalar joint coordinates.Impedance law (terms enabled at construction):
- τ = [M(q) if use_inertia_decoupling else I] · (q̈_des + Kp·Δq + Kd·Δq̇)
[C(q,q̇)·q̇ if use_coriolis_compensation else 0]
[g(q) if use_gravity_compensation else 0]
- Parameters:
builder (ModelBuilder) –
ModelBuilderwith N articulations (one per robot). Articulations may have different DOF counts.default_dof_indices (wp.array[wp.uint32]) – Concatenated per-robot index arrays of length
sum(dofs per articulation)mapping controller DOF slots to positions in the flat simulation arrays (robot 0’s indices first, then robot 1’s, etc.).stiffness (wp.array2d[wp.float32] | None) – Position-error gain Kp [N/m or N·m/rad], shape
(N, max_dofs). Pass a baked array orNoneto read frominputs.stiffnesseach step.damping (wp.array2d[wp.float32] | None) – Velocity-error gain Kd [N·s/m or N·m·s/rad]. Same format as
stiffness.use_gravity_compensation (bool) – Add gravity generalized forces to τ.
use_coriolis_compensation (bool) – Add Coriolis generalized forces to τ.
use_inertia_decoupling (bool) – Premultiply the PD term by M(q).
has_qdd_feedforward (bool) – Accept a desired-acceleration feedforward via
inputs.joint_qdd.joint_q_idx (wp.array[wp.uint32] | None) – Optional index array (same length as
default_dof_indices) overriding it for the position read.joint_qd_idx (wp.array[wp.uint32] | None) – Optional index array for velocity read.
joint_q_des_idx (wp.array[wp.uint32] | None) – Optional index array for desired position read.
joint_qd_des_idx (wp.array[wp.uint32] | None) – Optional index array for desired velocity read.
joint_qdd_idx (wp.array[wp.uint32] | None) – Optional index array for feedforward read.
joint_f_idx (wp.array[wp.uint32] | None) – Optional index array overriding
default_dof_indicesfor the torque-output write.device (Any) – Warp device.
requires_grad (bool) – Whether internal buffers need gradient support.
- class Inputs#
Bases:
objectInput struct returned by
input().Dynamics fields (mass matrix, gravity, Coriolis) are computed internally and do not appear here.
- damping: wp.array2d[wp.float32] | None#
Velocity-error gain Kd [N·s/m or N·m·s/rad], shape
(robot_count, max_dofs).Nonewhen gains are baked at construction.
- joint_q: wp.array[wp.float32]#
Current joint positions [m or rad], flat sim-level array.
- joint_q_des: wp.array[wp.float32]#
Desired joint positions [m or rad], flat sim-level array.
- joint_qd: wp.array[wp.float32]#
Current joint velocities [m/s or rad/s], flat sim-level array.
- joint_qd_des: wp.array[wp.float32]#
Desired joint velocities [m/s or rad/s], flat sim-level array.
- class Outputs#
Bases:
objectOutput struct returned by
output().- joint_f: wp.array[wp.float32]#
Joint torque command [N or N·m], flat sim-level array.
- __init__(builder, *, default_dof_indices, stiffness, damping, use_gravity_compensation=True, use_coriolis_compensation=True, use_inertia_decoupling=True, has_qdd_feedforward=False, joint_q_idx=None, joint_qd_idx=None, joint_q_des_idx=None, joint_qd_des_idx=None, joint_qdd_idx=None, joint_f_idx=None, device=None, requires_grad=False)#
- is_graphable()#
- step(*, inputs, outputs, dt)#
Run one impedance-control step.