Set starting times and distance to TL individually

This commit is contained in:
Tobias Eidelpes 2021-06-14 13:04:42 +02:00
parent 843b1d63e1
commit d6a44ac1f6
2 changed files with 25 additions and 6 deletions

View File

@ -2,16 +2,24 @@
{
"oem": "BENTLEY",
"modelType": "Continental",
"vin": "SCBFR7ZA5CC072256"
"vin": "SCBFR7ZA5CC072256",
"startingVelocity": 130,
"startingDistance": 300
},
{
"oem": "SATURN",
"modelType": "Vue",
"vin": "5GZCZ43D13S812715"
"vin": "5GZCZ43D13S812715",
"startingVelocity": 130,
"startingDistance": 500,
"startingTime": 15
},
{
"oem": "SATURN",
"modelType": "Vue2",
"vin": "5GZCZ43D13S812716"
"vin": "5GZCZ43D13S812716",
"startingVelocity": 130,
"startingDistance": 100,
"startingTime": 25
}
]

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'])