Hi,
I'm fairly sure this is a misunderstanding on how the simulator works from
my side, but I can't understand how it is supposed to work...
I have a testprogram that, using TraCI, selects a random car and then finds
all the cars in a certain radius around this car.
I paint the tracked car green, and the surrounding cars red. I also print
the number of found cars.
The loop looks similar to this:
while(true) {
client.simulationStep(0); // Wait one step
cars = getCarsInPlay(); // Get the cars that are active on the map
close = getCloseCars(cars); // Get the cars that are close
paintCarsRed(close);
}
getCloseCars gets the position of all cars (getPosition(vehicleID)) and
calculates the distance between the special car and the rest of the cars.
Well, everything works fine. Except for one thing. It seems my program is
lagging one step behind the simulation.
That is, if my special car has 3 neighboring cars at time x, I will at time
x+1 get 'There are 3 close cars' and see them painted red. Except that at
time x+1 in the UI, they no longer necessarily needs to be close to 'my'
car.
Of course, this does not matter when running a simulation, but it would be
nice to have some UI to show also.
I guess my question is, how come getPosition returns the position for the
last time tick and not current time tick?
Can I somehow sync the UI with the simulator?
Best Regards,
//Fredrik
------------------------------------------------------------------------------
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user