__init__.py
Go to the documentation of this file.
1 import numpy as np
2 from numpy import cos, sin, sqrt
3 
4 from .dynamic import DynamicPinocchio # noqa
5 
6 
7 def fromSotToPinocchio(q_sot, freeflyer=True):
8  if freeflyer:
9  [r, p, y] = q_sot[3:6]
10  cr = cos(r)
11  cp = cos(p)
12  cy = cos(y)
13  sr = sin(r)
14  sp = sin(p)
15  sy = sin(y)
16 
17  rotmat = np.matrix(
18  [
19  [cy * cp, cy * sp * sr - sy * cr, cy * sp * cr + sy * sr],
20  [sy * cp, sy * sp * sr + cy * cr, sy * sp * cr - cy * sr],
21  [-sp, cp * sr, cp * cr],
22  ]
23  )
24 
25  d0 = rotmat[0, 0]
26  d1 = rotmat[1, 1]
27  d2 = rotmat[2, 2]
28  rr = 1.0 + d0 + d1 + d2
29 
30  if rr > 0:
31  s = 0.5 / sqrt(rr)
32  _x = (rotmat[2, 1] - rotmat[1, 2]) * s
33  _y = (rotmat[0, 2] - rotmat[2, 0]) * s
34  _z = (rotmat[1, 0] - rotmat[0, 1]) * s
35  _r = 0.25 / s
36  else:
37  # Trace is less than zero, so need to determine which
38  # major diagonal is largest
39  if (d0 > d1) and (d0 > d2):
40  s = 0.5 / sqrt(1 + d0 - d1 - d2)
41  _x = 0.5 * s
42  _y = (rotmat[0, 1] + rotmat[1, 0]) * s
43  _z = (rotmat[0, 2] + rotmat[2, 0]) * s
44  _r = (rotmat[1, 2] + rotmat[2, 1]) * s
45  elif d1 > d2:
46  s = 0.5 / sqrt(1 + d0 - d1 - d2)
47  _x = (rotmat[0, 1] + rotmat[1, 0]) * s
48  _y = 0.5 * s
49  _z = (rotmat[1, 2] + rotmat[2, 1]) * s
50  _r = (rotmat[0, 2] + rotmat[2, 0]) * s
51  else:
52  s = 0.5 / sqrt(1 + d0 - d1 - d2)
53  _x = (rotmat[0, 2] + rotmat[2, 0]) * s
54  _y = (rotmat[1, 2] + rotmat[2, 1]) * s
55  _z = 0.5 * s
56  _r = (rotmat[0, 1] + rotmat[1, 0]) * s
57 
58  return np.matrix([q_sot[0:3] + (_x, _y, _z, _r) + q_sot[6:]])
59  else:
60  return np.matrix([q_sot[0:]])
dynamic_pinocchio.fromSotToPinocchio
def fromSotToPinocchio(q_sot, freeflyer=True)
Definition: __init__.py:7


sot-dynamic-pinocchio
Author(s): Olivier Stasse
autogenerated on Fri Jul 28 2023 02:10:01