diff --git a/components/entitiy_ident/mongo/cars.json b/components/entitiy_ident/mongo/cars.json index b6d5a87..4232e5c 100644 --- a/components/entitiy_ident/mongo/cars.json +++ b/components/entitiy_ident/mongo/cars.json @@ -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 } ] \ No newline at end of file diff --git a/components/i_feed/i_feed.py b/components/i_feed/i_feed.py index 04b1d11..383566a 100644 --- a/components/i_feed/i_feed.py +++ b/components/i_feed/i_feed.py @@ -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'])