-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
26 lines (21 loc) · 765 Bytes
/
client.py
File metadata and controls
26 lines (21 loc) · 765 Bytes
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
import airsim
import numpy as np
import msgpackrpc
from utils import Gate
class Simulator(object):
def __init__(self):
self.client = airsim.VehicleClient()
try:
self.client.confirmConnection()
except msgpackrpc.error.TransportError:
raise Exception("Can't connect to Unreal Engine") from None
def get_gates(self, num):
self.gates = []
self.num_gates = num
for i in range(num):
self.gates.append(Gate.from_api(self.client, i))
def track_position_matrix(self):
p = np.zeros((self.num_gates + 1, 3)) # Include the start as end for the track
for i in range(self.num_gates + 1):
p[i, :] = self.gates[i % self.num_gates].pos
return p