Set starting times and distance to TL individually

This commit is contained in:
2021-06-14 13:04:42 +02:00
parent 843b1d63e1
commit d6a44ac1f6
2 changed files with 25 additions and 6 deletions
+14 -3
View File
@@ -1,6 +1,8 @@
import sys
import time
import geopy.distance
import requests
from dse_shared_libs import daf, traffic_light_state, traffic_light_color, target_velocity
@@ -38,7 +40,16 @@ if __name__ == '__main__':
switching_time=traffic_light['switchingTime']).start()
time.sleep(0.5)
for car in cars['cursor']:
for index, car in enumerate(cars['cursor']):
print(car)
Vehicle(vin=car['vin']).start_driving()
time.sleep(15)
# Get location of first TL
tl_1_loc = geopy.Point(47.89584, 16.20719)
# Calculate starting point by going south of TL_location the amount specified in cars.json
d = geopy.distance.distance(kilometers=car['startingDistance'] / float(1000))
starting_point = d.destination(point=tl_1_loc, bearing=182)
starting_velocity = car['startingVelocity']
print('StartingPoint is {} and startingVelocity is {}'.format(starting_point, starting_velocity))
Vehicle(vin=car['vin'], starting_point=starting_point, starting_velocity=starting_velocity).start_driving()
# Sleep for amount of seconds defined in second car before second car starts
if len(cars['cursor']) > 1 and index < len(cars['cursor']) - 1:
time.sleep(cars['cursor'][index + 1]['startingTime'])