viewer

exception jiminy_py.viewer.ViewerClosedError[source]

Bases: ViewerError

Raised when a method is called in a closed viewer.

jiminy_py.viewer.sleep(dt)[source]

Function to provide cross-platform time sleep with maximum accuracy.

Warning

Use this method with cautious since it relies on busy looping principle instead of system scheduler. As a result, it wastes a lot more resources than time.sleep. However, it is the only way to ensure accurate delay on Python<3.11

Parameters:

dt (float) – Sleep duration in seconds.

Return type:

None

class jiminy_py.viewer.Viewer(robot, use_theoretical_model=False, robot_color=None, lock=None, backend=None, open_gui_if_parent=None, delete_robot_on_close=False, robot_name=None, scene_name='world', display_com=False, display_dcm=False, display_contact_frames=False, display_contact_forces=False, display_f_external=None, **kwargs)[source]

Bases: object

TODO: Write documentation.

Note

The environment variable ‘JIMINY_INTERACTIVE_DISABLE’ can be used to force disabling interactive display.

Note

The environment variable ‘JIMINY_VIEWER_DEFAULT_BACKEND’ can be used to overwrite the default backend.

Parameters:
  • robot (Model) – Jiminy.Model to display.

  • use_theoretical_model (bool) – Whether to use the theoretical rigid or extended simulation model of this robot. Note that using the extended model if possible is more efficient since update of the frames placements can be skipped as it is already synchronized with the simulation state. Optional: Actual model by default.

  • robot_color (str | Tuple[float, float, float, float] | ndarray | None) – Color of the robot. It will override the original color of the meshes if not None. It supports both RGBA codes as a list of 4 floating-point values ranging from 0.0 and 1.0, and a few named colors. Optional: Disabled by default.

  • lock (RLock | None) – Custom threading.RLock for parallel rendering. None to use the unique lock associated with the current thread. Optional: None by default.

  • backend (str | None) – Name of the rendering backend to use. It can be either ‘panda3d’, ‘panda3d-qt’, ‘meshcat’. None to keep using to one already running if any, or the default one otherwise. Note that the default is hardware and environment dependent. See viewer.default_backend method for details. Optional: None by default.

  • open_gui_if_parent (bool | None) – Open GUI if new viewer’s backend server is started. None to fallback to default. Optional: Do not open gui for ‘meshcat’ backend in interactive mode with already one display cell already opened, open gui by default in any other case if graphical server is available.

  • delete_robot_on_close (bool) – Enable automatic deletion of the robot when closing. Optional: False by default.

  • robot_name (str | None) – Unique robot name, to identify each robot. Optional: Randomly generated identifier by default.

  • scene_name (str) – Scene name. Optional: ‘world’ by default.

  • display_com (bool) – Whether to display the center of mass. Optional: Disabled by default.

  • display_dcm (bool) – Whether to display the capture point / DCM. Optional: Disabled by default.

  • display_contact_frames (bool) – Whether to display the contact frames. Optional: Disabled by default.

  • display_contact_forces (bool) – Whether to display the contact forces. Note that the user is responsible for updating sensors data since Viewer.display is only computing kinematic quantities. Optional: Disabled by default.

  • display_f_external (Sequence[bool] | bool | None) – Whether to display the external external forces applied at the joints on the robot. If a boolean is provided, the same visibility will be set for each joint, alternatively one can provide a boolean list whose ordering is consistent with pinocchio_model.names. Note that the user is responsible for updating the force buffer viewer.f_external data since Viewer.display is only computing kinematic quantities. Optional: Root joint for robot with freeflyer by default.

  • kwargs (Any) – Unused extra keyword arguments to enable forwarding.

backend: str | None = None
window_name = 'jiminy'
static open_gui()[source]

Open a new viewer graphical interface. It is only possible if a backend is already running.

Note

Only one graphical interface can be opened locally for efficiency.

Return type:

None

