Skip to content

Commit 84d1120

Browse files
committed
Fix RPY
1 parent 54263ee commit 84d1120

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

api/parsers/ulgparser.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@ def euler_from_quaternion(self, w, x, y, z):
1616
angles = {}
1717

1818
#roll(x-axis rotation)
19-
sinr_cosp = 2 * (w * x + y * z);
20-
cosr_cosp = 1 - 2 * (x * x + y * y);
21-
angles['roll'] = math.atan2(sinr_cosp, cosr_cosp);
19+
sinr_cosp = 2 * (w * x + y * z)
20+
cosr_cosp = 1 - 2 * (x * x + y * y)
21+
angles['roll'] = math.atan2(sinr_cosp, cosr_cosp)
2222

2323
#pitch (y-axis rotation)
24-
sinp = 2 * (w * y - z * x);
25-
if (abs(sinp) >= 1):
26-
angles['pitch'] = math.copysign(math.pi / 2, sinp); # use 90 degrees if out of range
27-
else:
28-
angles['pitch'] = math.asin(sinp);
24+
sinp = math.sqrt(1+2*(w*y - x*z))
25+
cosp = math.sqrt(1-2*(w*y - x*z))
26+
angles['pitch'] = 2*math.atan2(sinp,cosp) - math.pi/2
2927

3028
# yaw (z-axis rotation)
31-
siny_cosp = 2 * (w * z + x * y);
32-
cosy_cosp = 1 - 2 * (y * y + z * z);
33-
angles['yaw'] = math.atan2(siny_cosp, cosy_cosp);
29+
siny_cosp = 2 * (w * z + x * y)
30+
cosy_cosp = 1 - 2 * (y * y + z * z)
31+
angles['yaw'] = math.atan2(siny_cosp, cosy_cosp)
3432

3533
return angles
3634

0 commit comments

Comments
 (0)