3 from ..
import pinocchio_pywrap
as pin
4 from ..utils
import npToTuple
5 from .base_visualizer
import BaseVisualizer
9 WITH_HPP_FCL_BINDINGS =
True 11 WITH_HPP_FCL_BINDINGS =
False 15 A Pinocchio display using panda3d engine. 19 """Init the viewer by attaching to / creating a GUI viewer.""" 26 from panda3d_viewer
import Viewer
as Panda3dViewer
28 self.
viewer = Panda3dViewer(window_title=
"python-pinocchio")
34 """Create a group of nodes displaying the robot meshes in the viewer.""" 43 if WITH_HPP_FCL_BINDINGS
and isinstance(geom, hppfcl.ShapeBase):
45 if isinstance(geom, hppfcl.Capsule):
46 r, l = geom.radius, 2 * geom.halfLength
47 self.
viewer.append_capsule(root, obj.name, r, l)
48 elif isinstance(geom, hppfcl.Cylinder):
49 r, l = geom.radius, 2 * geom.halfLength
50 self.
viewer.append_cylinder(root, obj.name, r, l)
51 elif isinstance(geom, hppfcl.Box):
53 self.
viewer.append_box(root, obj.name, size)
54 elif isinstance(geom, hppfcl.Sphere):
55 self.
viewer.append_sphere(root, obj.name, geom.radius)
57 msg =
"Unsupported geometry type for %s (%s)" % (
59 warnings.warn(msg, category=UserWarning, stacklevel=2)
64 self.
viewer.append_mesh(root, obj.name, obj.meshPath, scale)
66 if obj.overrideMaterial:
68 path = obj.meshTexturePath
69 self.
viewer.set_material(root, obj.name, rgba, path)
70 elif color
is not None:
71 self.
viewer.set_material(root, obj.name, color)
85 """Return the name of the geometry object inside the viewer.""" 86 if geometry_type
is pin.GeometryType.VISUAL:
88 elif geometry_type
is pin.GeometryType.COLLISION:
92 """Display the robot at configuration q in the viewer by placing all the bodies.""" 94 pin.forwardKinematics(self.
model, self.
data, q)
96 def move(group, model, data):
97 pin.updateGeometryPlacements(self.
model, self.
data, model, data)
99 for obj
in model.geometryObjects:
100 oMg = data.oMg[model.getGeometryId(obj.name)]
101 x, y, z, qx, qy, qz, qw = pin.SE3ToXYZQUATtuple(oMg)
102 name_pose_dict[obj.name] = (x, y, z), (qw, qx, qy, qz)
103 self.
viewer.move_nodes(group, name_pose_dict)
113 """Set whether to display collision objects or not.""" 118 """Set whether to display visual objects or not.""" 122 __all__ = [
'Panda3dVisualizer']
result_of::push_front< V const, T >::type append(T const &t, V const &v)
Append the element T at the front of boost fusion vector V.
def getViewerNodeName(self, geometry_object, geometry_type)
def displayCollisions(self, visibility)
def displayCollisions(self, visibility)
def displayVisuals(self, visibility)
def displayVisuals(self, visibility)
def loadViewerModel(self, args, kwargs)
def initViewer(self, viewer=None, load_model=False)
def display(self, q=None)
def loadViewerModel(self, group_name, color=None)