static has_gui()[source]

TODO: Write documentation.

Return type:

bool

static wait(require_client=False)[source]

Wait for all the meshes to finish loading in every clients.

Parameters:

require_client (bool) – Wait for at least one client to be available before checking for mesh loading.

Return type:

None

static is_alive()[source]

Check if the backend server is running and responding to queries.

Return type:

bool

is_open()[source]

Check if a given viewer instance is open, or if the backend server is running if no instance is specified.

Parameters:

self (Viewer | None)

Return type:

bool

close()[source]

Close a given viewer instance, or all of them if no instance is specified.

Note

Calling this method with an viewer instance always closes the client. It may also remove the robot from the server if the viewer attribute delete_robot_on_close is True. Moreover, it is the one having started the backend server, it also terminates it, resulting in closing every viewer somehow. It results in the same outcome than calling this method without specifying any viewer instance.

Parameters:

self (Viewer | None)

Return type:

None

static connect_backend(backend=None)[source]

Get the running process of backend client.

This method can be used to open a new process if necessary.

Parameters:

backend (str | None) – Name of the rendering backend to use. It can be either ‘panda3d’, ‘panda3d-qt’, ‘meshcat’. Optional: The default is hardware and environment dependent. See viewer.default_backend for details.

Returns:

Pointer to the running backend Client and its PID.

Return type:

None

static set_watermark(img_fullpath=None, width=None, height=None)[source]

Insert desired watermark on bottom left corner of the window.

Note

The relative width and height cannot exceed 20% of the visible area, otherwise it will be rescaled.

Parameters:
  • img_fullpath (str | None) – Full path of the image to use as watermark. Meshcat supports format ‘.png’, ‘.jpeg’ or ‘svg’, while Panda3d only supports ‘.png’ and ‘.jpeg’ for now. None or empty string to disable. Optional: None by default.

  • width (int | None) – Desired width for the image. None to not rescale the image manually. Optional: None by default.

  • height (int | None) – Desired height for the image. None to not rescale the image manually. Optional: None by default.

Return type:

None

static set_legend(labels=None)[source]

Insert legend on top left corner of the window.

Note

Make sure to have specified different colors for each robot on the scene, since it will be used as marker on the legend.

Parameters:

labels (Sequence[str] | None) – Sequence of strings whose length must be consistent with the number of robots on the scene. None to disable. Optional: None by default.

Return type:

None

static set_clock(t=None)[source]

Insert clock on bottom right corner of the window.

Note

Only Panda3d rendering backend is supported by this method.

Parameters:

t (float | None) – Current simulation time is seconds. None to disable. Optional: None by default.

Return type:

None

static get_camera_transform()[source]

Get transform of the camera pose.

Warning

The reference axis is negative z-axis instead of positive x-axis.

Warning

It returns the previous requested camera transform for meshcat, since it is impossible to get access to this information. Thus this method is valid as long as the user does not move the camera manually using mouse camera control.

Return type:

Tuple[Tuple[float, float, float] | ndarray, Tuple[float, float, float] | ndarray]

set_camera_transform(position=None, rotation=None, relative=None, wait=False)[source]

Set transform of the camera pose.

Warning

The reference axis is negative z-axis instead of positive x-axis, which means that position = [0.0, 0.0, 0.0], rotation = [0.0, 0.0, 0.0] moves the camera at the center of scene, looking downward.

Parameters:
  • position (Tuple[float, float, float] | ndarray | None) – Position [X, Y, Z] as a list or 1D array. If None, when it will be kept as is. Optional: None by default.

  • rotation (Tuple[float, float, float] | ndarray | None) – Rotation [Roll, Pitch, Yaw] as a list or 1D np.array. If None, when it will be kept as is. Optional: None by default.

  • relative (int | str | None) – How to apply the transform:

    • None: absolute.

    • ’camera’: relative to current camera pose.

    • other: relative to a robot frame, not accounting for the rotation of the frame during travelling. It supports both frame name and index in model.

  • wait (bool) – Whether to wait for rendering to finish.

  • self (Viewer | None)

