newton.eval_mimic#
- newton.eval_mimic(model, state_in, state_out=None, *, mask=None, indices=None)[source]#
Update follower joint coordinates from their reference joints.
For each follower, this function reads every position and velocity coordinate of the reference joint, then writes the matching follower coordinates according to
Model.joint_mimic_coeffs. Independent joints are left unchanged. OnlyState.joint_qandState.joint_qdare written.If
state_outis omitted,state_inis updated in place. Otherwise, independent joint coordinates are copied fromstate_intostate_outand follower coordinates are evaluated fromstate_in.Like
eval_fk()andeval_ik(),maskorindicesselects articulations, not worlds or joints. Only the selected articulations are copied and updated; unselected coordinates instate_outretain their existing values. With neither selector, all joints are processed.Solvers with mimic support enforce the relationship during
step(); this helper is not a required post-step call. Whetherstep()refreshes joint coordinates instate_outis solver-defined. If a solver advances body coordinates without refreshing joint coordinates, useeval_ik()to derive current joint values from the output body state; calling this function on stale joint arrays would use stale reference values. Call this helper beforeeval_fk()when initializing body poses from joint values that need mimic projection.- Parameters:
model (Model) – Model containing the joint mimic metadata.
state_in (State) – State providing the input joint coordinates.
state_out (State | None) – State receiving the updated joint coordinates. If
None, updatestate_inin place.mask (wp.array[bool] | None) – Boolean mask of shape
(model.articulation_count,)on the model device.Trueselects an articulation. Mutually exclusive withindices.indices (wp.array[int] | None) – One-dimensional array of unique integer articulation indices on the model device. Out-of-range indices are skipped, matching
eval_fk()andeval_ik(). An empty array updates nothing. Mutually exclusive withmask.
- Raises:
ValueError – If either state does not contain joint coordinate arrays, both selectors are provided, or a selector has an incompatible shape, dtype, or device.