9 import numpy.linalg
as npl
11 from .
import pinocchio_pywrap_default
as pin
12 from .pinocchio_pywrap_default.rpy
import matrixToRpy, rotate, rpyToMatrix
17 for i
in range(len(L)):
24 return tuple(M.tolist())
26 return tuple(M.tolist()[0])
28 return tuple(M.T.tolist()[0])
42 return np.random.rand(n)
if isinstance(n, int)
else np.random.rand(n[0], n[1])
46 if "np" in a.__class__.__dict__:
48 if "np" in b.__class__.__dict__:
50 if isinstance(a, (np.ndarray, list))
and isinstance(b, (np.ndarray, list)):
51 a = np.squeeze(np.array(a))
52 b = np.squeeze(np.array(b))
53 return np.allclose(a, b, epsilon)
54 return abs(a - b) < epsilon
57 def mprint(M, name="ans", eps=1e-15):
59 Matlab-style pretty matrix print.
61 if isinstance(M, pin.SE3):
64 M = np.expand_dims(M, axis=0)
70 Mm = (abs(M[np.nonzero(M)])).
min()
71 MM = (abs(M[np.nonzero(M)])).
max()
73 fmt =
"% 10.3e" if Mm < 1e-5
or MM > 1e6
or MM / Mm > 1e3
else "% 1.5f"
75 for i
in range((ncol - 1) // NC + 1):
78 cmax = ncol
if ncol < cmax
else cmax
79 print(f
"Columns {cmin} through {cmax - 1}")
81 for r
in range(M.shape[0]):
83 for c
in range(cmin, cmax):
84 if abs(M[r, c]) > eps:
85 sys.stdout.write(fmt % M[r, c] +
" ")
87 sys.stdout.write(
" 0" +
" " * 9)
93 vector = pin.StdVec_StdString()
94 vector.extend(item
for item
in items)
111 "fromListToVectorOfString",