API

Core Modules

Player

Recorder

MuJoCo Loader

MuJoCo Model Loader and Viewer

This script provides functionality to load and visualize MuJoCo physics simulation models. It supports both active and passive viewing modes: - Active viewer: Runs independently in a separate thread - Passive viewer: Requires manual synchronization

Usage:

python -m mujoco_tools.mujoco_loader –model path/to/model.xml [–active_viewer|–passive_viewer]

param –model:

Path to the MuJoCo XML model file

param –passive_viewer:

Enable passive viewer mode

param –active_viewer:

Enable active viewer mode

Data Processor

Tools

mujoco_tools.tools.load_model_from_path(model_path)[source]

Load a MuJoCo model from a path and initialize its data.

Parameters:

model_path (str) – Path to the MuJoCo XML model file

Returns:

Model and data objects

Return type:

Tuple[mujoco.MjModel, mujoco.MjData]

mujoco_tools.tools.get_joint_qpos(model, data, joint_name)[source]

Get joint position(s) by joint name.

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

  • joint_name (str) – Name of the joint

Returns:

Joint position(s)

Return type:

np.ndarray

mujoco_tools.tools.set_joint_qpos(model, data, joint_name, value)[source]

Set joint position(s) by joint name.

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

  • joint_name (str) – Name of the joint

  • value (ndarray) – Position value(s) to set

mujoco_tools.tools.get_body_pose(model, data, body_name)[source]

Get body position and orientation (quaternion).

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

  • body_name (str) – Name of the body

Returns:

Position (xyz) and orientation (quaternion)

Return type:

Tuple[np.ndarray, np.ndarray]

mujoco_tools.tools.apply_force_to_body(model, data, body_name, force, point=None)[source]

Apply force to a body at specified point (or center of mass if not specified).

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

  • body_name (str) – Name of the body

  • force (ndarray) – Force vector [fx, fy, fz]

  • point (ndarray | None) – Point of application in world coordinates (optional)

mujoco_tools.tools.get_sensor_data(model, data, sensor_name)[source]

Get sensor reading by name.

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

  • sensor_name (str) – Name of the sensor

Returns:

Sensor reading

Return type:

np.ndarray

mujoco_tools.tools.reset_simulation(model, data)[source]

Reset simulation to initial state.

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

mujoco_tools.tools.forward_kinematics(model, data)[source]

Compute forward kinematics.

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

mujoco_tools.tools.get_jacobian(model, data, body_name)[source]

Get body Jacobian (translational and rotational).

Parameters:
  • model (MjModel) – MuJoCo model

  • data (MjData) – MuJoCo data

  • body_name (str) – Name of the body

Returns:

Translational and rotational Jacobians

Return type:

Tuple[np.ndarray, np.ndarray]

Command Line Interface

Command-line interface for MuJoCo tools

mujoco_tools.cli.parse_data_arg(data_str)[source]

Parse data argument string into a dictionary Example: “qpos data/qpos.npy ctrl data/ctrl.npy” -> {“qpos”: “data/qpos.npy”, “ctrl”: “data/ctrl.npy”}

Parameters:

data_str (str) –

Return type:

Dict[str, str]

mujoco_tools.cli.parse_vision_flags(flags_str)[source]

Parse vision flags string into a dictionary Example: “mjVIS_ACTUATOR mjVIS_ACTIVATION” -> {“mjVIS_ACTUATOR”: True, “mjVIS_ACTIVATION”: True}

Parameters:

flags_str (str) –

Return type:

Dict[str, bool]