Visualization

Pinker displays robots with Viser, which serves the scene to a Web browser and handles user inputs. You can start a visualizer from a robot wrapper, then display configurations as the inverse kinematics unrolls:

from pinker.visualizer import start_viser_visualizer

viz = start_viser_visualizer(robot)
viz.display(configuration.q)

Visuals come from the geometry model that build_geom_from_urdf() reads from the URDF: see Kinematics for the geometry types the parser supports.

Robot visualization with Viser.

class pinker.visualizer.ViserVisualizer(model, visual_model=None)

A robot visualizer using Viser, like Pinocchio’s.

The viewer and the scene nodes are created when the visualizer starts: init_viewer() connects to a Viser server, then load_viewer_model() adds the robot’s visuals and frames to its scene.

data

Data where the visualizer runs its forward kinematics.

frames

Scene nodes of the robot’s visuals and frames, by node name.

frames_root_frame

Scene node the frames of the model hang from.

frames_root_node_name

Name of that scene node.

model

Robot model to visualize.

viewer

Viser server the scene is displayed in, None until init_viewer() is called.

viewer_root_node_name

Name of the scene node the robot hangs from.

visual_model

Geometry model with the robot’s visuals.

visual_root_frame

Scene node the visuals of the model hang from.

visual_root_node_name

Name of that scene node.

display(q=None)

Display the robot at a given configuration.

Parameters:

q (Optional[ndarray]) – Configuration vector. If None, the placements already in the visualizer’s data are displayed as is.

Return type:

None

display_frames(visibility)

Toggle display of the model frames.

Parameters:

visibility (bool) – If true, display the frames of the model.

Return type:

None

display_visuals(visibility)

Toggle display of the visual model.

Parameters:

visibility (bool) – If true, display the visual model.

Return type:

None

init_viewer(viewer=None, open=False, loadModel=False, host='localhost', port=8080)

Start a new Viser server (or reuse the one passed as viewer).

Parameters:
  • viewer – Existing Viser server to reuse. If None, a new server is started.

  • open (bool) – If true, open the viewer in a web browser and wait for a client to connect, for at most ten seconds.

  • loadModel (bool) – If true, load the visual model in the viewer.

  • host (str) – Host name the new server listens to.

  • port (int) – Port the new server listens to.

Return type:

None

load_viewer_model(rootNodeName='robot', frame_axis_length=0.2, frame_axis_radius=0.01)

Load the visual model in the viewer.

Parameters:
  • rootNodeName (str) – Name of the root node of the robot in the scene.

  • frame_axis_length (float) – Length of frame axes in [m].

  • frame_axis_radius (float) – Radius of frame axes in [m].

Return type:

None

update_frames()

Update model frame placements in the viewer.

Return type:

None

update_placements()

Update visual geometry placements in the viewer.

Return type:

None

pinker.visualizer.start_viser_visualizer(robot, open=True)

Open a Viser visualizer in a Web browser.

Parameters:
  • robot (RobotWrapper) – Robot wrapper with its model and data.

  • open (bool) – If set (default), open Viser in a new Web browser tab.

Return type:

ViserVisualizer

Returns:

Viser visualizer.