Set starting times and distance to TL individually
This commit is contained in:
parent
843b1d63e1
commit
d6a44ac1f6
@ -2,16 +2,24 @@
|
|||||||
{
|
{
|
||||||
"oem": "BENTLEY",
|
"oem": "BENTLEY",
|
||||||
"modelType": "Continental",
|
"modelType": "Continental",
|
||||||
"vin": "SCBFR7ZA5CC072256"
|
"vin": "SCBFR7ZA5CC072256",
|
||||||
|
"startingVelocity": 130,
|
||||||
|
"startingDistance": 300
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oem": "SATURN",
|
"oem": "SATURN",
|
||||||
"modelType": "Vue",
|
"modelType": "Vue",
|
||||||
"vin": "5GZCZ43D13S812715"
|
"vin": "5GZCZ43D13S812715",
|
||||||
|
"startingVelocity": 130,
|
||||||
|
"startingDistance": 500,
|
||||||
|
"startingTime": 15
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oem": "SATURN",
|
"oem": "SATURN",
|
||||||
"modelType": "Vue2",
|
"modelType": "Vue2",
|
||||||
"vin": "5GZCZ43D13S812716"
|
"vin": "5GZCZ43D13S812716",
|
||||||
|
"startingVelocity": 130,
|
||||||
|
"startingDistance": 100,
|
||||||
|
"startingTime": 25
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -1,6 +1,8 @@
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import geopy.distance
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from dse_shared_libs import daf, traffic_light_state, traffic_light_color, target_velocity
|
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()
|
switching_time=traffic_light['switchingTime']).start()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
for car in cars['cursor']:
|
for index, car in enumerate(cars['cursor']):
|
||||||
print(car)
|
print(car)
|
||||||
Vehicle(vin=car['vin']).start_driving()
|
# Get location of first TL
|
||||||
time.sleep(15)
|
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'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user