5 from ..
import pinocchio_pywrap_default
as pin
6 from ..utils
import npToTuple
7 from .base_visualizer
import BaseVisualizer
12 WITH_HPP_FCL_BINDINGS =
True
14 WITH_HPP_FCL_BINDINGS =
False
19 A Pinocchio display using panda3d engine.
23 """Init the viewer by attaching to / creating a GUI viewer."""
30 from panda3d_viewer
import Viewer
as Panda3dViewer
33 self.
viewer = Panda3dViewer(window_title=
"python-pinocchio")
39 """Create a group of nodes displaying the robot meshes in the viewer."""
48 if WITH_HPP_FCL_BINDINGS
and isinstance(geom, hppfcl.ShapeBase):
50 if isinstance(geom, hppfcl.Capsule):
51 r, fl = geom.radius, 2 * geom.halfLength
52 self.
viewer.append_capsule(root, obj.name, r, fl)
53 elif isinstance(geom, hppfcl.Cylinder):
54 r, fl = geom.radius, 2 * geom.halfLength
55 self.
viewer.append_cylinder(root, obj.name, r, fl)
56 elif isinstance(geom, hppfcl.Box):
58 self.
viewer.append_box(root, obj.name, size)
59 elif isinstance(geom, hppfcl.Sphere):
60 self.
viewer.append_sphere(root, obj.name, geom.radius)
62 msg = f
"Unsupported geometry type for {obj.name} ({type(geom)})"
63 warnings.warn(msg, category=UserWarning, stacklevel=2)
68 self.
viewer.append_mesh(root, obj.name, obj.meshPath, scale)
70 if obj.overrideMaterial:
72 path = obj.meshTexturePath
73 self.
viewer.set_material(root, obj.name, rgba, path)
74 elif color
is not None:
75 self.
viewer.set_material(root, obj.name, color)
89 """Return the name of the geometry object inside the viewer."""
90 if geometry_type
is pin.GeometryType.VISUAL:
92 elif geometry_type
is pin.GeometryType.COLLISION:
97 Display the robot at configuration q in the viewer by placing all the bodies.
100 pin.forwardKinematics(self.
model, self.
data, q)
102 def move(group, model, data):
103 pin.updateGeometryPlacements(self.
model, self.
data, model, data)
105 for obj
in model.geometryObjects:
106 oMg = data.oMg[model.getGeometryId(obj.name)]
107 x, y, z, qx, qy, qz, qw = pin.SE3ToXYZQUATtuple(oMg)
108 name_pose_dict[obj.name] = (x, y, z), (qw, qx, qy, qz)
109 self.
viewer.move_nodes(group, name_pose_dict)
118 """Set whether to display collision objects or not."""
123 """Set whether to display visual objects or not."""
128 raise NotImplementedError()
131 raise NotImplementedError()
134 raise NotImplementedError()
137 raise NotImplementedError()
140 raise NotImplementedError()
143 raise NotImplementedError()
146 raise NotImplementedError()
149 raise NotImplementedError()
152 raise NotImplementedError()
155 __all__ = [
"Panda3dVisualizer"]