Skip to content

Commit f67edac

Browse files
committed
normalize quaternion before converting to euler
1 parent 27bc266 commit f67edac

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

api/parsers/ulgparser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ def __init__(self):
1414
self.initEntities()
1515

1616
def euler_from_quaternion(self, w, x, y, z):
17-
angles = {}
17+
norm = math.sqrt(w*w + x*x + y*y + z*z)
18+
w, x, y, z = w / norm, x / norm, y / norm, z / norm
1819

20+
angles = {}
1921
#roll(x-axis rotation)
2022
sinr_cosp = 2 * (w * x + y * z)
2123
cosr_cosp = 1 - 2 * (x * x + y * y)
@@ -30,9 +32,10 @@ def euler_from_quaternion(self, w, x, y, z):
3032
siny_cosp = 2 * (w * z + x * y)
3133
cosy_cosp = 1 - 2 * (y * y + z * z)
3234
angles['yaw'] = math.atan2(siny_cosp, cosy_cosp)
33-
3435
return angles
3536

37+
38+
3639
def add_euler(self,datadict):
3740
if "vehicle_attitude" in datadict:
3841
a=datadict['vehicle_attitude']

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tiplot",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"private": true,
55
"homepage": "./",
66
"proxy": "http://localhost:5000",

0 commit comments

Comments
 (0)