6 from typing 
import ClassVar
 
    8 import pinocchio 
as pin
 
   15     m = pin.SE3.Identity()
 
   16     m.translation = np.array([x, y, z])
 
   17     m.rotation *= rotate(
"x", rx)
 
   18     m.rotation *= rotate(
"y", ry)
 
   19     m.rotation *= rotate(
"z", rz)
 
   24     return [int(i) 
for i 
in f
"{int(bin(body_number % 8)[2:]):03d}"] + [1]
 
   30             (
"universe", pin.SE3.Identity(), pin.SE3.Identity().translation)
 
   32         self.
name = self.__class__.__name__ 
if name 
is None else name
 
   38         for joint 
in self.joints:
 
   53         if joint_model 
is None:
 
   55         elif isinstance(joint_model, str):
 
   56             joint_model = pin.__dict__[
"JointModel" + joint_model]()
 
   57         if joint_placement 
is None:
 
   58             joint_placement = pin.SE3.Identity()
 
   59         elif isinstance(joint_placement, dict):
 
   60             joint_placement = 
placement(**joint_placement)
 
   62             lever = pin.SE3.Identity()
 
   63         elif isinstance(lever, dict):
 
   65         joint_name, body_name = (
 
   66             f
"world/{self.name}_{joint_name}_{i}" for i 
in (
"joint", 
"body")
 
   68         body_inertia = pin.Inertia.Random()
 
   71                 (float(i) 
for i 
in dimensions)
 
   72                 if isinstance(dimensions, tuple)
 
   73                 else [float(dimensions)] * 3
 
   76                 mass = w * h * d * DENSITY
 
   77             body_inertia = pin.Inertia.FromBox(mass, w, h, d)
 
   79                 self.
display.viewer.gui.addBox(body_name, w, h, d, 
color(body_color))
 
   80         elif shape == 
"cylinder":
 
   83                 mass = pi * r**2 * h * DENSITY
 
   84             body_inertia = pin.Inertia.FromCylinder(mass, r, h)
 
   86                 self.
display.viewer.gui.addCylinder(body_name, r, h, 
color(body_color))
 
   87         elif shape == 
"sphere":
 
   89                 (float(i) 
for i 
in dimensions)
 
   90                 if isinstance(dimensions, tuple)
 
   91                 else [float(dimensions)] * 3
 
   94                 mass = 4.0 / 3.0 * pi * w * h * d * DENSITY
 
   95             body_inertia = pin.Inertia.FromEllipsoid(mass, w, h, d)
 
   97                 self.
display.viewer.gui.addSphere(
 
   98                     body_name, dimensions, 
color(body_color)
 
  100         body_inertia.lever = lever.translation
 
  101         joint_id = self.
model.addJoint(parent, joint_model, joint_placement, joint_name)
 
  102         self.
model.appendBodyToJoint(joint_id, body_inertia, pin.SE3.Identity())
 
  103         self.
model.addJointFrame(joint_id, -1)
 
  104         self.
model.addBodyFrame(body_name, joint_id, pin.SE3.Identity(), -1)
 
  111         for i, (name, placement, lever) 
in enumerate(self.
visuals):
 
  115         self.
display.viewer.gui.refresh()
 
  120         from gepetto 
import corbaserver
 
  124             window_id = self.
viewer.gui.getWindowID(window_name)
 
  126             window_id = self.
viewer.gui.createWindow(window_name)
 
  127             self.
viewer.gui.createSceneWithFloor(
"world")
 
  128             self.
viewer.gui.addSceneToWindow(
"world", window_id)
 
  129         self.
viewer.gui.setLightingMode(
"world", 
"OFF")
 
  130         self.
viewer.gui.setVisibility(
"world/floor", 
"OFF")
 
  134         self.
viewer.gui.applyConfiguration(obj_name, pin.se3ToXYZQUATtuple(m))
 
  140             "joint_name": 
"pelvis",
 
  141             "dimensions": (0.1, 0.2, 0.1),
 
  145             "joint_name": 
"left_leg",
 
  147             "joint_placement": {
"y": -0.15},
 
  148             "lever": {
"z": -0.45},
 
  150             "dimensions": (0.1, 0.9),
 
  156             "joint_name": 
"right_leg",
 
  158             "joint_placement": {
"y": 0.15},
 
  159             "lever": {
"z": -0.45},
 
  161             "dimensions": (0.1, 0.9),