MuJoCo
Ver. 1.2.8 (2024-04-10)
This module wraps bf.Systems with MuJoCo Simulation functionality.
- class mlpro.wrappers.mujoco.CallbacksViewer
Bases:
object
All callbacks function for the viewer
- _key_callback(window, key, scancode, action, mods)
- _scroll_callback(window, x_offset, y_offset)
- _cursor_pos_callback(window, xpos, ypos)
- _mouse_button_callback(window, button, act, mods)
- class mlpro.wrappers.mujoco.BaseViewer(model, data, width, height)
Bases:
object
- _init_camera(xyz_pos=None, elevation=None, distance=None)
- add_overlay(gridpos: int, text1: str, text2: str)
- _set_mujoco_buffer()
- _make_context_current()
- close()
- class mlpro.wrappers.mujoco.OffRenderViewer(model, data, xyz_pos=None, elevation=None, distance=None)
Bases:
BaseViewer
- _set_mujoco_buffer()
- _make_context_current()
- _get_opengl_backend(width: int, height: int)
- render()
- close()
- free()
- class mlpro.wrappers.mujoco.RenderViewer(model, data, xyz_pos=None, elevation=None, distance=None)
Bases:
BaseViewer
,CallbacksViewer
- _create_overlays()
Should be user customizeable
- _set_mujoco_buffer()
- _make_context_current()
- render()
- close()
- free()
- class mlpro.wrappers.mujoco.MujocoHandler(p_mujoco_file, p_frame_skip, p_state_mapping=None, p_action_mapping=None, p_camera_conf=(None, None, None), p_visualize=False, p_logging=True)
Bases:
Wrapper
Module provides the functionality of MuJoCo.
- Parameters:
p_mujoco_file (str) – String path points the MuJoCo file.
p_frame_skip (int) – Frame skips for each simulation step.
p_state_mapping (list) – State mapping for customized state. Defaults to None.
p_action_mapping (list) – Action mapping for customized action. Defaults to None.
p_camera_conf (tuple) – Camera configuration (xyz position, elevation, distance). Defaults to (None, None, None).
p_visualize (bool) – Visualize the MuJoCo Simulation. Defaults to False.
p_logging (bool) – Logging. Defaults to Log.C_LOG_ALL.
- C_NAME = 'MuJoCo'
- C_TYPE = 'Wrapper MuJoCo -> MLPro'
- C_WRAPPED_PACKAGE = 'mujoco'
- C_MINIMUM_VERSION = '2.3.1'
- setup_spaces()
Setup state and action spaces.
- get_init_qpos_space()
Get Initial State Space
- get_init_qvel_space()
Get Initial State Space
- _get_state_space()
Generate the state space based on MJCF file.
- Returns:
State Space
- Return type:
- _get_action_space()
Generate the action space based on MJCF file.
- Returns:
Action Space
- Return type:
- _get_obs()
Get the current observation of MuJoCo Simulation.
- Returns:
List of state values.
- Return type:
list
- _reset_model(reset_state=None)
Reset the model simulation. If resete_state is None, then the default state from MuJoCo will be taken for the intial value. Otherwise, a customized state can be defined in _reset() function.
- Parameters:
reset_state (list) – qpos data and qvel data. Defaults to None.
- Returns:
List of state values
- Return type:
list
- _set_state(*args)
Set the current state of MuJoCo Simulation.
- _initialize_simulation()
Initialize Simulation.
- _setup_camera(camera_name)
Setup MuJoCo Camera Object.
- Parameters:
camera_name (str) – Camera name in MJCF file.
- Returns:
MuJoCo Camera Object.
- Return type:
mujoco.MjvCamera
- _get_camera_data(cam)
Get camera data from MuJoCo camera.
- Parameters:
cam (mujoco.MjvCamera) – MuJoCo Camera Object.
- Returns:
RGB Image or Depth Image.
- Return type:
ndarray
- _get_viewer()
Get the MuJoCo viewer.
- Returns:
MuJoCo Viewer
- Return type:
- _reset_simulation(reset_state=None)
Reset the simulation. If resete_state is None, then the default state from MuJoCo will be taken for the intial value. Otherwise, a customized state can be defined in _reset() function.
- Parameters:
reset_state (list) – qpos data and qvel data. Defaults to None.
- Returns:
List of state values
- Return type:
list
- _step_simulation(p_action: Action)
Pass the action to the simulation.
- Parameters:
p_action (Action) – Action
- render()
Render the MuJoCo Viewer.
- get_latency()
Get latency from MJCF file.
- Returns:
None or Timestep
- Return type:
float
- _close()
Close MuJoCo Viewer
Cross References