Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Relative distance in ring road

Hi Ruud, 

Thanks for sharing you methods! 
I just figured out to plot a more 'perfect' circle by adding more junctions and then converting it to geometry points. Given the perfect shape, I'm thinking another way of computing the distance: based on the two vehicles' coordinates, compute the arc length. And the arc length is the relative distance. 

Best,
Di

Ruud van Gaal <r.vangaal@xxxxxxxxxx> 于2023年5月1日周一 01:00写道:
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 <dichen981@xxxxxxxxx> wrote:
Hi,

I have drawn a ring road following this 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
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