-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathTest.py
68 lines (61 loc) · 2.11 KB
/
Test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import sys
import time
python_path = os.path.abspath('AirSim/PythonClient')
sys.path.append(python_path)
from AirSimClient import *
def test_drone():
client = MultirotorClient()
client.confirmConnection()
client.enableApiControl(True)
client.armDisarm(True)
client.takeoff()
client.moveToPosition(0, 0, -15, 10)
i = 0
while True:
offset = [0.25, 0.25, 0.0]
quad_vel = client.getVelocity()
quad_pos = client.getPosition()
print i
print quad_vel
print quad_pos, "\n\n"
# client.moveByVelocityZ( quad_vel.x_val + offset[0],
# quad_vel.y_val + offset[1],
# -15, 2)
client.moveByVelocity( quad_vel.x_val + offset[0],
quad_vel.y_val + offset[1],
quad_vel.z_val + offset[2],
5)
time.sleep(0.5)
i += 1
def test_car_reset():
from CarConnector import CarConnector
connector = CarConnector()
state = connector.reset()
def test_detection():
from Environment import Environment
env = Environment()
while True:
current_state = env.reset()
time.sleep(1)
def test_get_images_at_positions():
from MultiRotorConnector import MultiRotorConnector
connector = MultiRotorConnector()
_ = connector.get_frame(path='dummy.png')
position = connector.get_position()
x_val = position.x_val
y_val = position.y_val
z_val = position.z_val
print "Initial Positions:", x_val, y_val, z_val
count = 0
for i,z in enumerate([-9, -6, -3, 0, 3, 6, 9]):
for j,x in enumerate([0, 5, -5]):
for k,y in enumerate([0, 5, -5]):
connector.move_to_position([x_val+x, y_val+y, z_val+z])
time.sleep(1)
path = 'TF_ObjectDetection/data/orig_data/' + str(count) + '.png'
count += 1
_ = connector.get_frame(path=path)
print "\tTest Case:", x_val+x, y_val+y, z_val+z, path
if __name__=='__main__':
test_drone()