Return type:

None

set_camera_lookat(position, relative=None, wait=False)[source]

Set the camera look-at position.

Note

It preserve the relative camera pose wrt the lookup position.

Parameters:
  • position (Tuple[float, float, float] | ndarray) – Position [X, Y, Z] as a list or 1D array

  • relative (int | str | None) – If specified, set the lookat position relative to provided position, in absolute world otherwise. Both frame name and index in model are supported.

  • wait (bool) – Whether to wait for rendering to finish.

Return type:

None

static register_camera_motion(camera_motion)[source]

Register camera motion. It will be used later by replay to set the absolute or relative camera pose, depending on whether or not travelling is enable.

Parameters:

camera_motion (Sequence[CameraMotionBreakpointType]) –

Camera breakpoint poses over time, as a list of CameraMotionBreakpointType dict. Here is an example:

[{'t': 0.0,
  'pose': ([3.5, 0.0, 1.4], [1.4, 0.0, np.pi / 2])},
 {'t': 0.3,
  'pose': ([4.5, 0.0, 1.4], [1.4, np.pi / 6, np.pi / 2])},
 {'t': 0.6,
  'pose': ([8.5, 0.0, 1.4], [1.4, np.pi / 3, np.pi / 2])},
 {'t': 1.0,
  'pose': ([9.5, 0.0, 1.4], [1.4, np.pi / 2, np.pi / 2])}]

Return type:

None

static remove_camera_motion()[source]

Remove camera motion.

Return type:

None

attach_camera(relative, position=None, rotation=None, lock_relative_pose=None)[source]

Attach the camera to a given robot frame.

Only the position of the frame is taken into account. A custom relative orientation of the camera wrt to the frame can be further specified. If so, then the relative camera pose wrt the frame is locked, otherwise the camera is only constrained to look at the frame.

Parameters:
  • relative (str | int) – Name or index of the frame of the robot to follow with the camera.

  • position (Tuple[float, float, float] | ndarray | None) – Relative position [X, Y, Z] of the camera wrt the tracked frame. It is used to initialize the camera pose if relative pose is not locked. None to disable. Optional: Disable by default.

  • rotation (Tuple[float, float, float] | ndarray | None) – Relative orientation [Roll, Pitch, Yaw] of the camera wrt the tracked frame. It is used to initialize the camera pose if relative pose is not locked. None to disable. Optional: Disable by default.

  • lock_relative_pose (bool | None) – Whether to lock the relative pose of the camera wrt tracked frame. Optional: False by default iif Panda3d backend is used.

Return type:

None

static detach_camera()[source]

Detach the camera.

Must be called to undo attach_camera, so that it will stop automatically tracking a frame.

Return type:

None

set_color(color=None)[source]

Override the color of the visual and collision geometries of the robot on-the-fly.

Note

This method is only supported by Panda3d for now.

Parameters:

color (str | Tuple[float, float, float, float] | ndarray | None) – Color of the robot. It will override the original color of the meshes if not None, and restore them otherwise. It supports both RGBA codes as a list of 4 floating-point values ranging from 0.0 and 1.0, and a few named colors. Optional: Disabled by default.

Return type:

None

static update_floor(ground_profile=None, x_range=(-10.0, 10.0), y_range=(-10.0, 10.0), grid_unit=(0.04, 0.04), simplify_mesh=False, show_vertices=False)[source]

Display a custom ground profile as a height map or the original tile ground floor.

