Hi Cindy,

I used the 'repeat' attribute of the 'route' command before to do loops,
instead of using re-routers; that was much easier. That may affect the
outcome of vehicle.getdistance().


*    <route id="r_ego" repeat="10000" edges="a b c d"  />*

An alternative is to somehow find out the circle perimeter and modulo the
distance: veh_distance = relative_distance % perimiter.
One other alternative is to consider the ring road a pure circle, then take
both vehicle's forward vectors, generate a circle through those two points
and calculate the circular distance. Mathematically perhaps a bit more
unstable than just using the x/y coordinates and calculating a distance. I
would go for the first method though: try to cut off 1 full perimeter if
the distance seems too large. The hard part is then perhaps figuring out
the perimeter.

Kind regards,
Ruud


On Mon, May 1, 2023 at 6:20 AM Chen Di <[email protected]> wrote:

> Hi,
>
> I have drawn a ring road following this
> <https://sumo.dlr.de/docs/Tutorials/Driving_in_Circles.html> tutorial,
> where gives me a circle that is not perfect (not smooth and the radius at
> different position may vary a bit). I also had re-routers so that vehicles
> drive for multiple rounds.
>
> I need to compute the relative distance between vehicles. I tried the
> function vehice.getdistance(). However, this will give me some errors in
> calculation. For example, if vehicle A in its second round is close to
> vehicle B in its third round, then the relative distance is a large value
> that contains a perimeter of the ring road.
>
> I also thought about using x,y coordinates and the angle, and convert it
> to distance. However, this seems not accurate, given that my ring road is
> not a perfect circle.
>
> I am wondering if there are any good ways to compute relative distance
> correctly in this case. Thanks!
>
> Best,
> Cindy
> _______________________________________________
> sumo-user mailing list
> [email protected]
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user
>
_______________________________________________
sumo-user mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to