forked from microsoft/AirSim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcar_monitor.py
More file actions
26 lines (21 loc) · 826 Bytes
/
Copy pathcar_monitor.py
File metadata and controls
26 lines (21 loc) · 826 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 setup_path
import airsim
import cv2 #conda install opencv
import time
# connect to the AirSim simulator
client = airsim.CarClient()
client.confirmConnection()
car_controls = airsim.CarControls()
start = time.time()
print("Time,Speed,Gear,PX,PY,PZ,OW,OX,OY,OZ")
# monitor car state while you drive it manually.
while (cv2.waitKey(1) & 0xFF) == 0xFF:
# get state of the car
car_state = client.getCarState()
pos = car_state.kinematics_estimated.position
orientation = car_state.kinematics_estimated.orientation
milliseconds = (time.time() - start) * 1000
print("%s,%d,%d,%f,%f,%f,%f,%f,%f,%f" % \
(milliseconds, car_state.speed, car_state.gear, pos.x_val, pos.y_val, pos.z_val,
orientation.w_val, orientation.x_val, orientation.y_val, orientation.z_val))
time.sleep(0.1)