Parameters:
  • ground_profile (HeightmapFunction | None) – jiminy_py.core.HeightmapFunction associated with the ground profile. It renders a flat tile ground if not specified. Optional: None by default.

  • x_range (Tuple[float, float]) – Tuple gathering min and max limits along x-axis for which the heightmap mesh associated with the ground profile will be procedurally generated. Optional: (-10.0, 10.0) by default.

  • y_range (Tuple[float, float]) – Tuple gathering min and max limits along y-axis. Optional: (-10.0, 10.0) by default.

  • grid_unit (Tuple[float, float]) – Tuple gathering X and Y discretization steps for the generation of the heightmap mesh. Optional: 4cm by default.

  • simplify_mesh (bool) – Whether the generated heightmap mesh should be decimated before final rendering. This option must be enabled for the ratio between grid size and unit is very large to avoid a prohibitive slowdown of the viewer. Optional: False by default

  • show_vertices (bool) – Whether to highlight the mesh vertices. Optional: disabled by default.

Return type:

None

static capture_frame(width=None, height=None, raw_data=False)[source]

Take a snapshot and return associated data.

Parameters:
  • width (int | None) – Width for the image in pixels. None to keep unchanged. Optional: Kept unchanged by default.

  • height (int | None) – Height for the image in pixels. None to keep unchanged. Optional: Kept unchanged by default.

  • raw_data (bool) – Whether to return a 2D numpy array, or the raw output from the backend (the actual type may vary).

Return type:

ndarray | bytes

static save_frame(image_path, width=None, height=None)[source]

Save a snapshot in png format.

Parameters:
  • image_path (str) – Fullpath of the image (.png extension is mandatory)

  • width (int | None) – Width for the image in pixels. None to keep unchanged. Optional: Kept unchanged by default.

  • height (int | None) – Height for the image in pixels. None to keep unchanged. Optional: Kept unchanged by default.

Return type:

None

display_visuals(visibility)[source]

Set the visibility of the visual model of the robot.

Parameters:

visibility (bool) – Whether to enable or disable display of the visual model.

Return type:

None

display_collisions(visibility)[source]

Set the visibility of the collision model of the robot.

Parameters:

visibility (bool) – Whether to enable or disable display of the visual model.

Return type:

None

add_marker(name, shape, pose=(None, None), scale=1.0, color=None, always_foreground=True, remove_if_exists=False, auto_refresh=True, **shape_kwargs)[source]

Add marker on the scene.

Warning

This method is only supported by Panda3d.

Parameters:
  • name (str) – Unique name. It must be a valid string identifier.

  • shape (Literal['cone', 'box', 'sphere', 'capsule', 'cylinder', 'frame', 'arrow']) – Desired shape, as a string, i.e. ‘cone’, ‘box’, ‘sphere’, ‘capsule’, ‘cylinder’, ‘frame’, or ‘arrow’.

  • pose (SE3 | Tuple[Tuple[float, float, float] | ndarray | None, Tuple[float, float, float, float] | ndarray | None] | Callable[[], Tuple[Tuple[float, float, float] | ndarray, Tuple[float, float, float, float] | ndarray]]) – Pose of the geometry on the scene, as a transform object pin.SE3, or a tuple (position, orientation). In the latter case, the position must be the vector [X, Y, Z], while the orientation can be either a rotation matrix, or a quaternion [X, Y, Z, W]. None can be used to specify neutral frame position and/or orientation. Optional: Neutral position and orientation by default.

  • scale (float | Tuple[float, float, float] | ndarray | Callable[[], Tuple[float, float, float] | ndarray]) – Size of the marker. Each principal axis of the geometry are scaled separately.

  • color (str | Tuple[float, float, float, float] | ndarray | None | Callable[[], Tuple[float, float, float, float] | ndarray]) – Color of the marker. It supports both RGBA codes as a list of 4 floating-point values ranging from 0.0 and 1.0, and a few named colors. Optional: Robot’s color by default if overridden, ‘white’ otherwise, except for ‘frame’.

  • always_foreground (bool) – Whether to force rendering the marker on foreground. Optional: True by default.

  • auto_refresh (bool) – Whether to refresh the scene after adding the marker. Useful for adding a bunch of markers and only refresh once. Note that the marker will not display properly until then.

  • shape_kwargs (Any) – Any additional keyword arguments to forward to jiminy_py.viewer.panda3d.panda3d_visualizer. Panda3dApp.append_{shape} for shape instantiation.

  • remove_if_exists (bool)

