[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [sumo-user] Time gap calculation
|
Note, that setPhaseDuration only sets the remaining duration of the current phasee and does not affect future repetitions of that phase. Also, the function currently, takes no effect for traffic light types other than 'static'.
Thanks a lot Jakob, it works. But now, i would like to change the durations of the phases with "setPhaseDuration". But by running the code, this command is fully ignored. I have alsways the same phase durations. What would you suggest how to change the phase duration?
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)
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.
You can get additional info from traci.inductionLoop.getVehicleData.
This allows determining sub-second time gaps.
regards,
Jakob
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
_______________________________________________ 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