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
8e4d7a01
Commit
8e4d7a01
authored
6 years ago
by
Luise Odenthal
Browse files
Options
Downloads
Patches
Plain Diff
uploaded convention tests for blender, but still not working
parent
29cac28a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
navipy/sensors/blendtest1.py
+158
-0
158 additions, 0 deletions
navipy/sensors/blendtest1.py
with
158 additions
and
0 deletions
navipy/sensors/blendtest1.py
0 → 100644
+
158
−
0
View file @
8e4d7a01
from
navipy.sensors.renderer
import
BlenderRender
from
navipy.maths.euler
import
matrix
,
from_matrix
from
navipy.maths.quaternion
import
from_matrix
as
quat_matrix
import
pandas
as
pd
import
numpy
as
np
import
os
import
sys
import
unittest
class
TestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
i
=
[
np
.
array
([
'
location
'
,
'
location
'
,
'
location
'
,
'
sxyz
'
,
'
sxyz
'
,
'
sxyz
'
]),
np
.
array
([
'
x
'
,
'
y
'
,
'
z
'
,
'
alpha_0
'
,
'
alpha_1
'
,
'
alpha_2
'
])]
self
.
i2
=
[
np
.
array
([
'
location
'
,
'
location
'
,
'
location
'
,
'
syzx
'
,
'
syzx
'
,
'
syzx
'
]),
np
.
array
([
'
x
'
,
'
y
'
,
'
z
'
,
'
alpha_0
'
,
'
alpha_1
'
,
'
alpha_2
'
])]
self
.
image2
=
np
.
zeros
((
4
,
180
,
360
,
4
,
1
))
self
.
posorient2
=
pd
.
Series
(
index
=
self
.
i2
)
self
.
posorient2
.
loc
[
'
location
'
][
'
x
'
]
=
0
self
.
posorient2
.
loc
[
'
location
'
][
'
y
'
]
=
0
self
.
posorient2
.
loc
[
'
location
'
][
'
z
'
]
=
0
self
.
posorient2
.
loc
[
'
syzx
'
][
'
alpha_0
'
]
=
0
self
.
posorient2
.
loc
[
'
syzx
'
][
'
alpha_1
'
]
=
0
self
.
posorient2
.
loc
[
'
syzx
'
][
'
alpha_2
'
]
=
0
self
.
a
=
1
self
.
b
=
0.75
self
.
c
=
0.5
self
.
posorient
=
pd
.
Series
(
index
=
self
.
i
)
self
.
posorient
.
loc
[
'
location
'
][
'
x
'
]
=
0
self
.
posorient
.
loc
[
'
location
'
][
'
y
'
]
=
0
self
.
posorient
.
loc
[
'
location
'
][
'
z
'
]
=
0
self
.
posorient
.
loc
[
'
sxyz
'
][
'
alpha_0
'
]
=
self
.
a
self
.
posorient
.
loc
[
'
sxyz
'
][
'
alpha_1
'
]
=
self
.
b
self
.
posorient
.
loc
[
'
sxyz
'
][
'
alpha_2
'
]
=
self
.
c
def
test_diff_euler_xyz2yzx
(
self
):
# print("euler test")
logfile
=
'
blender_render.log
'
open
(
logfile
,
'
a
'
).
close
()
old
=
os
.
dup
(
1
)
sys
.
stdout
.
flush
()
os
.
close
(
1
)
os
.
open
(
logfile
,
os
.
O_WRONLY
)
renderer
=
BlenderRender
()
renderer2
=
BlenderRender
()
mat1
=
matrix
(
self
.
a
,
self
.
b
,
self
.
c
,
axes
=
'
sxyz
'
)
a1
,
a2
,
a3
=
from_matrix
(
mat1
,
axes
=
'
sxyz
'
)
at
,
bt
,
ct
=
from_matrix
(
mat1
,
axes
=
'
syzx
'
)
self
.
posorient2
.
loc
[
'
syzx
'
][
'
alpha_0
'
]
=
at
self
.
posorient2
.
loc
[
'
syzx
'
][
'
alpha_1
'
]
=
bt
self
.
posorient2
.
loc
[
'
syzx
'
][
'
alpha_2
'
]
=
ct
# renderer.camera_rotation_mode = 'YZX'
# print("poorient ### ",self.posorient2.loc[['syzx'],
# ['alpha_0', 'alpha_1', 'alpha_2']].values)
self
.
image2
[
0
]
=
renderer2
.
scene
(
self
.
posorient2
)
# conv = renderer2.camera_rotation_mode
# self.posorient.loc['sxyz']['alpha_0'] = a
# self.posorient.loc['sxyz']['alpha_1'] = b
# self.posorient.loc['sxyz']['alpha_2'] = c
# print("poorient ### ",posorient.loc[['sxyz'],
# ['alpha_0', 'alpha_1', 'alpha_2']].values)
# renderer.camera_rotation_mode = 'XYZ'
self
.
image2
[
1
]
=
renderer
.
scene
(
self
.
posorient
)
# disable output redirection
os
.
close
(
1
)
os
.
dup
(
old
)
os
.
close
(
old
)
# print("first image")
# print(self.image[0,:,0,0] - self.image[1,:,0,0])
# print("second image")
# print(self.image[1,:,0,0])
# conv2= renderer.camera_rotation_mode
# print("angels xyz",a1,a2,a3,"angles yzx",at,bt,ct)
# print("sh be yzx",conv,"sh be xyz",conv2)
# print(np.sum(np.abs(image2[0,:,:,0]-image2[1,:,:,0])))
# print("max diff ",np.max(np.abs(self.image2[0]-self.image2[1])))
# assert np.testing,assert_allclose(self.image[0],
# self.image[1], atol = 0.007)
def
test_euler_xyz_2_quaternion
(
self
):
# print("quaternion test")
logfile
=
'
blender_render.log
'
open
(
logfile
,
'
a
'
).
close
()
old
=
os
.
dup
(
1
)
sys
.
stdout
.
flush
()
os
.
close
(
1
)
os
.
open
(
logfile
,
os
.
O_WRONLY
)
i2
=
[
np
.
array
([
'
location
'
,
'
location
'
,
'
location
'
,
'
quaternion
'
,
'
quaternion
'
,
'
quaternion
'
,
'
quaternion
'
]),
np
.
array
([
'
x
'
,
'
y
'
,
'
z
'
,
'
q_0
'
,
'
q_1
'
,
'
q_2
'
,
'
q_3
'
])]
renderer
=
BlenderRender
()
renderer2
=
BlenderRender
()
mat1
=
matrix
(
self
.
a
,
self
.
b
,
self
.
c
,
axes
=
'
sxyz
'
)
at
,
bt
,
ct
,
dt
=
quat_matrix
(
mat1
)
posorient2
=
pd
.
Series
(
index
=
i2
)
posorient2
.
loc
[
'
location
'
][
'
x
'
]
=
0
posorient2
.
loc
[
'
location
'
][
'
y
'
]
=
0
posorient2
.
loc
[
'
location
'
][
'
z
'
]
=
0
posorient2
.
loc
[
'
quaternion
'
][
'
q_0
'
]
=
at
posorient2
.
loc
[
'
quaternion
'
][
'
q_1
'
]
=
bt
posorient2
.
loc
[
'
quaternion
'
][
'
q_2
'
]
=
ct
posorient2
.
loc
[
'
quaternion
'
][
'
q_3
'
]
=
dt
# renderer.camera_rotation_mode = 'YZX'
# print("poorient ### ",posorient2.loc[['quternion'],
# ['q_0', 'q_1',
# 'q_2', 'q_3']].values)
self
.
image2
[
2
]
=
renderer2
.
scene
(
posorient2
)
# conv = renderer2.camera_rotation_mode
# self.posorient = pd.Series(index=self.i)
# self.posorient.loc['sxyz']['alpha_0'] = a
# self.posorient.loc['sxyz']['alpha_1'] = b
# self.posorient.loc['sxyz']['alpha_2'] = c
# print("poorient ### ",self.posorient.loc[['sxyz'],
# ['alpha_0', 'alpha_1', 'alpha_2']].values)
# renderer.camera_rotation_mode = 'XYZ'
self
.
image2
[
3
]
=
renderer
.
scene
(
self
.
posorient
)
# disable output redirection
os
.
close
(
1
)
os
.
dup
(
old
)
os
.
close
(
old
)
# print(self.image2[2,:,0,0] - self.image2[3,:,0,0])
# print("max diff ",np.max(np.abs(self.image2[2]-self.image2[3])))
# print("alternative");
# indices = np.where(np.abs(self.image2[0,:,:,0] -
# self.image2[1,:,:,0])
# ==np.max(np.abs(self.image2[0,:,:,0]
# - self.image2[1,:,:,0])))
# print("indices", indices)
# print("first image")
# print(self.image[0,0,:,0])
# print("second image")
# print(self.image[1,0,:,0])
# conv2= renderer.camera_rotation_mode
# print("angels xyz",a,b,c,"angles yzx",at,bt,ct)
# print("sh be yzx",conv,"sh be xyz",conv2)
# print(np.sum(np.abs(self.image[0,:,:,0]-self.image[1,:,:,0])))
# print(np.all(np.isclose(self.image[0], self.image[1])))
# assert np.testing.assert_allclose(self.image[0],
# self.image[1], atol = 0.007)
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