osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

Avoid u-turns

Open JMGGarcia opened this issue 10 years ago • 6 comments

(I've asked in #102 but doesn't like I'm going to get an answer there)

I'm working on a heavy vehicle routing system using OSRM. It has proven very useful but the issue mentioned by DrVanScott is kinda annoying, has there been any work done on this? Using the car.lua file as the profile, I noticed there is a "u_turn_penalty" variable but changing it doesn't seem to have much of an effect. Am I missing something?

JMGGarcia avatar Dec 17 '15 11:12 JMGGarcia

From a look at the profiles and the graph creation, the u_turn_penalty is used here in addition to a function penalty based on the angle of the turn (link).

What kind of values did you supply to the profile?

MoKob avatar Dec 17 '15 15:12 MoKob

I didn't change anything in the turn function, are u-turns also considered in the turn function?

As for the u_turn_penalty values, I tried values from the 10 to something ridiculous like 400000000000 and saw no change in behavior.

JMGGarcia avatar Dec 17 '15 15:12 JMGGarcia

From the turn function, I'd say that a u-turn is penalised by 40/1.2 + 20 or 40*1.2 + 20 (depending on whether the u-turn is classified as left or right u-turn). High values within 32 bit (e.g. 100000) should usually avoid u-turns as long as there is no other reasonable way.

MoKob avatar Dec 17 '15 15:12 MoKob

I had a look at the code, apparently it is a problem in the default profile. The u_turn_penalty variable is local, which results in a u_turn_penalty of 0, no matter what value you specify. For a quick fix, you can remove the local keyword and your u-turn penalty should work fine.

MoKob avatar Dec 18 '15 11:12 MoKob

done with https://github.com/Project-OSRM/osrm-backend/pull/1832/

MoKob avatar Dec 18 '15 11:12 MoKob

Was about to post a specific example, but that solved it, thanks!

JMGGarcia avatar Dec 18 '15 11:12 JMGGarcia