Modules¶
MuJoCo Loader¶
The MuJoCo Loader module provides utilities for loading MuJoCo models and setting up the simulation environment.
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
Player¶
The Player module provides visualization capabilities for MuJoCo simulations.
Recorder¶
The Recorder module offers tools for recording data and videos from MuJoCo simulations.
- class mujoco_tools.recorder.VideoRecorder(camera_name='lateral_camera_angle', width=1920, height=1080, fps=50, vision_flags=None, output_video_freq=50)[source]¶
Bases:
objectInitialize video recorder with rendering settings
- class mujoco_tools.recorder.StateRecorder(model, output_format='npy', datatypes=None, output_data_freq=50)[source]¶
Bases:
objectInitialize state recorder for positions and orientations
Data Processor¶
The Data Processor module provides utilities for processing and analyzing simulation data.
Tools¶
The Tools module contains various utility functions for working with MuJoCo simulations.
- 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]
CLI¶
The CLI module provides a command-line interface for using MuJoCo Tools.
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”}