Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Time gap calculation

Here is some old code that was called once per simulation step to compute the gaps:

INDUCTION_LOOP_EXIT_TIMES_CACHE = {} # det_id : (veh_id, exitTime)
def inductionloop_timegap(id):
    """returns the largest netto-time gap between sucessive vehicles"""
    vehicleData = traci.inductionloop.getVehicleData(id)
    if len(vehicleData) == 0:
        return traci.inductionloop.getTimeSinceDetection(id)
    gaps = []
    for veh_id, veh_length, entry_time, exit_time, vType in vehicleData:
        last_veh, last_exit = INDUCTION_LOOP_EXIT_TIMES_CACHE.get(id, (None, None))
        if last_veh != veh_id:
            gaps.append((last_exit, entry_time))
            if last_exit is not None and entry_time - last_exit <= 0:
                print("negative time gap det=%s lastVeh=%s (exit=%s) veh_id=%s (entry=%s)" % (
                        id, last_veh, last_exit, veh_id, entry_time))
        INDUCTION_LOOP_EXIT_TIMES_CACHE[id] = veh_id, exit_time
    #if id == 'RD1': print vehicleData, gaps
    gaps = [entry - exit for exit, entry in gaps if exit is not None]
    if len(gaps) > 0:
        #assert(min(gaps) > 0)
        return max(gaps + [0])
    else:
        return traci.inductionloop.getTimeSinceDetection(id)

Am Do., 15. Nov. 2018 um 09:26 Uhr schrieb Lina Siegerts <linas331@xxxxxxx>:
Thanks for the fast answer. Yes, i had also this idea. But do you know, how i can extract the time of this resulted lists by using this comand? Sorry, i am a beginner in sumo and python, so i would be very happy, if you could help me.
 
Gesendet: Mittwoch, 14. November 2018 um 16:02 Uhr
Von: "Jakob Erdmann" <namdre.sumo@xxxxxxxxx>
An: "Sumo project User discussions" <sumo-user@xxxxxxxxxxx>
Betreff: Re: [sumo-user] Time gap calculation
You can get additional info from traci.inductionLoop.getVehicleData.
This allows determining sub-second time gaps.
 
regards,
Jakob
 
Am Mi., 14. Nov. 2018 um 14:23 Uhr schrieb Lina Siegerts <linas331@xxxxxxx>:
Dear all,
 
i would like to calculate the time gaps between vehicles which pass an induction loop. The comand "getTimeSinceDetection" don´t extract the real time gap. So would you have an idea how to extract the time gaps in seconds? Thanks all,
 
Lina
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.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://www.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://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top