visualizers.py
Go to the documentation of this file.
1 from enum import Enum
2 from importlib.util import find_spec
3 from os import environ
4 
5 from .base_visualizer import BaseVisualizer
6 from .gepetto_visualizer import GepettoVisualizer
7 from .meshcat_visualizer import MeshcatVisualizer
8 from .panda3d_visualizer import Panda3dVisualizer
9 from .rviz_visualizer import RVizVisualizer
10 
11 
12 class Visualizer(Enum):
13  BASE = BaseVisualizer
14  GEPETTO = GepettoVisualizer
15  MESHCAT = MeshcatVisualizer
16  PANDA3D = Panda3dVisualizer
17  RVIZ = RVizVisualizer
18 
19  @classmethod
20  def default(cls):
21  """
22  Allow user to choose their prefered viewer with eg.
23  export PINOCCHIO_VIEWER=RVIZ.
24 
25  Otherwise, try to find one which is installed.
26  """
27  # Allow user to define which viewer they want
28  if "PINOCCHIO_VIEWER" in environ:
29  selected = environ["PINOCCHIO_VIEWER"].upper()
30  if hasattr(cls, selected):
31  return getattr(cls, selected).value
32  err = (
33  f"The visualizer '{selected}' is not available.\n"
34  "Please set PINOCCHIO_VIEWER to something installed among:\n"
35  "- meshcat\n"
36  "- gepetto-viewer\n"
37  "- panda3d\n"
38  "- rviz\n"
39  )
40  raise ImportError(err)
41 
42  # Otherwise, use the first available
43  for v in ["meshcat", "gepetto", "panda3d_viewer", "rviz"]:
44  if find_spec(v) is not None:
45  return getattr(cls, v.replace("_viewer", "").upper()).value
46 
47  err = (
48  "No visualizer could be found.\n"
49  "Please install one of those:\n"
50  "- meshcat\n"
51  "- gepetto-viewer\n"
52  "- panda3d\n"
53  "- rviz\n"
54  )
55  raise ImportError(err)
pinocchio.visualize.visualizers.Visualizer.default
def default(cls)
Definition: visualizers.py:20
pinocchio.visualize.visualizers.Visualizer
Definition: visualizers.py:12


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:13