Update turn penalty function to better fit measured data

This commit is contained in:
Daniel Patterson 2016-09-06 09:07:00 -07:00 committed by GitHub
parent 97c66c6c82
commit 1ab2b87cc0
2 changed files with 8 additions and 6 deletions

View File

@ -3,6 +3,7 @@
- Profiles - Profiles
- includes library guidance.lua that offers preliminary configuration on guidance. - includes library guidance.lua that offers preliminary configuration on guidance.
- added left_hand_driving flag in global profile properties - added left_hand_driving flag in global profile properties
- modified turn penalty function for car profile - better fit to real data
- Guidance - Guidance
- Handle Access tags for lanes, only considering valid lanes in lane-guidance (think car | car | bike | car) - Handle Access tags for lanes, only considering valid lanes in lane-guidance (think car | car | bike | car)
- API: - API:

View File

@ -150,10 +150,10 @@ properties.left_hand_driving = false
local side_road_speed_multiplier = 0.8 local side_road_speed_multiplier = 0.8
local turn_penalty = 1 local turn_penalty = 7.5
-- Note: this biases right-side driving. Should be -- Note: this biases right-side driving. Should be
-- inverted for left-driving countries. -- inverted for left-driving countries.
local turn_bias = properties.left_hand_driving and 1/1.2 or 1.2 local turn_bias = properties.left_hand_driving and 1/1.075 or 1.075
local obey_oneway = true local obey_oneway = true
local ignore_areas = true local ignore_areas = true
@ -544,12 +544,13 @@ function way_function (way, result)
end end
function turn_function (angle) function turn_function (angle)
---- compute turn penalty as angle^2, with a left/right bias -- Use a sigmoid function to return a penalty that maxes out at turn_penalty
-- over the space of 0-180 degrees. Values here were chosen by fitting
-- the function to some turn penalty samples from real driving.
-- multiplying by 10 converts to deci-seconds see issue #1318 -- multiplying by 10 converts to deci-seconds see issue #1318
k = 10*turn_penalty/(90.0*90.0)
if angle>=0 then if angle>=0 then
return angle*angle*k/turn_bias return 10 * turn_penalty / (1 + 2.718 ^ - ((13 / turn_bias) * angle/180 - 6.5*turn_bias))
else else
return angle*angle*k*turn_bias return 10 * turn_penalty / (1 + 2.718 ^ - ((13 * turn_bias) * - angle/180 - 6.5/turn_bias))
end end
end end