5 from __future__
import print_function, division
10 import numpy.linalg
as npl
12 from .
import pinocchio_pywrap
as pin
13 from .pinocchio_pywrap.rpy
import matrixToRpy, rpyToMatrix, rotate
15 from .deprecation
import deprecated
19 for i
in range(len(L)):
25 return tuple(M.tolist())
27 return tuple(M.tolist()[0])
29 return tuple(M.T.tolist()[0])
40 return np.random.rand(n)
if isinstance(n, int)
else np.random.rand(n[0], n[1])
42 @
deprecated(
"Please use numpy.cross(a, b) or numpy.cross(a, b, axis=0).")
44 return np.cross(a, b, axis=0)
46 @
deprecated(
'Now useless. You can directly have access to this function from the main scope of Pinocchio')
50 @
deprecated(
'Now useless. You can directly have access to this function from the main scope of Pinocchio')
52 return pin.SE3ToXYZQUATtuple(M)
54 @
deprecated(
'Now useless. You can directly have access to this function from the main scope of Pinocchio')
56 return pin.XYZQUATToSE3(vec)
59 if "np" in a.__class__.__dict__:
61 if "np" in b.__class__.__dict__:
63 if isinstance(a, (np.ndarray, list))
and isinstance(b, (np.ndarray, list)):
64 a = np.squeeze(np.array(a))
65 b = np.squeeze(np.array(b))
66 return np.allclose(a, b, epsilon)
67 return abs(a - b) < epsilon
72 Matlab-style pretty matrix print. 74 if isinstance(M, pin.SE3):
77 M = np.expand_dims(M, axis=0)
83 Mmin =
lambda M: M.min()
84 Mmax =
lambda M: M.max()
85 Mm = Mmin(abs(M[np.nonzero(M)]))
86 MM = Mmax(abs(M[np.nonzero(M)]))
88 fmt =
"% 10.3e" if Mm < 1e-5
or MM > 1e6
or MM / Mm > 1e3
else "% 1.5f" 90 for i
in range((ncol - 1) // NC + 1):
93 cmax = ncol
if ncol < cmax
else cmax
94 print(
"Columns %s through %s" % (cmin, cmax - 1))
96 for r
in range(M.shape[0]):
98 for c
in range(cmin, cmax):
99 if abs(M[r,c])>eps: sys.stdout.write(fmt % M[r,c] +
" ")
100 else: sys.stdout.write(
" 0"+
" "*9)
106 vector = pin.StdVec_StdString()
107 vector.extend(item
for item
in items)
111 __all__ = [
'np',
'npl',
'eye',
'zero',
'rand',
'isapprox',
'mprint',
113 'npToTTuple',
'npToTuple',
'rotate',
114 'rpyToMatrix',
'matrixToRpy',
115 'se3ToXYZQUAT',
'XYZQUATToSe3',
116 'fromListToVectorOfString']
def fromListToVectorOfString(items)
def deprecated(instructions)
def mprint(M, name="ans", eps=1e-15)
def isapprox(a, b, epsilon=1e-6)