7 from pinocchio
import Force, Motion, skew
12 """Return the joint index from the velocity index"""
13 for j
in range(1, robot.model.njoint):
15 robot.model.joints[j].idx_v,
16 robot.model.joints[j].idx_v + robot.model.joints[j].nv,
21 parent =
lambda i, robot: robot.model.parents[i]
22 iv =
lambda i, robot: list(
24 robot.model.joints[i].idx_v,
25 robot.model.joints[i].idx_v + robot.model.joints[i].nv,
28 ancestors =
lambda j, robot, res=[]: (
32 robot.model.parents[j],
50 dec = self.
robot.model.parents[dec]
55 descendants =
lambda root, robot: robot.model.subtrees[root]
59 ancestors.__defaults__ = (robot, *ancestors.__defaults__)
60 descendants.__defaults__ = (robot,)
62 iv.__defaults__ = (robot,)
63 parent.__defaults__ = (robot,)
64 jFromIdx.__defaults__ = (robot,)
69 Mcross.__doc__ =
"Motion cross product"
72 Fcross.__doc__ =
"Force cross product"
74 MCross =
lambda V, v: np.bmat([
Mcross(V[:, i], v)
for i
in range(V.shape[1])])
75 FCross =
lambda V, f: np.bmat([
Fcross(V[:, i], f)
for i
in range(V.shape[1])])
79 adj.__doc__ =
"Motion pre-cross product (ie adjoint, lie bracket operator)"
81 adjdual =
lambda nu: np.bmat(
84 adjdual.__doc__ =
"Force pre-cross product adjdual(a) = -adj(a)' "
87 quad =
lambda H, v: np.array(
td(
td(H, v, [2, 0]), v, [1, 0]))
88 quad.__doc__ =
"""Tensor product v'*H*v, with H.shape = [ nop, nv, nv ]"""
92 mformat = lambda x, sarg=sarg, eps=eps: (
93 sarg.format(x)
if abs(x) > eps
else " 0. "
95 np.set_printoptions(formatter={
"float": mformat})