Returns:

Dict of type MarkerDataType, storing references to the current pose, scale, and color of the marker, and itself a reference to viewer.markers[name]. Any modification of it will take effect at next refresh call.

Return type:

MarkerDataType

display_center_of_mass(visibility)[source]

Display the position of the center of mass as a sphere.

Note

It corresponds to the attribute com[0] of the provided robot.pinocchio_model. Calling Viewer.display will update it automatically, while Viewer.refresh will not.

Parameters:

visibility (bool) – Whether to enable or disable display of the center of mass.

Return type:

None

display_capture_point(visibility)[source]

Display the position of the capture point,also called divergent component of motion (DCM) as a sphere.

Note

Calling Viewer.display will update it automatically, while Viewer.refresh will not.

Parameters:

visibility (bool) – Whether to enable or disable display of the capture point.

Return type:

None

display_contact_frames(visibility)[source]

Display the contact frames of the robot as spheres.

Note

The frames to display are specified by the attribute contact_frame_names of the provided robot. Calling Viewer.display will update it automatically, while Viewer.refresh will not.

Warning

This method is only supported by Panda3d.

Parameters:

visibility (bool) – Whether to display the contact frames.

Return type:

None

display_contact_forces(visibility)[source]

Display forces associated with the contact sensors attached to the robot, as cylinders of variable length depending of Fz.

Note

Fz can be signed. It will affect the orientation of the capsule.

Warning

It corresponds to the attribute data of jiminy.ContactSensor. Calling Viewer.display will NOT update its value automatically. It is up to the user to keep it up-to-date.

Warning

This method is only supported by Panda3d.

Parameters:

visibility (bool) – Whether to display the contact forces.

Return type:

None

display_external_forces(visibility)[source]

Display external forces applied on the joints the robot, as arrows of variable length depending of magnitude of the force.

Warning

It only display the linear component of the force, while ignoring the angular part for now.

Warning

It corresponds to the attribute viewer.f_external. Calling Viewer.display will NOT update its value automatically. It is up to the user to keep it up-to-date.

Warning

This method is only supported by Panda3d.

Parameters:

visibility (Sequence[bool] | bool) – Whether to display the external force applied at each joint selectively. If a boolean is provided, the same visibility will be set for each joint, alternatively, one can provide a boolean list whose ordering is consistent with pinocchio model (i.e. pinocchio_model.names).

Return type:

None

remove_marker(name)[source]

Remove a marker, based on its name.

Parameters:
  • identifier – Name of the marker to remove.

  • name (str)

Return type:

None

refresh(force_update_visual=False, force_update_collision=False, wait=False)[source]

Refresh the configuration of Robot in the viewer.

This method is also in charge of updating the camera placement for travelling.

Note

This method is copy-pasted from Pinocchio.visualize.*.display method, after removing parts responsible of update pinocchio data and collision data. Visual data must still be updated.

Parameters:
  • force_update_visual (bool) – Force update of visual geometries.

  • force_update_collision (bool) – Force update of collision geometries.

  • wait (bool) – Whether to wait for rendering to finish.

Return type:

None

display(q, v=None, xyz_offset=None, update_hook=None, wait=False)[source]

Update the configuration of the robot.

Warning

It will alter original robot data if viewer attribute use_theoretical_model is false.

Parameters:
  • q (ndarray) – Configuration of the robot.

  • v (ndarray | None) – Velocity of the robot. Used only to update velocity dependent markers such as DCM. None if undefined. Optional: None by default.

  • xyz_offset (ndarray | None) – Freeflyer position offset. Note that it does not check for the robot actually have a freeflyer.

  • update_hook (Callable[[], None] | None) – Callable that will be called right after updating kinematics data. None to disable. Optional: None by default.

  • wait (bool) – Whether to wait for rendering to finish.

