5 from __future__
import print_function
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])
34 if pin.getNumpyType()==np.matrix:
40 if pin.getNumpyType()==np.matrix:
41 return np.matrix(np.zeros([n, 1]
if isinstance(n, int)
else n))
46 if pin.getNumpyType()==np.matrix:
47 return np.matrix(np.random.rand(n, 1)
if isinstance(n, int)
else np.random.rand(n[0], n[1]))
49 return np.random.rand(n)
if isinstance(n, int)
else np.random.rand(n[0], n[1])
51 @
deprecated(
"Please use numpy.cross(a, b) or numpy.cross(a, b, axis=0).")
53 return np.matrix(np.cross(a, b, axis=0))
55 @
deprecated(
'Now useless. You can directly have access to this function from the main scope of Pinocchio')
59 @
deprecated(
'Now useless. You can directly have access to this function from the main scope of Pinocchio')
61 return pin.SE3ToXYZQUATtuple(M)
63 @
deprecated(
'Now useless. You can directly have access to this function from the main scope of Pinocchio')
65 return pin.XYZQUATToSE3(vec)
68 if "np" in a.__class__.__dict__:
70 if "np" in b.__class__.__dict__:
72 if isinstance(a, (np.ndarray, list))
and isinstance(b, (np.ndarray, list)):
73 a = np.squeeze(np.array(a))
74 b = np.squeeze(np.array(b))
75 return np.allclose(a, b, epsilon)
76 return abs(a - b) < epsilon
81 Matlab-style pretty matrix print. 83 if isinstance(M, pin.SE3):
86 M = np.expand_dims(M, axis=0)
92 Mmin =
lambda M: M.min()
93 Mmax =
lambda M: M.max()
94 Mm = Mmin(abs(M[np.nonzero(M)]))
95 MM = Mmax(abs(M[np.nonzero(M)]))
97 fmt =
"% 10.3e" if Mm < 1e-5
or MM > 1e6
or MM / Mm > 1e3
else "% 1.5f" 99 for i
in range((ncol - 1) / NC + 1):
102 cmax = ncol
if ncol < cmax
else cmax
103 print(
"Columns %s through %s" % (cmin, cmax - 1))
105 for r
in range(M.shape[0]):
106 sys.stdout.write(
" ")
107 for c
in range(cmin, cmax):
108 if abs(M[r,c])>eps: sys.stdout.write(fmt % M[r,c] +
" ")
109 else: sys.stdout.write(
" 0"+
" "*9)
115 vector = pin.StdVec_StdString()
116 vector.extend(item
for item
in items)
120 __all__ = [
'np',
'npl',
'eye',
'zero',
'rand',
'isapprox',
'mprint',
122 'npToTTuple',
'npToTuple',
'rotate',
123 'rpyToMatrix',
'matrixToRpy',
124 'se3ToXYZQUAT',
'XYZQUATToSe3',
125 'fromListToVectorOfString']
def fromListToVectorOfString(items)
def deprecated(instructions)
def mprint(M, name="ans", eps=1e-15)
def isapprox(a, b, epsilon=1e-6)