LyceumMuJoCoViz is an OpenGL-based interactive visualizer for MuJoCo-based models and environments. It allows for visualizing passive dynamics, playing back recorded trajectories, and interacting with a policy or controller in real time. Several additional features are provided:

  • Interact with the simulation using the mouse and keyboard.
  • "Burst mode", the ability to render multiple snapshots along an entire trajectory at once.
  • Run the simulation faster or slower than real time, or in reverse.
  • Record a high-resolution video of the rendered scene.
  • Step through time, one or several timesteps at a time.

All of these commands are controlled via keyboard shortcuts which are displayed in a help window when the visualizer is launched:


visualize(model::Union{LyceumMuJoCo.AbstractMuJoCoEnvironment, MJSim}; trajectories, controller)

Starts an interactive visualization of model, which can be either a valid subtype of AbstractMuJoCoEnvironment or just a MJSim simulation. The visualizer has several "modes" that allow you to visualize passive dynamics, play back recorded trajectories, and run a controller interactively. The passive dynamics mode depends only on model and is always available, while the other modes are specified by the keyword arguments below.

For more information, see the on-screen help menu.


  • trajectories::AbstractVector{<:AbstractMatrix}: a vector of trajectories, where each trajectory is an AbstractMatrix of states with size (length(statespace(model)), T) and T is the length of the trajectory. Note that each trajectory can have different length.
  • controller: a callback function with the signature controller(model), called at each timestep, that that applys a control input to the system.


using LyceumMuJoCo, LyceumMuJoCoViz
env = LyceumMuJoCo.HopperV2()
T = 100
states = Array(undef, statespace(env), T)
for t = 1:T
    states[:, t] .= getstate(env)
    controller = env -> setaction!(env, rand(actionspace(env)))