Return type:

None

replay(evolution_robot, time_interval=(0.0, inf), speed_ratio=1.0, xyz_offset=None, update_hook=None, enable_clock=False, wait=False)[source]

Replay a complete robot trajectory at a given real-time ratio.

Note

Specifying ‘udpate_hook’ is necessary to be able to display sensor information such as contact forces. It will be automatically disable otherwise.

Warning

It will alter original robot data if viewer attribute use_theoretical_model is false.

Parameters:
  • evolution_robot (Sequence[State]) – List of State object of increasing time.

  • time_interval (ndarray | Tuple[float, float]) – Specific time interval to replay. Optional: Complete evolution by default [0, inf].

  • speed_ratio (float) – Real-time factor. Optional: No time dilation by default (1.0).

  • xyz_offset (ndarray | None) – Freeflyer position offset. Note that it does not check for the robot actually have a freeflyer. Optional: None by default.

  • update_hook (Callable[[float, ndarray, ndarray], None] | None) –

    Callable that will be called periodically between every state update. None to disable, otherwise it must have the following signature:

    f(t:float, q: ndarray, v: ndarray) -> None
    

    Optional: No update hook by default.

  • wait (bool) – Whether to wait for rendering to finish.

  • enable_clock (bool)

Return type:

None

jiminy_py.viewer.interactive_mode()[source]

Determine what kind of process is running Python kernel.

Returns:

  • 0: builtin terminal or plain script

  • 1: Spyder or Ipython console that does not support HTML embedding

  • 2: Interactive Jupyter Notebook (can be confused with Qtconsole)

  • 3: Interactive Google Colab

Return type:

int

jiminy_py.viewer.is_display_available()[source]

Check if graphical server is available locally for onscreen rendering or if the viewer can be opened in an interactive cell.

Return type:

bool

jiminy_py.viewer.get_default_backend()[source]

Determine the default backend viewer, depending eventually on the running environment, hardware, and set of available backends.

Panda3d is preferred over Meshcat in non-interactive mode, and on Google Colaboratory because of known latency issue making it unusable. See https://github.com/googlecolab/colabtools/issues/2870

Note

Both Meshcat and Panda3d supports Nvidia EGL rendering without graphical server. Besides, both can fallback to software rendering if necessary, although Panda3d offers only very limited support of it.

Return type:

str

jiminy_py.viewer.extract_replay_data_from_log(log_data, robot)[source]

Extract replay data from log data.

Parameters:
  • robot (Robot) – Jiminy robot for which to extract log data.

  • log_data (Dict[str, ndarray]) – Data from the log file, in a dictionary.

Returns:

Trajectory data, update hook and extra keyword arguments to forward to play_trajectories method to display the trajectory. By default, it enables display of external forces applied on freeflyer if any.

Return type:

Tuple[TrajectoryDataType, Callable[[float, ndarray, ndarray], None] | None, Dict[str, Any]]

jiminy_py.viewer.play_trajectories(trajs_data, update_hooks=None, time_interval=(0.0, inf), speed_ratio=1.0, xyz_offsets=None, robots_colors=None, camera_pose=None, enable_travelling=False, camera_motion=None, watermark_fullpath=None, legend=None, enable_clock=False, display_com=None, display_dcm=None, display_contacts=None, display_f_external=None, scene_name='world', record_video_path=None, record_video_size=None, start_paused=False, backend=None, delete_robot_on_close=None, remove_widgets_overlay=True, close_backend=False, viewers=None, verbose=True, **kwargs)[source]

Replay one or several robot trajectories in a viewer.

The ratio between the replay and the simulation time is kept constant to the desired ratio. One can choose between several backend (‘panda3d’ or ‘meshcat’).

Note

