-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVictim_GPS_Groundtruth.py
62 lines (52 loc) · 1.74 KB
/
Victim_GPS_Groundtruth.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
#Version = 1.0
#Author = [email protected]
#import lib
import airsim
import math
from math import pi
import cv2
import os
import sys
import tempfile
from airsim import MultirotorClient
import numpy as np
with open('GPS_groundtruth.csv', 'w') as f:
client = airsim.MultirotorClient()
client.confirmConnection()
client.enableApiControl(True)
client.armDisarm(True)
landed = client.getMultirotorState().landed_state
if landed == airsim.LandedState.Landed:
print("taking off...")
client.takeoffAsync().join()
else:
print("already flying...")
client.hoverAsync().join()
#victim1
client.moveToPositionAsync(-90, 0, -5, 4).join()
client.hoverAsync().join()
state = client.getMultirotorState()
f.write(str(state.gps_location.latitude) + "," + str(state.gps_location.longitude) + '\n')
#victim2
client.moveToPositionAsync(10, -100, -5, 5).join()
client.hoverAsync().join()
state = client.getMultirotorState()
f.write(str(state.gps_location.latitude) + "," + str(state.gps_location.longitude) + '\n')
#victim3
client.moveToPositionAsync(110, 0, -5, 5).join()
client.hoverAsync().join()
state = client.getMultirotorState()
f.write(str(state.gps_location.latitude) + "," + str(state.gps_location.longitude) + '\n')
#victim4
client.moveToPositionAsync(10, 100, -5, 5).join()
client.hoverAsync().join()
state = client.getMultirotorState()
client.hoverAsync().join()
client.hoverAsync().join()
client.hoverAsync().join()
f.write(str(state.gps_location.latitude) + "," + str(state.gps_location.longitude) + '\n')
#Landing
print("landing...")
client.landAsync().join()
print("disarming.")
client.armDisarm(False)