Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
navipy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olivier Bertrand
navipy
Commits
491ae3da
Commit
491ae3da
authored
6 years ago
by
Luise Odenthal
Browse files
Options
Downloads
Patches
Plain Diff
repaired some text
parent
cc7e1161
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
navipy/maths/new_euler.py
+9
-9
9 additions, 9 deletions
navipy/maths/new_euler.py
navipy/maths/test_euler.py
+28
-28
28 additions, 28 deletions
navipy/maths/test_euler.py
with
37 additions
and
37 deletions
navipy/maths/new_euler.py
+
9
−
9
View file @
491ae3da
...
...
@@ -45,7 +45,7 @@ def R3(a):
def
rotation_matrix
(
ai
,
aj
,
ak
,
axes
=
'
rxyz
'
):
if
axes
not
in
list
(
_AXES2TUPLE
.
keys
()):
raise
Exception
(
"
the chosen convention is not supported
"
)
raise
ValueError
(
"
the chosen convention is not supported
"
)
r
,
i
,
j
,
k
=
_AXES2TUPLE
[
axes
]
matrixes
=
[
R1
,
R2
,
R3
]
Rijk
=
np
.
dot
(
matrixes
[
i
](
ai
),
...
...
@@ -57,7 +57,7 @@ def rotation_matrix(ai, aj, ak, axes='rxyz'):
return
np
.
transpose
(
Rijk
)
def
from_matrix
_new
(
matrix
,
axes
=
'
sxyz
'
):
def
from_matrix
(
matrix
,
axes
=
'
sxyz
'
):
"""
Return Euler angles from rotation matrix for specified axis sequence.
axes : One of 24 axis sequences as string or encoded tuple
...
...
@@ -67,7 +67,7 @@ def from_matrix_new(matrix, axes='sxyz'):
if
not
isinstance
(
matrix
,
np
.
ndarray
)
and
not
isinstance
(
matrix
,
list
):
raise
TypeError
(
"
matrix must be np.array or list
"
)
if
axes
not
in
list
(
_AXES2TUPLE
.
keys
()):
raise
Exception
(
"
the chosen convention is not supported
"
)
raise
ValueError
(
"
the chosen convention is not supported
"
)
# if np.any(np.isnan(np.array(matrix, dtype=np.float64))):
# raise ValueError('posorient must not contain nan')
if
not
is_numeric_array
(
matrix
):
...
...
@@ -143,11 +143,11 @@ def from_quaternion(quaternion, axes='sxyz'):
# if np.any(np.isnan(np.array(quaternion, dtype=np.float64))):
# raise ValueError('posorient must not contain nan')
if
axes
not
in
list
(
_AXES2TUPLE
.
keys
()):
raise
Exception
(
"
the chosen convention is not supported
"
)
return
from_matrix
_new
(
quat
.
matrix
(
quaternion
),
axes
)
raise
ValueError
(
"
the chosen convention is not supported
"
)
return
from_matrix
(
quat
.
matrix
(
quaternion
),
axes
)
def
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
axes
=
'
rxyz
'
):
def
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
axes
=
'
rxyz
'
):
"""
Return the Euler Angle Rates Matrix
...
...
@@ -165,7 +165,7 @@ def angular_rate_matrix(ai, aj, ak, axes='rxyz'):
# np.isnan(np.array([ak], dtype=np.float64)):
# raise ValueError("quaternions must not be nan or none")
if
axes
not
in
list
(
_AXES2TUPLE
.
keys
()):
raise
Exception
(
"
the chosen convention is not supported
"
)
raise
ValueError
(
"
the chosen convention is not supported
"
)
s
,
i
,
j
,
k
=
_AXES2TUPLE
[
axes
]
ei
=
np
.
zeros
(
3
)
ej
=
np
.
zeros
(
3
)
...
...
@@ -216,7 +216,7 @@ def angular_velocity(ai, aj, ak, dai, daj, dak, axes='rxyz'):
# np.isnan(np.array([dak], dtype=np.float64)):
# raise ValueError("quaternions must not be nan or none")
if
axes
not
in
list
(
_AXES2TUPLE
.
keys
()):
raise
Exception
(
"
the chosen convention is not supported
"
)
rotM
=
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
axes
)
raise
ValueError
(
"
the chosen convention is not supported
"
)
rotM
=
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
axes
)
vel
=
np
.
dot
(
rotM
,
[
dai
,
daj
,
dak
])
return
vel
This diff is collapsed.
Click to expand it.
navipy/maths/test_euler.py
+
28
−
28
View file @
491ae3da
...
...
@@ -4,11 +4,11 @@ import navipy.maths.new_euler as new_euler
# import navipy.maths.constants as constants
import
unittest
# from navipy.maths.euler import matrix
from
navipy.maths.new_euler
import
ang
ular
_rate_matrix
from
navipy.maths.new_euler
import
ang
le
_rate_matrix
from
navipy.maths.new_euler
import
angular_velocity
from
navipy.maths.new_euler
import
rotation_matrix
from
navipy.maths.new_euler
import
R1
,
R2
,
R3
# from navipy.maths.euler import angle_rate_matrix as old_ang
ular
_rate_matrix
# from navipy.maths.euler import angle_rate_matrix as old_ang
le
_rate_matrix
# from navipy.maths.euler import angular_velocity as old_angular_velocity
# from navipy.maths.euler import matrix as old_rotation_matrix
...
...
@@ -146,7 +146,7 @@ class TestEuler(unittest.TestCase):
# print("key", key)
rotation_0
=
new_euler
.
rotation_matrix
(
1
,
2
,
3
,
key
)
# print("roation_0", rotation_0)
[
ai
,
aj
,
ak
]
=
new_euler
.
from_matrix
_new
(
rotation_0
,
key
)
[
ai
,
aj
,
ak
]
=
new_euler
.
from_matrix
(
rotation_0
,
key
)
# print("res", ai, aj, ak)
rotation_1
=
new_euler
.
rotation_matrix
(
ai
,
aj
,
ak
,
key
)
condition
[
key
]
=
np
.
allclose
(
rotation_0
,
...
...
@@ -261,7 +261,7 @@ class TestEuler(unittest.TestCase):
print
(
"
between key
"
,
key
)
rotation_0
=
new_euler
.
rotation_matrix
(
1
,
2
,
3
,
refkey
)
print
(
"
betewwen matrix
"
,
rotation_0
)
[
ai
,
aj
,
ak
]
=
new_euler
.
from_matrix
_new
(
rotation_0
,
key
)
[
ai
,
aj
,
ak
]
=
new_euler
.
from_matrix
(
rotation_0
,
key
)
print
(
"
between
"
,
ai
,
aj
,
ak
)
rotation_1
=
new_euler
.
rotation_matrix
(
ai
,
aj
,
ak
,
key
)
condition
[
key
]
=
np
.
allclose
(
rotation_0
,
...
...
@@ -275,8 +275,8 @@ class TestEuler(unittest.TestCase):
self
.
assertTrue
(
np
.
allclose
(
angles
,
[
0.123
,
0
,
0
]))
def
test_from_quaternion_params
(
self
):
for
a
,
b
,
c
,
d
in
[(
None
,
2
,
6
,
8
),
(
9.0
,
'
w
'
,
2
,
3
),
(
5.0
,
4.0
,
None
,
8.0
),
for
a
,
b
,
c
,
d
in
[(
None
,
2
,
6
,
'
rxyz
'
),
(
9.0
,
'
w
'
,
2
,
'
rxyz
'
),
(
5.0
,
4.0
,
None
,
'
rxyz
'
),
(
1.0
,
2.0
,
3.0
,
'
w
'
)]:
with
self
.
assertRaises
(
ValueError
):
new_euler
.
from_quaternion
([
a
,
b
,
c
,
d
])
...
...
@@ -311,9 +311,9 @@ class TestEuler(unittest.TestCase):
with
self
.
assertRaises
(
TypeError
):
new_euler
.
angle_rate_matrix
(
a
,
b
,
c
,
d
)
for
a
,
b
,
c
,
d
in
[(
9.0
,
np
.
nan
,
2
,
3
)]:
with
self
.
assertRaises
(
ValueError
):
new_euler
.
angle_rate_matrix
(
a
,
b
,
c
,
d
)
#
for a, b, c, d in [(9.0, np.nan, 2,
'rxyz'
)]:
#
with self.assertRaises(ValueError):
#
new_euler.angle_rate_matrix(a, b, c, d)
with
self
.
assertRaises
(
Exception
):
new_euler
.
angle_rate_matrix
(
9.0
,
8.0
,
7.0
,
'
w
'
)
...
...
@@ -437,8 +437,8 @@ class TestEuler(unittest.TestCase):
# dak = 0
Rijk_r
=
rotation_matrix
(
ai
,
aj
,
ak
,
'
rxyz
'
)
Rijk
=
rotation_matrix
(
ai
,
aj
,
ak
,
'
sxyz
'
)
E_p
=
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
'
rxyz
'
)
E
=
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
'
sxyz
'
)
E_p
=
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
'
rxyz
'
)
E
=
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
'
sxyz
'
)
E_inv
=
np
.
linalg
.
inv
(
E
)
newR
=
np
.
dot
(
E_p
,
E_inv
)
self
.
assertTrue
(
np
.
allclose
(
Rijk
,
newR
))
...
...
@@ -456,8 +456,8 @@ class TestEuler(unittest.TestCase):
# dai = 0
# daj = 0
# dak = 1
E_p
=
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
'
rzxz
'
)
E
=
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
'
szxz
'
)
E_p
=
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
'
rzxz
'
)
E
=
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
'
szxz
'
)
testE
=
[[
np
.
sin
(
aj
)
*
np
.
sin
(
ak
),
np
.
cos
(
ak
),
0
],
[
-
np
.
sin
(
aj
)
*
np
.
cos
(
ak
),
np
.
sin
(
ak
),
0
],
[
np
.
cos
(
aj
),
0
,
1
]]
...
...
@@ -482,8 +482,8 @@ class TestEuler(unittest.TestCase):
E_p
=
[[
0
,
np
.
cos
(
ai
),
np
.
sin
(
aj
)
*
np
.
sin
(
ai
)],
[
0
,
-
np
.
sin
(
ai
),
np
.
sin
(
aj
)
*
np
.
cos
(
ai
)],
[
1
,
0
,
np
.
cos
(
aj
)]]
E_fkt
=
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
'
szxz
'
)
E_p_fkt
=
ang
ular
_rate_matrix
(
ai
,
aj
,
ak
,
'
rzxz
'
)
E_fkt
=
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
'
szxz
'
)
E_p_fkt
=
ang
le
_rate_matrix
(
ai
,
aj
,
ak
,
'
rzxz
'
)
self
.
assertTrue
(
np
.
allclose
(
E
,
E_fkt
))
self
.
assertTrue
(
np
.
allclose
(
E_p
,
E_p_fkt
))
w
=
np
.
dot
(
E
,
[
dai
,
daj
,
dak
])
...
...
@@ -541,7 +541,7 @@ class TestEuler(unittest.TestCase):
self.assertTrue(np.allclose([100, 0, 0], vel_p, 0.1))
"""
def
test_ang
ular
_rate
(
self
):
def
test_ang
le
_rate
(
self
):
ea
=
0.1
eb
=
0.15
ec
=
0.7
...
...
@@ -558,7 +558,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MR3
,
np
.
dot
(
MR2
,
e1
))
p2
=
np
.
dot
(
MR3
,
e2
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e3
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxyz
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxyz
'
)
self
.
assertTrue
(
np
.
all
(
rotM
==
M
))
# ryzx
...
...
@@ -570,7 +570,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e2
))
p2
=
np
.
dot
(
MRk
,
e3
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e1
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
syzx
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
syzx
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# ryxz
...
...
@@ -582,7 +582,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e2
))
p2
=
np
.
dot
(
MRk
,
e1
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e3
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
syxz
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
syxz
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# rxzy
...
...
@@ -594,7 +594,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e1
))
p2
=
np
.
dot
(
MRk
,
e3
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e2
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxzy
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxzy
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# rzxy
...
...
@@ -606,7 +606,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e3
))
p2
=
np
.
dot
(
MRk
,
e1
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e2
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
szxy
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
szxy
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# rxzx
...
...
@@ -618,7 +618,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e1
))
p2
=
np
.
dot
(
MRk
,
e3
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e1
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxzx
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxzx
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# rzxz
...
...
@@ -639,8 +639,8 @@ class TestEuler(unittest.TestCase):
# -s(ea)*s(ec)+c(ea)*c(eb)*c(ec),
# c(ea)*s(eb)],
# [s(eb)*s(ec), -s(eb)*c(ec), c(eb)]]
# mfunc = ang
ular
_rate_matrix(ea, eb, ec, 'szxz')
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
szxz
'
)
# mfunc = ang
le
_rate_matrix(ea, eb, ec, 'szxz')
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
szxz
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# rxyx
...
...
@@ -652,7 +652,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e1
))
p2
=
np
.
dot
(
MRk
,
e2
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e1
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxyx
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
sxyx
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# ryxy
...
...
@@ -664,7 +664,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e2
))
p2
=
np
.
dot
(
MRk
,
e1
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e2
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
syxy
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
syxy
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# ryzy
...
...
@@ -676,7 +676,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e2
))
p2
=
np
.
dot
(
MRk
,
e3
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e2
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
syzy
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
syzy
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
# rzyz
...
...
@@ -688,7 +688,7 @@ class TestEuler(unittest.TestCase):
p1
=
np
.
dot
(
MRk
,
np
.
dot
(
MRj
,
e3
))
p2
=
np
.
dot
(
MRk
,
e2
)
rotM
=
np
.
column_stack
([
p1
,
p2
,
e3
])
M
=
ang
ular
_rate_matrix
(
ea
,
eb
,
ec
,
'
szyz
'
)
M
=
ang
le
_rate_matrix
(
ea
,
eb
,
ec
,
'
szyz
'
)
self
.
assertTrue
(
np
.
allclose
(
rotM
,
M
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment