mirror of https://github.com/commaai/rednose.git
Add rot_to_euler sympy helper (#46)
* Add rot2quat and quat2euler * Single element helpers * Simplify * Remove trash
This commit is contained in:
parent
66926771e0
commit
05fd60278a
|
@ -55,6 +55,7 @@ def euler2quat(eulers):
|
|||
def euler2rot(eulers):
|
||||
return quat2rot(euler2quat(eulers))
|
||||
|
||||
|
||||
rotations_from_quats = quat2rot
|
||||
|
||||
|
||||
|
@ -66,6 +67,13 @@ def cross(x):
|
|||
return ret
|
||||
|
||||
|
||||
def rot_to_euler(R):
|
||||
gamma = sp.atan2(R[2, 1], R[2, 2])
|
||||
theta = sp.asin(-R[2, 0])
|
||||
psi = sp.atan2(R[1, 0], R[0, 0])
|
||||
return sp.Matrix([gamma, theta, psi])
|
||||
|
||||
|
||||
def rot_matrix(roll, pitch, yaw):
|
||||
cr, sr = np.cos(roll), np.sin(roll)
|
||||
cp, sp = np.cos(pitch), np.sin(pitch)
|
||||
|
|
Loading…
Reference in New Issue