Avoid u-turns
(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?
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?
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.
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.
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.
done with https://github.com/Project-OSRM/osrm-backend/pull/1832/
Was about to post a specific example, but that solved it, thanks!