integrations
Adapters for MuJoCo MJX dynamics in OpenSCvx BYOF.
The recommended entry-point is :func:mjx_byof, which returns a complete
byof["dynamics"] dict and automatically handles free-joint quaternion
kinematics for floating-base models (drones, humanoids, etc.):
from openscvx.integrations import mjx_byof
byof = {"dynamics": mjx_byof(mjx_model, qpos=qpos, qvel=qvel, ctrl=ctrl)}
For models without free joints (cartpoles, manipulators) the returned dict
contains only "qvel" and dynamics={"qpos": qvel} should still be
provided to :class:~openscvx.Problem. For models with free joints
(nq > nv) "qpos" is included automatically — no extra imports needed.
:func:mjx_dynamics is also available for advanced users who need direct
access to the BYOF callable for the qvel (acceleration) derivative.
All symbols delegate lazily so mujoco.mjx is only imported when used.
The :mod:menagerie submodule is loaded lazily via attribute access.
Example — cartpole (nq == nv)::
from openscvx.integrations import mjx_byof
byof = {"dynamics": mjx_byof(mjx_model, qpos=qpos, qvel=qvel, ctrl=ctrl)}
problem = ox.Problem(dynamics={"qpos": qvel}, byof=byof, ...)
Example — quadrotor with free joint (nq=7, nv=6)::
from openscvx.integrations import mjx_byof
byof = {"dynamics": mjx_byof(mjx_model, qpos=qpos, qvel=qvel, ctrl=ctrl)}
problem = ox.Problem(dynamics={}, byof=byof, ...)