Replay speed is independent of the platform (windows, linux…) and available CPU power.

Parameters:
  • trajs_data (TrajectoryDataType | Sequence[TrajectoryDataType]) – List of TrajectoryDataType dicts.

  • update_hooks (Callable[[float, ndarray, ndarray], None] | Sequence[Callable[[float, ndarray, ndarray], None] | None] | None) –

    Callables associated with each robot that can be used to update non-kinematic robot data, for instance to emulate sensors data from log using the hook provided by update_sensor_measurements_from_log method. None to disable, otherwise it must have signature:

    f(t: float, q: ndarray, v: ndarray) -> None
    

    Optional: None by default.

  • time_interval (ndarray | Tuple[float, float]) – Replay only timesteps in this interval of time. It does not have to be finite. Optional: [0, inf] by default.

  • speed_ratio (float) – Speed ratio of the simulation. Optional: 1.0 by default.

  • xyz_offsets (Tuple[float, float, float] | ndarray | Sequence[Tuple[float, float, float] | ndarray | None] | None) – List of constant position of the root joint for each robot in world frame. None to disable. Optional: None by default.

  • robots_colors (str | Tuple[float, float, float, float] | ndarray | Sequence[str | Tuple[float, float, float, float] | ndarray | None] | None) – List of RGBA codes or named colors defining the color for each robot. It will be applied to every link. None to disable. Optional: Original color if single robot, default color cycle otherwise.

  • camera_pose (Tuple[Tuple[float, float, float] | ndarray | None, Tuple[float, float, float] | ndarray | None, int | str | None] | None) – Tuple position [X, Y, Z], rotation [Roll, Pitch, Yaw], frame name/index specifying the initial pose of the camera or the relative pose wrt the tracked frame depending on whether travelling is enabled. None to disable. Optional: None by default.

  • enable_travelling (bool) – Whether the camera tracks the robot associated with the first trajectory specified in trajs_data. None to disable. Optional: Disabled by default.

  • camera_motion (Sequence[CameraMotionBreakpointType] | None) – Camera breakpoint poses over time, as a list of CameraMotionBreakpointType dict. None to disable. Optional: None by default.

  • watermark_fullpath (str | None) – Add watermark to the viewer. It is not persistent but disabled after replay. This option is only supported by Meshcat backend. None to disable. Optional: No watermark by default.

  • legend (str | Sequence[str] | None) – List of labels defining the legend for each robot. It is not persistent but disabled after replay. None to disable. Optional: No legend by default for a single robot without color, the name of each robot otherwise.

  • enable_clock (bool) – Add clock on bottom right corner of the viewer. Only available with ‘panda3d’ rendering backend. Optional: Disabled by default.

  • display_com (bool | None) – Whether to display the center of mass. None to keep current viewers’ settings, if any. Optional: Enabled by default iif viewers is None, and backend is ‘panda3d’.

  • display_dcm (bool | None) – Whether to display the capture point (also called DCM). None to keep current viewers’ settings. Optional: Enabled by default iif `viewers is None, and backend is ‘panda3d’.

  • display_contacts (bool | None) – Whether to display the contact forces. Note that the user is responsible for updating sensors data via update_hooks. None to keep current viewers’ settings. Optional: Enabled by default iif update_hooks is specified, viewers is None, and backend is ‘panda3d’.

  • display_f_external (Sequence[bool] | bool | None) – Whether to display the external external forces applied at the joints on the robot. If a boolean is provided, the same visibility will be set for each joint, alternatively one can provide a boolean list whose ordering is consistent with pinocchio_model.names. Note that the user is responsible for updating the force buffer viewer.f_external via update_hooks. None to keep current viewers’ settings. Optional: None by default.

  • scene_name (str) – Name of viewer’s scene in which to display the robot. Optional: Common default name if omitted.

  • record_video_path (str | None) – Fullpath location where to save generated video. It must be specified to enable video recording. Meshcat only support ‘webm’ format, while the other renderer only supports ‘mp4’ format encoded with web-compatible ‘h264’ codec. Optional: None by default.

  • record_video_size (Tuple[int, int] | None) – The width and height of the video recording. Optional: (800, 800) if non-interactive and (800, 400) otherwise by default.

  • start_paused (bool) – Start the simulation is pause, waiting for keyboard input before starting to play the trajectories. Only available if record_video_path is None. Optional: False by default.

  • backend (str | None) – Backend, one of ‘meshcat’, ‘panda3d’ and’panda3d-sync. If None, the most appropriate backend will be selected automatically based on hardware and python environment. Optional: None by default.

  • delete_robot_on_close (bool | None) – Whether to delete the robot from the viewer when closing it. Optional: True by default for Panda3d backend in non-interactive mode, False otherwise.

  • remove_widgets_overlay (bool) – Remove overlay (legend, watermark, clock, …) automatically before returning. Optional: Enabled by default.

  • close_backend (bool) – Whether to close backend automatically before returning. Optional: Disabled by default.

  • viewers (Viewer | Sequence[Viewer | None] | None) – List of already instantiated viewers, associated one by one in order to each trajectory data. None to disable. Optional: None by default.

  • verbose (bool) – Add information to keep track of the process. Optional: True by default.

  • kwargs (Any) – Unused keyword arguments to allow chaining rendering methods with ease.

Returns:

List of viewers used to play the trajectories.

Return type:

Sequence[Viewer]

jiminy_py.viewer.play_logs_data(robots, logs_data, **kwargs)[source]

Play log data in a viewer.

This method simply formats the data then calls play_trajectories.

Parameters:
  • robots (Sequence[Robot] | Robot) – Either a single robot, or a list of robot for each log data.

  • logs_data (Sequence[Dict[str, ndarray]] | Dict[str, ndarray]) – Either a single dictionary, or a list of dictionaries of simulation data log.

  • kwargs (Any) – Keyword arguments to forward to play_trajectories method.

Return type:

Sequence[Viewer]

jiminy_py.viewer.play_logs_files(logs_files, mesh_path_dir=None, mesh_package_dirs=(), **kwargs)[source]

Play the content of a logfile in a viewer.

This method reconstruct the exact extended model used during the simulation associated with the logfile, including random biases or flexibility joints.

Parameters:
  • logs_files (str | Sequence[str]) – Either a single simulation log files in any format, or a list.

  • mesh_path_dir (str | None) – Overwrite the common root of all absolute mesh paths. It which may be necessary to read log generated on a different environment.

  • mesh_package_dirs (Sequence[str]) – Additional search paths for all relative mesh paths beginning with ‘packages://’ directive. It may be necessary to specify it to read log generated on a different environment.

  • kwargs (Any) – Keyword arguments to forward to play_trajectories method.

Return type:

Sequence[Viewer]

jiminy_py.viewer.async_play_and_record_logs_files(logs_files, enable_replay=None, mesh_path_dir=None, mesh_package_dirs=(), **kwargs)[source]

Play and/or replay the content of a logfile in a viewer asynchronously.

Note

This call can be made blocking at any point in time by calling join() on the returned Thread instance.

Parameters:
  • logs_files (str | Sequence[str]) – Simulation log files in any of the supported formats.

  • enable_replay (bool | None) – Whether to force replay the simulation. It would first replay then record if this option is enabled and record_video_path is specified. Optional: True by default if record_video_path is not specified and the current backend supports onscreen rendering, False otherwise.

  • mesh_path_dir (str | None) – Overwrite the common root of all absolute mesh paths. It which may be necessary to read log generated on a different environment.

  • mesh_package_dirs (Sequence[str]) – Prepend custom mesh package search path directories to the ones provided by log file.

  • kwargs (Any) – Keyword arguments to forward to play_logs_files method.

Return type:

Thread | None