Hello Jacob,
I've been working for while based on your last suggestion, placing cars as obstacles on one lane and using TraCI to detect when two opposing vehicles are within a range of each other.
1) My current approach is to make a distance matrix between vehicles to know whether car A is within range of car B and then decide which one parks. This relies on each car's current lane and the succeeding lane. Do you recommend using context subscriptions or any other approaches to detect an impending collision?
2) To test out the simplest case, for now my scenario only has 2 opposing vehicles, before moving on to greater complexity. I have vehicles 'Red' and 'Blue'. Red is on the wrong lane which is being blocked by long green vehicles, and Blue is on the natural lane which is unblocked. All attempts to make the vehicles park on the side of the road have failed.
For some reason, whenever they are in range (150 meters) of each other, the TraCI command to park fails. This is the command I used:
traci.vehicle.setStop(vehID=stopping_vehicleID,
edgeID=stopping_vehicleEdge, laneIndex=0, duration=duration,
flags=traci.constants.STOP_PARKING)
When I force Red to park on the side of the road, I get an error, whether the stopping edge is the one it is currently on (
'6to1_0' ) or whether it is the neighboring edge (
'1to6_0' ) which is in its route but is of course blocked:
Stop for vehicle 'red' ... is not downstream the current route.
I then tried making Blue the vehicle that always parked, but I got the same type of error even though the lane is within the current route:
route: ['in', '4to5', '5to6', '6to1', '1to2', '2to3', '3to4', 'out']
traci.exceptions.TraCIException: Stop for vehicle 'blue' on lane '5to6_0' is not downstream the current route.
Can you please suggest what is wrong and how I can fix this? Thank you
Below is just raw output from the console.
Traceback (most recent call last):
File "<input>", line 3, in <module>
File "<input>", line 228, in run
File "D:\Program Files\DLR\Sumo\tools\traci\_vehicle.py", line 693, in setStop
self._connection._sendExact()
File "D:\Program Files\DLR\Sumo\tools\traci\connection.py", line 109, in _sendExact
raise TraCIException(prefix[1], _RESULTS[prefix[2]], err)
traci.exceptions.TraCIException: Stop for vehicle 'red' on lane '6to1_0' is not downstream the current route.
stopping_vehicleEdge: 1to6
route: ['in', '4to3', '3to2', '2to1', '1to6', '6to5', '5to4', 'out']
Traceback (most recent call last):
File "<input>", line 24, in <module>
File "<input>", line 205, in run
File "D:\Program Files\DLR\Sumo\tools\traci\_vehicle.py", line 693, in setStop
self._connection._sendExact()
File "D:\Program Files\DLR\Sumo\tools\traci\connection.py", line 109, in _sendExact
raise TraCIException(prefix[1], _RESULTS[prefix[2]], err)
traci.exceptions.TraCIException: Stop for vehicle 'red' on lane '1to6_0' is not downstream the current route.
stopping_vehicleEdge: 5to6
route: ['in', '4to5', '5to6', '6to1', '1to2', '2to3', '3to4', 'out']
lanePos: 534.0311930685754
Traceback (most recent call last):
File "<input>", line 3, in <module>
File "<input>", line 229, in run
File "D:\Program Files\DLR\Sumo\tools\traci\_vehicle.py", line 693, in setStop
self._connection._sendExact()
File "D:\Program Files\DLR\Sumo\tools\traci\connection.py", line 109, in _sendExact
raise TraCIException(prefix[1], _RESULTS[prefix[2]], err)
traci.exceptions.TraCIException: Stop for vehicle 'blue' on lane '5to6_0' is not downstream the current route.