Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] getting Trajectory using Traci

hello Jakob, 
yes but I want to calculate travel time in each time step and optimize it and I think fcd output can not change vehicles' positions dynamically.
to compute travel time for each vehicle in Traci I used this code:
    while step < 14000:
        traci.simulationStep()
        for id in traci.vehicle.getIDList():
            pos0 =traci.vehicle.getPosition(id)[0]
            speed0 =traci.vehicle.getSpeed(id)
            step += 0.4
            traci.simulationStep()
            pos1 =traci.vehicle.getPosition(id)[0]
            speed1 =traci.vehicle.getSpeed(id)
            if speed1 == 0:
                avgTT = 0
            else:
                avgTT =(pos1-pos0)/speed1
            avgTT_list.append(avgTT)
            print(avgTT_list)
        step += 0.4
but after some time step sumo raise this error 
    raise TraCIException(err, prefix[1], _RESULTS[prefix[2]])
traci.exceptions.TraCIException: Vehicle '1.3' is not known.
how can I fix it and do you have any suggestions for calculating the travel time of each vehicle in each time step?

On Wed, Mar 2, 2022 at 10:00 AM Jakob Erdmann <namdre.sumo@xxxxxxxxx> wrote:
Have you considered using fcd-output?
The simplest (though not the most efficient) way to retrieve data from all vehicles is by looping over the list of all ids:

for vehID in traci.vehicle.getIDList():
   traci.vehicle.getPosition(vehID)

Am Di., 1. März 2022 um 14:59 Uhr schrieb amir kr <amirhkr1995@xxxxxxxxx>:
Hello everyone,
I want to get the position of all vehicles in each step time but when I want to use traci.vehicle.getPosition(VehID) I do not know what to put instead of VehID because I want to get the position of all vehicles. how can I fix it ?
best regards,
Amir,
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top