Exemplo n.º 1
0
def makeZXZArm(isFixed=True, X_base=sva.PTransformd.Identity()):
    mbg = rbdyn.MultiBodyGraph()

    mass = 1.0
    I = eigen.Matrix3d.Identity()
    h = eigen.Vector3d.Zero()

    rbi = sva.RBInertiad(mass, h, I)

    b0 = rbdyn.Body(rbi, "b0")
    b1 = rbdyn.Body(rbi, "b1")
    b2 = rbdyn.Body(rbi, "b2")
    b3 = rbdyn.Body(rbi, "b3")

    mbg.addBody(b0)
    mbg.addBody(b1)
    mbg.addBody(b2)
    mbg.addBody(b3)

    j0 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitZ(), True, "j0")
    j1 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitX(), True, "j1")
    j2 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitZ(), True, "j2")

    mbg.addJoint(j0)
    mbg.addJoint(j1)
    mbg.addJoint(j2)

    to = sva.PTransformd(eigen.Vector3d(0, 0.5, 0))
    _from = sva.PTransformd(eigen.Vector3d(0, 0, 0))

    mbg.linkBodies("b0", sva.PTransformd.Identity(), "b1", _from, "j0")
    mbg.linkBodies("b1", to, "b2", _from, "j1")
    mbg.linkBodies("b2", to, "b3", _from, "j2")

    mb = mbg.makeMultiBody("b0", isFixed, X_base)

    mbc = rbdyn.MultiBodyConfig(mb)
    mbc.zero(mb)

    return mb, mbc
Exemplo n.º 2
0
def TutorialTree():
    """
  Return the MultiBodyGraph, MultiBody and the zeroed MultiBodyConfig with the
  following tree structure:

                b4
             j3 | Spherical
  Root     j0   |   j1     j2     j4
  ---- b0 ---- b1 ---- b2 ----b3 ----b5
  Fixed    RevX   RevY    RevZ   PrismZ
  """

    mbg = rbd.MultiBodyGraph()

    mass = 1.
    I = e.Matrix3d.Identity()
    h = e.Vector3d.Zero()

    rbi = sva.RBInertia(mass, h, I)

    b0 = rbd.Body(rbi, 0, "b0")
    b1 = rbd.Body(rbi, 1, "b1")
    b2 = rbd.Body(rbi, 2, "b2")
    b3 = rbd.Body(rbi, 3, "b3")
    b4 = rbd.Body(rbi, 4, "b4")
    b5 = rbd.Body(rbi, 5, "b5")

    mbg.addBody(b0)
    mbg.addBody(b1)
    mbg.addBody(b2)
    mbg.addBody(b3)
    mbg.addBody(b4)
    mbg.addBody(b5)

    j0 = rbd.Joint(rbd.Joint.Rev, e.Vector3d.UnitX(), True, 0, "j0")
    j1 = rbd.Joint(rbd.Joint.Rev, e.Vector3d.UnitY(), True, 1, "j1")
    j2 = rbd.Joint(rbd.Joint.Rev, e.Vector3d.UnitZ(), True, 2, "j2")
    j3 = rbd.Joint(rbd.Joint.Spherical, True, 3, "j3")
    j4 = rbd.Joint(rbd.Joint.Prism, e.Vector3d.UnitY(), True, 4, "j4")

    mbg.addJoint(j0)
    mbg.addJoint(j1)
    mbg.addJoint(j2)
    mbg.addJoint(j3)
    mbg.addJoint(j4)

    to = sva.PTransformd(e.Vector3d(0., 0.5, 0.))
    fro = sva.PTransformd.Identity()

    mbg.linkBodies(0, to, 1, fro, 0)
    mbg.linkBodies(1, to, 2, fro, 1)
    mbg.linkBodies(2, to, 3, fro, 2)
    mbg.linkBodies(1, sva.PTransformd(e.Vector3d(0.5, 0., 0.)), 4, fro, 3)
    mbg.linkBodies(3, to, 5, fro, 4)

    mb = mbg.makeMultiBody(0, True)
    mbc = rbd.MultiBodyConfig(mb)
    mbc.zero(mb)

    return mbg, mb, mbc
Exemplo n.º 3
0
def makeEnv():
    mbg = rbdyn.MultiBodyGraph()

    mass = 1.0
    I = eigen.Matrix3d.Identity()
    h = eigen.Vector3d.Zero()

    rbi = sva.RBInertiad(mass, h, I)

    b0 = rbdyn.Body(rbi, "b0")

    mbg.addBody(b0)

    mb = mbg.makeMultiBody("b0", True)

    mbc = rbdyn.MultiBodyConfig(mb)
    mbc.zero(mb)

    return mb, mbc
Exemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import eigen
import sva
import rbdyn

mbg = rbdyn.MultiBodyGraph()

mass = 1.0
I = eigen.Matrix3d.Identity()
h = eigen.Vector3d.Zero()

rbi = sva.RBInertiad(mass, h, I)

