newton.eval_mass_matrix#
- newton.eval_mass_matrix(model, state, H=None, J=None, body_I_s=None, joint_S_s=None, mask=None)[source]#
Evaluate generalized mass matrix for articulations.
Computes the generalized mass matrix H = J^T * M * J, where J is the spatial Jacobian and M is the block-diagonal spatial mass matrix. The mass matrix relates joint accelerations to joint forces/torques.
- Parameters:
model (Model) – The model containing articulation definitions.
state (State) – The state containing body transforms (body_q).
H (array | None) – Optional output array for mass matrix, shape (articulation_count, max_dofs, max_dofs). If None, allocates internally.
J (array | None) – Optional pre-computed Jacobian. If None, computes internally. Shape (articulation_count, max_links*6, max_dofs).
body_I_s (array | None) – Optional pre-allocated temp array for spatial inertias, shape (body_count,), dtype wp.spatial_matrix. If None, allocates internally.
joint_S_s (array | None) – Optional pre-allocated temp array for motion subspaces (only used if J is None), shape (joint_dof_count,), dtype wp.spatial_vector. If None, allocates internally.
mask (array | None) – Optional boolean mask to select which articulations to compute. Shape [articulation_count]. If None, computes for all articulations.
- Returns:
The mass matrix array H, or None if the model has no articulations.
- Return type:
array | None