Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Efficient way to count #vehicles within a distance of junction

Hi Harald,

Thank you for letting me know the other approaches: they may be worthwhile to explore in the future. And equally thankful for pointing me to that discussion.

Sincerely,
Shuyi

On Thu, Jul 26, 2018 at 12:15 AM Harald Schaefer <haraldschaefer@xxxxxxxxxxx> wrote:
Hi Shuyi,

there are different approaches to control traffic lights depending on the traffic.
One is to look for gaps in the incoming traffic flow (see http://sumo.dlr.de/wiki/Simulation/Traffic_Lights#Improving_Generated_programs_with_knowledge_about_traffic_demand and http://sumo.dlr.de/wiki/Simulation/Traffic_Lights#Actuated_Traffic_Lights)
For your approach see also the discussion recently here about "Locating cars around certain coordinates"

Best regards, Harald

Am 25.07.2018 um 23:43 schrieb Shuyi Yin:
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
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sumo-user


_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sumo-user

Back to the top