6 from pinocchio
import Motion, Force, skew
10 '''Return the joint index from the velocity index''' 11 for j
in range(1,robot.model.njoint):
12 if idxv
in range(robot.model.joints[j].idx_v,
13 robot.model.joints[j].idx_v+robot.model.joints[j].nv):
16 parent =
lambda i,robot: robot.model.parents[i]
17 iv =
lambda i,robot: list(range(robot.model.joints[i].idx_v,
18 robot.model.joints[i].idx_v+robot.model.joints[i].nv))
19 ancestors =
lambda j,robot,res=[]: res
if j==0
else ancestors(robot.model.parents[j],robot,[j,]+res)
26 if anc==dec:
return True 27 else: dec = self.
robot.model.parents[dec]
29 descendants =
lambda root,robot: robot.model.subtrees[root]
33 ancestors.__defaults__ = (robot,)+ancestors.__defaults__
34 descendants.__defaults__ = (robot,)
36 iv.__defaults__ = (robot,)
37 parent.__defaults__ = (robot,)
38 jFromIdx.__defaults__ = (robot,)
42 Mcross.__doc__ =
"Motion cross product" 45 Fcross.__doc__ =
"Force cross product" 47 MCross =
lambda V,v: np.bmat([
Mcross(V[:,i],v)
for i
in range(V.shape[1]) ])
48 FCross =
lambda V,f: np.bmat([
Fcross(V[:,i],f)
for i
in range(V.shape[1]) ])
52 adj.__doc__ =
"Motion pre-cross product (ie adjoint, lie bracket operator)" 54 adjdual =
lambda nu: np.bmat([[
skew(nu[3:]),
zero([3,3])],[
skew(nu[:3]),
skew(nu[3:])]])
55 adjdual.__doc__ =
"Force pre-cross product adjdual(a) = -adj(a)' " 58 quad =
lambda H,v: np.array(
td(
td(H,v,[2,0]),v,[1,0]))
59 quad.__doc__ =
'''Tensor product v'*H*v, with H.shape = [ nop, nv, nv ]''' 62 mformat = lambda x,sarg = sarg,eps=eps: sarg.format(x)
if abs(x)>eps
else ' 0. ' 63 np.set_printoptions(formatter={
'float': mformat})
def __contains__(self, anc)
ForceTpl< double, 0 > Force
def __init__(self, i, robot)
def np_prettyprint(sarg='{:0.5f}', eps=5e-7)
MotionTpl< double, 0 > Motion
def jFromIdx(idxv, robot)