b0 = rbdyn.Body(rbi, "b0")
b1 = rbdyn.Body(rbi, "b1")
b2 = rbdyn.Body(rbi, "b2")
b3 = rbdyn.Body(rbi, "b3")

mbg.addBody(b0)
mbg.addBody(b1)
mbg.addBody(b2)
mbg.addBody(b3)

j0 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitX(), True, "j0")
j1 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitX(), True, "j1")
j2 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitX(), True, "j2")

mbg.addJoint(j0)
mbg.addJoint(j1)
Exemplo n.º 5
0
 def makeBody(bName):
     I = sva.RBInertiad(e3.Vector3d.Random().x(), e3.Vector3d.Random(),
                        e3.Matrix3d.Random())
     return rbd.Body(I, bName)
Exemplo n.º 6
0
def createRobot():
    mb, mbc, mbg = rbdyn.MultiBody(), rbdyn.MultiBodyConfig(
    ), rbdyn.MultiBodyGraph()
    limits = mc_rbdyn_urdf.Limits()
    visual = {}
    collision_tf = {}

    I0 = eigen.Matrix3d([[0.1, 0.0, 0.0], [0.0, 0.05, 0.0], [0.0, 0.0, 0.001]])
    I1 = eigen.Matrix3d([[1.35, 0.0, 0.0], [0.0, 0.05, 0.0], [0.0, 0.0,
                                                              1.251]])
    I2 = eigen.Matrix3d([[0.6, 0.0, 0.0], [0.0, 0.05, 0.0], [0.0, 0.0, 0.501]])
    I3 = eigen.Matrix3d([[0.475, 0.0, 0.0], [0.0, 0.05, 0.0],
                         [0.0, 0.0, 0.376]])
    I4 = eigen.Matrix3d([[0.1, 0.0, 0.0], [0.0, 0.3, 0.0], [0.0, 0.0, 0.251]])

    T0 = sva.PTransformd(eigen.Vector3d(0.1, 0.2, 0.3))
    T1 = sva.PTransformd.Identity()

    b0 = rbdyn.Body(1., eigen.Vector3d.Zero(), I0, "b0")
    b1 = rbdyn.Body(5., eigen.Vector3d(0., 0.5, 0.), I1, "b1")
    b2 = rbdyn.Body(2., eigen.Vector3d(0., 0.5, 0.), I2, "b2")
    b3 = rbdyn.Body(1.5, eigen.Vector3d(0., 0.5, 0.), I3, "b3")
    b4 = rbdyn.Body(1., eigen.Vector3d(0.5, 0., 0.), I4, "b4")

    mbg.addBody(b0)
    mbg.addBody(b1)
    mbg.addBody(b2)
    mbg.addBody(b3)
    mbg.addBody(b4)

    j0 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitX(), True, "j0")
    j1 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitY(), True, "j1")
    j2 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitZ(), True, "j2")
    j3 = rbdyn.Joint(rbdyn.Joint.Rev, eigen.Vector3d.UnitX(), True, "j3")

    mbg.addJoint(j0)
    mbg.addJoint(j1)
    mbg.addJoint(j2)
    mbg.addJoint(j3)

    to = sva.PTransformd(eigen.Vector3d(0, 1, 0))
    from_ = sva.PTransformd.Identity()

    mbg.linkBodies("b0", to, "b1", from_, "j0")
    mbg.linkBodies("b1", to, "b2", from_, "j1")
    mbg.linkBodies("b2", to, "b3", from_, "j2")
    mbg.linkBodies("b1",
                   sva.PTransformd(sva.RotX(1.), eigen.Vector3d(1., 0., 0.)),
                   "b4", from_, "j3")

    mb = mbg.makeMultiBody("b0", True)
    mbc = rbdyn.MultiBodyConfig(mb)
    mbc.zero(mb)

    limits.lower = {
        "j0": [-1.],
        "j1": [-1.],
        "j2": [-1.],
        "j3": [-float('Inf')]
    }
    limits.upper = {"j0": [1.], "j1": [1.], "j2": [1.], "j3": [float('Inf')]}
    limits.velocity = {
        "j0": [10.],
        "j1": [10.],
        "j2": [10.],
        "j3": [float('Inf')]
    }
    limits.torque = {
        "j0": [50.],
        "j1": [50.],
        "j2": [50.],
        "j3": [float('Inf')]
    }

    v1 = mc_rbdyn_urdf.Visual()
    v1.origin = T0
    geometry = mc_rbdyn_urdf.Geometry()
    geometry.type = mc_rbdyn_urdf.Geometry.MESH
    mesh = mc_rbdyn_urdf.GeometryMesh()
    mesh.filename = "test_mesh1.dae"
    geometry.data = mesh
    v1.geometry = geometry

    v2 = mc_rbdyn_urdf.Visual()
    v2.origin = T1
    mesh.filename = "test_mesh2.dae"
    geometry.data = mesh
    v2.geometry = geometry

    visual = {b"b0": [v1, v2]}

    return mb, mbc, mbg, limits, visual, collision_tf