Closed dawn-fm closed 5 days ago
traci.vehicle.subscribeContext(vehID, inductionloop.DOMAIN_ID, range, [traci.constants.TRACI_ID_LIST])
or you could iterate over all detectors and check whether they have the vehicle with lanearea.getLastStepVehicleIDs
.
@namdre Thank you for your kind response!
I tried your former suggestion among two. Since I chose and installed lanearea detector on my network, I wrote the code as follows:
import traci.constants as tc
...
traci.start()
traci.route.add('OD', ['origin','destination']
...
traci.vehicle.subscribeContext(EV_ID, tc.CMD_GET_LANEAREA_VARIABLE, 20, [tc.TRACI_ID_LIST])
while traci.simulation.getMinExpectedNumber() > 0:
traci.simulationStep()
e2_id = traci.vehicle.getContextSubscriptionResults(EV_ID)
print(e2_id)
traci.close()
But this kept shows me a result of
>> {}
{}
{}
...
{}
Judging by the observation that changing domain to LANE
(i.e., tc.CMD_GET_LANE_VARIABLE
yields lane IDs, TraCI connection and subscription works well.
Afraid of bothering you but can you help me more?
Thank you.
The described approach works in my own test. Please provide all input files (including the minimal python script) to replicate the problem on my end. (you can attach a .zip archive)
Okay. Here is my zip archive. The version of my environment is stated above. LaneRPM_share.zip
Hi,
After upgrading Ubuntu 22.04 and SUMO 1.12.0, e2 detector value retrieval from vehicle subscription became available. The bug was with the old version! I will self-close this issue.
Thank you for your help so far Dr. Erdmann (@namdre).
Hi all,
I'm not sure whether this is proper to write a question on here. Sorry in advance if not proper.
I am writing to find a method to ask if there are any methods to get a detector ID where a vehicle of interest is located.
My scenario is as follows:
I have a 5x5 grid network (below figure), each edge of which has two lanes.
Say the length of each lane is 100m and has E2 detectors of length 10m on every unit distance (say 10m).
Moreover, there is a vehicle of interest with a given origin-destination pair.
In order to move this vehicle via TraCI, I want to get a detector ID where this vehicle is located.
How can I do above things?
Thank you.
If possible, upload an example that shows your problem.
SUMO-version: SUMO 1.4.0
operating system: Ubuntu 20.04 on WSL2 (Windows 11)