mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-06-01 01:39:32 +00:00
Add tests for animation_lib
This commit is contained in:
51
tests/animation_1.csv
Normal file
51
tests/animation_1.csv
Normal file
@@ -0,0 +1,51 @@
|
||||
basic
|
||||
1,0.0,0.0,0.0,0.0,204,2,0
|
||||
2,0.0,0.0,0.0,0.0,204,9,1
|
||||
3,0.0,0.0,0.0,0.0,204,21,2
|
||||
4,0.0,0.0,0.0,0.0,204,37,3
|
||||
5,0.0,0.0,0.0,0.0,204,56,4
|
||||
6,0.0,0.0,0.0,0.0,204,77,5
|
||||
7,0.0,0.0,0.0,0.0,204,97,6
|
||||
8,0.0,0.0,0.0,0.0,204,116,6
|
||||
9,0.0,0.0,0.0,0.0,204,131,7
|
||||
10,0.0,0.0,0.0,0.0,204,143,7
|
||||
11,0.0,0.0,0.1,0.0,199,153,7
|
||||
12,0.0,0.0,0.2,0.0,185,163,6
|
||||
13,0.0,0.0,0.3,0.0,163,172,6
|
||||
14,0.0,0.0,0.4,0.0,134,181,5
|
||||
15,0.0,0.0,0.5,0.0,102,188,5
|
||||
16,0.0,0.0,0.6,0.0,69,194,4
|
||||
17,0.0,0.0,0.7,0.0,40,199,3
|
||||
18,0.0,0.0,0.8,0.0,18,201,3
|
||||
19,0.0,0.0,0.9,0.0,4,203,2
|
||||
20,0.0,0.0,1.0,0.0,0,204,2
|
||||
21,0.02217,0.0,1.0,0.0,0,204,2
|
||||
22,0.08889,0.0,1.0,0.0,0,204,2
|
||||
23,0.19737,0.0,1.0,0.0,0,204,2
|
||||
24,0.33926,0.0,1.0,0.0,0,204,2
|
||||
25,0.5,0.0,1.0,0.0,0,204,2
|
||||
26,0.66074,0.0,1.0,0.0,0,204,2
|
||||
27,0.80263,0.0,1.0,0.0,0,204,2
|
||||
28,0.91111,0.0,1.0,0.0,0,204,2
|
||||
29,0.97783,0.0,1.0,0.0,0,204,2
|
||||
30,1.0,0.0,1.0,0.0,0,204,2
|
||||
31,1.0,0.0,0.9,0.0,3,204,2
|
||||
32,1.0,0.0,0.8,0.0,14,204,2
|
||||
33,1.0,0.0,0.7,0.0,32,204,2
|
||||
34,1.0,0.0,0.6,0.0,56,204,1
|
||||
35,1.0,0.0,0.5,0.0,84,204,1
|
||||
36,1.0,0.0,0.4,0.0,112,204,0
|
||||
37,1.0,0.0,0.3,0.0,138,204,0
|
||||
38,1.0,0.0,0.2,0.0,159,204,0
|
||||
39,1.0,0.0,0.1,0.0,175,204,0
|
||||
40,1.0,0.0,0.0,0.0,183,204,0
|
||||
41,1.0,0.0,0.0,0.0,188,199,0
|
||||
42,1.0,0.0,0.0,0.0,192,185,0
|
||||
43,1.0,0.0,0.0,0.0,196,163,0
|
||||
44,1.0,0.0,0.0,0.0,199,135,0
|
||||
45,1.0,0.0,0.0,0.0,201,102,0
|
||||
46,1.0,0.0,0.0,0.0,202,69,0
|
||||
47,1.0,0.0,0.0,0.0,203,40,0
|
||||
48,1.0,0.0,0.0,0.0,203,18,0
|
||||
49,1.0,0.0,0.0,0.0,203,5,0
|
||||
50,1.0,0.0,0.0,0.0,204,0,0
|
||||
|
1066
tests/animation_2.csv
Executable file
1066
tests/animation_2.csv
Executable file
File diff suppressed because it is too large
Load Diff
12
tests/animation_3.csv
Normal file
12
tests/animation_3.csv
Normal file
@@ -0,0 +1,12 @@
|
||||
route
|
||||
20,0.0,0.0,1.0,0.0,0,204,2
|
||||
21,0.02217,0.0,1.0,0.0,0,204,2
|
||||
22,0.08889,0.0,1.0,0.0,0,204,2
|
||||
23,0.19737,0.0,1.0,0.0,0,204,2
|
||||
24,0.33926,0.0,1.0,0.0,0,204,2
|
||||
25,0.5,0.0,1.0,0.0,0,204,2
|
||||
26,0.66074,0.0,1.0,0.0,0,204,2
|
||||
27,0.80263,0.0,1.0,0.0,0,204,2
|
||||
28,0.91111,0.0,1.0,0.0,0,204,2
|
||||
29,0.97783,0.0,1.0,0.0,0,204,2
|
||||
30,1.0,0.0,1.0,0.0,0,204,2
|
||||
|
76
tests/animation_test.py
Normal file
76
tests/animation_test.py
Normal file
@@ -0,0 +1,76 @@
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
# Add parent dir to PATH to import config
|
||||
import inspect
|
||||
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
parent_dir = os.path.dirname(current_dir)
|
||||
sys.path.insert(0, parent_dir)
|
||||
sys.path.insert(0, os.path.join(parent_dir,"Drone"))
|
||||
|
||||
from config import ConfigManager
|
||||
|
||||
config_path = 'animation_config/config'
|
||||
spec_path = os.path.join(config_path,'spec')
|
||||
if not os.path.exists(spec_path):
|
||||
try:
|
||||
os.makedirs(spec_path)
|
||||
except OSError:
|
||||
print("Creation of the directory {} failed".format(spec_path))
|
||||
else:
|
||||
print("Successfully created the directory {}".format(spec_path))
|
||||
|
||||
shutil.copy("../Drone/config/spec/configspec_client.ini", spec_path)
|
||||
|
||||
config = ConfigManager()
|
||||
config.load_config_and_spec(os.path.join(config_path,'client.ini'))
|
||||
|
||||
assert config.config_name == "client"
|
||||
|
||||
import animation_lib
|
||||
|
||||
a = animation_lib.Animation(config, "animation_1.csv")
|
||||
|
||||
assert a.id == 'basic'
|
||||
assert a.original_frames[0].get_pos() == [0.,0.,0.]
|
||||
assert a.original_frames[0].get_color() == [204,2,0]
|
||||
assert a.original_frames[0].pose_is_valid()
|
||||
|
||||
# print animation_lib.get_numbers(a.static_begin_frames)
|
||||
# print animation_lib.get_numbers(a.takeoff_frames)
|
||||
# print animation_lib.get_numbers(a.route_frames)
|
||||
# print animation_lib.get_numbers(a.land_frames)
|
||||
# print animation_lib.get_numbers(a.static_end_frames)
|
||||
|
||||
assert animation_lib.get_numbers(a.static_begin_frames) == range(1,11)
|
||||
assert animation_lib.get_numbers(a.takeoff_frames) == range(11,21)
|
||||
assert animation_lib.get_numbers(a.route_frames) == range(21,31)
|
||||
assert animation_lib.get_numbers(a.land_frames) == range(31, 41)
|
||||
assert animation_lib.get_numbers(a.static_end_frames) == range(41, 51)
|
||||
|
||||
a.update_frames(config, "animation_2.csv")
|
||||
|
||||
assert a.id == 'parad'
|
||||
assert a.original_frames[269].get_pos() == [-1.00519,2.65699,0.21]
|
||||
assert a.original_frames[269].get_color() == [7,255,0]
|
||||
assert a.original_frames[269].pose_is_valid()
|
||||
assert animation_lib.get_numbers(a.static_begin_frames) == range(271)
|
||||
assert animation_lib.get_numbers(a.takeoff_frames) == range(271,285)
|
||||
assert animation_lib.get_numbers(a.route_frames) == range(285,1065)
|
||||
assert animation_lib.get_numbers(a.land_frames) == []
|
||||
assert animation_lib.get_numbers(a.static_end_frames) == []
|
||||
|
||||
a.update_frames(config, "animation_3.csv")
|
||||
|
||||
assert a.id == 'route'
|
||||
assert a.original_frames[9].get_pos() == [0.97783,0.0,1.0]
|
||||
assert a.original_frames[9].get_color() == [0,204,2]
|
||||
assert a.original_frames[9].pose_is_valid()
|
||||
assert animation_lib.get_numbers(a.static_begin_frames) == []
|
||||
assert animation_lib.get_numbers(a.takeoff_frames) == []
|
||||
assert animation_lib.get_numbers(a.route_frames) == range(20,31)
|
||||
assert animation_lib.get_numbers(a.land_frames) == []
|
||||
assert animation_lib.get_numbers(a.static_end_frames) == []
|
||||
|
||||
shutil.rmtree('animation_config')
|
||||
Reference in New Issue
Block a user