Go to the documentation of this file. 1 from ..
import pinocchio_pywrap_default
as pin
2 from ..shortcuts
import createDatas
12 IMAGEIO_SUPPORT =
True
14 IMAGEIO_SUPPORT =
False
18 """Pinocchio visualizers are employed to easily display a model at a given configuration.
19 BaseVisualizer is not meant to be directly employed, but only to provide a uniform interface and a few common methods.
20 New visualizers should extend this class and override its methods as neeeded.
37 """Construct a display from the given model, collision model, and visual model.
38 If copy_models is True, the models are copied. Otherwise, they are simply kept as a reference."""
59 if visual_data
is None and self.
visual_model is not None:
65 """Re-build the data objects. Needed if the models were modified.
66 Warning: this will delete any information stored in all data objects."""
72 """Return the name of the geometry object inside the viewer."""
76 """Init the viewer by loading the gui and creating a window."""
80 """Create the scene displaying the robot meshes in the viewer"""
83 def reload(self, new_geometry_object, geometry_type=None):
84 """Reload a geometry_object given by its type"""
88 """Delete all the objects from the whole scene"""
93 """Display the robot at configuration q or refresh the rendering
94 from the current placements contained in data by placing all the bodies in the viewer."""
98 """Set whether to display collision objects or not."""
102 """Set whether to display visual objects or not."""
106 """Set the visualizer background color."""
110 """Set the camera target."""
114 """Set the camera's 3D position."""
118 """Set camera zoom value."""
122 """Set camera 6D pose using a 4x4 matrix."""
126 """Captures an image from the viewer and returns an RGB array."""
130 """Disable camera manual control"""
134 """Enable camera manual control"""
138 """Draw current frame velocities."""
146 def play(self, q_trajectory, dt=None, callback=None, capture=False, **kwargs):
147 """Play a trajectory with given time step. Optionally capture RGB images and returns them."""
148 nsteps = len(q_trajectory)
153 for i
in range(nsteps):
156 if callback
is not None:
157 callback(i, **kwargs)
165 elapsed_time = t1 - t0
166 if dt
is not None and elapsed_time < dt:
167 self.
sleep(dt - elapsed_time)
172 """Create a video recording context, generating the output filename if necessary.
174 Code inspired from https://github.com/petrikvladimir/RoboMeshCat.
176 if not IMAGEIO_SUPPORT:
177 import warnings, contextlib
180 "Video context cannot be created because imageio is not available.",
183 return contextlib.nullcontext()
185 if directory
is None:
186 from tempfile
import gettempdir
188 directory = gettempdir()
189 f_fmt =
"%Y%m%d_%H%M%S"
191 filename = time.strftime(
"{}.{}".format(f_fmt, ext))
192 filename = osp.join(directory, filename)
199 self.
vid_writer = imageio.get_writer(filename, fps=fps, **kwargs)
202 print(
"[Entering video recording context]")
207 self.
viz._video_writer =
None
210 __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 Tue Jun 25 2024 02:42:34