Hi SUMO community,

I'm using TraCI to control traffic lights and would like the traffic light
to know the number of cars approaching it. Also, I'm only interested in
counting vehicles that are close enough, i.e. within 20 meters.

My current implementation is to get the ID of vehicles on a lane and
calculate the distance to the junction. Code is shown as follows. But is
there a more efficient way fo doing so?

Thanks,
Shuyi

def numberv(lane):
    nb = 0
    for k in traci.lane.getLastStepVehicleIDs(lane):
        if traci.vehicle.getLanePosition(k) < X-100:
             nb += 1
    return nb
_______________________________________________
sumo-user mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/sumo-user

Reply via email to