pythonUtils
- pythonUtils.visualize(time: ndarray, qpos: ndarray, modelFileOrScene: str | MJScene, speedUp: float = 1, track: str = '', files: List[str] = [])[source]
Calls a tool to visualize the movement of multi-body systems simulated through
MJScene.To be able to use this function, one must have built Basilisk with the flag: ‘–mujocoReplay True’.
The arguments
timeandqposare typically the product of anMJScenestate recorder:scene: MJScene = ... stateRecorder = scene.stateOutMsg.recorder() scSim.AddModelToTask("myTask", stateRecorder) # Run simulation mujoco.visualize( stateRecorder.times(), np.squeeze(stateRecorder.qpos), scene, ... )
- Parameters:
time (np.ndarray) – A one-dimensional array with the times at which the scene positions are recorded (in seconds)
qpos (np.ndarray) – A two-dimensional array with the position of the multi-body in general coordinates. The length of the first dimension must match the length of the
timeargument.modelFileOrScene (Union[str, MJScene]) – Path to a file describing the MuJoCo model (can be XML or compiled
.mjb). Alternatively, this can be anMJSceneobject, from which a model file will generated.speedUp (float, optional) – Factor with which to speed up simulation replay. =1 is real time, =2 is double speed, =0.2 is five times slower, etc.. Defaults to 1.
track (str, optional) – Name of the body to track during visualization, by default, the first free body in the simulation. If ‘none’, camera is moved freely by the user. Defaults to “”.
files (List[str], optional) – Paths to extra files to expose to MuJoCo, for example to load meshes. Defaults to [].