forked from microsoft/AirSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
car_stress_test.py
48 lines (37 loc) · 1.25 KB
/
car_stress_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
from AirSimClient import *
# connect to the AirSim simulator
client = CarClient()
client.confirmConnection()
client.enableApiControl(True)
car_controls = CarControls()
for idx in xrange(3000):
# get state of the car
car_state = client.getCarState()
print("Speed %d, Gear %d" % (car_state.speed, car_state.gear))
# go forward
car_controls.throttle = 0.5
car_controls.steering = 0
client.setCarControls(car_controls)
time.sleep(0.1) # let car drive a bit
# Go forward + steer right
car_controls.throttle = 0.5
car_controls.steering = 1
client.setCarControls(car_controls)
time.sleep(0.1) # let car drive a bit
# go reverse
car_controls.throttle = -0.5
car_controls.is_manual_gear = True;
car_controls.manual_gear = -1
car_controls.steering = 0
client.setCarControls(car_controls)
time.sleep(0.1) # let car drive a bit
car_controls.is_manual_gear = False; # change back gear to auto
car_controls.manual_gear = 0
# apply breaks
car_controls.brake = 1
client.setCarControls(car_controls)
time.sleep(0.1) # let car drive a bit
car_controls.brake = 0 #remove break
#restore to original state
client.reset()
client.enableApiControl(False)