IK is provided by the useIkController() hook — it is not part of the core MujocoSimAPI. The hook returns an IkContextValue that you pass to <IkGizmo> or use directly.
ik?.setIkEnabled(true); // IK writes to ctrl each frameik?.setIkEnabled(false); // IK disabled — you control ctrl
When IK is enabled, it overwrites data.ctrl for the arm joints inside useBeforePhysicsStep. Disable IK when running your own control (policies, teleoperation, etc.).
const ik = useIkController({ siteName: ModelSites.franka.tcp });
The controller finds the site body and infers scalar hinge/slide joints by walking toward the model root. For nonstandard MJCFs, multi-arm scenes, or actuator orders that do not match qpos order, pass explicit selectors:
jointIds are MuJoCo joint IDs. Input and output configurations contain model.nq
values, including wxyz quaternions; the THREE target uses xyzw.
The Jacobian has model.nv columns. The solver selects jnt_dofadr columns and
uses mj_integratePos for manifold-correct quaternion updates. It respects model
joint limits (ball limits bound the rotation angle), restores live qpos even on
failure, and returns the best solution for unreachable targets. It does not
perform collision avoidance. Apply the returned pose explicitly or map it to
appropriate actuator inputs; a ball quaternion is not three scalar commands.The epsilon option is deprecated and ignored. maxStepRad bounds each velocity
coordinate update; scalar slide-joint updates use model length units.