Go to the documentation of this file.
    3 from pathlib 
import Path
 
    7 from .. 
import pinocchio_pywrap_default 
as pin
 
    8 from ..shortcuts 
import createDatas
 
   13     IMAGEIO_SUPPORT = 
True 
   15     IMAGEIO_SUPPORT = 
False 
   20     Pinocchio visualizers are employed to easily display a model at a given 
   22     BaseVisualizer is not meant to be directly employed, but only to provide a uniform 
   23     interface and a few common methods. 
   24     New visualizers should extend this class and override its methods as neeeded. 
   42         Construct a display from the given model, collision model, and visual model. 
   43         If copy_models is True, the models are copied. Otherwise, they are simply kept 
   66         if visual_data 
is None and self.
visual_model is not None:
 
   72         """Re-build the data objects. Needed if the models were modified. 
   73         Warning: this will delete any information stored in all data objects.""" 
   79         """Return the name of the geometry object inside the viewer.""" 
   83         """Init the viewer by loading the gui and creating a window.""" 
   87         """Create the scene displaying the robot meshes in the viewer""" 
   90     def reload(self, new_geometry_object, geometry_type=None):
 
   91         """Reload a geometry_object given by its type""" 
   95         """Delete all the objects from the whole scene""" 
  101         Display the robot at configuration q or refresh the rendering 
  102         from the current placements contained in data by placing all the bodies in the 
  108         """Set whether to display collision objects or not.""" 
  112         """Set whether to display visual objects or not.""" 
  116         """Set the visualizer background color.""" 
  120         """Set the camera target.""" 
  124         """Set the camera's 3D position.""" 
  128         """Set camera zoom value.""" 
  132         """Set camera 6D pose using a 4x4 matrix.""" 
  136         """Captures an image from the viewer and returns an RGB array.""" 
  140         """Disable camera manual control""" 
  144         """Enable camera manual control""" 
  148         """Draw current frame velocities.""" 
  156     def play(self, q_trajectory, dt=None, callback=None, capture=False, **kwargs):
 
  158         Play a trajectory with given time step. Optionally capture RGB images and 
  161         nsteps = len(q_trajectory)
 
  166         for i 
in range(nsteps):
 
  169             if callback 
is not None:
 
  170                 callback(i, **kwargs)
 
  178             elapsed_time = t1 - t0
 
  179             if dt 
is not None and elapsed_time < dt:
 
  180                 self.
sleep(dt - elapsed_time)
 
  186         Create a video recording context, generating the output filename if necessary. 
  188         Code inspired from https://github.com/petrikvladimir/RoboMeshCat. 
  190         if not IMAGEIO_SUPPORT:
 
  195                 "Video context cannot be created because imageio is not available.",
 
  198             return contextlib.nullcontext()
 
  200             if directory 
is None:
 
  201                 from tempfile 
import gettempdir
 
  203                 directory = gettempdir()
 
  204             directory = Path(directory)
 
  205             f_fmt = 
"%Y%m%d_%H%M%S" 
  207             filename = directory / time.strftime(f
"{f_fmt}.{ext}")
 
  214         self.
vid_writer = imageio.get_writer(filename, fps=fps, **kwargs)
 
  217         print(
"[Entering video recording context]")
 
  222         self.
viz._video_writer = 
None 
  225 __all__ = [
"BaseVisualizer"]
 
  
def disableCameraControl(self)
def has_video_writer(self)
def setCameraPose(self, np.ndarray pose=np.eye(4))
def displayCollisions(self, visibility)
def setBackgroundColor(self)
def __init__(self, viz, fps, filename, **kwargs)
def getViewerNodeName(self, geometry_object, geometry_type)
def drawFrameVelocities(self, *args, **kwargs)
def setCameraZoom(self, float zoom)
def setCameraPosition(self, np.ndarray position)
def captureImage(self, w=None, h=None)
def reload(self, new_geometry_object, geometry_type=None)
ConstraintDataTpl< Scalar, Options, ConstraintCollectionTpl > createData(const ConstraintModelTpl< Scalar, Options, ConstraintCollectionTpl > &cmodel)
def setCameraTarget(self, target)
def create_video_ctx(self, filename=None, fps=30, directory=None, **kwargs)
def displayVisuals(self, visibility)
def display(self, q=None)
def __init__(self, model=pin.Model(), collision_model=None, visual_model=None, copy_models=False, data=None, collision_data=None, visual_data=None)
def enableCameraControl(self)
def __exit__(self, *args)
def play(self, q_trajectory, dt=None, callback=None, capture=False, **kwargs)
def loadViewerModel(self, *args, **kwargs)
def initViewer(self, *args, **kwargs)
pinocchio
Author(s): 
autogenerated on Wed May 28 2025 02:41:14