abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
510 stars 122 forks source link

Can a profile specify different costs for left and right turns? #110

Open lpirl opened 6 years ago

lpirl commented 6 years ago

This would probably be useful for routing in urban areas, where turning right is oftentimes much easier/quicker than turning left (the other way around for left-hand traffic). Maybe some users would want to configure turning right at traffic lights to be as cheap as there would be no traffic light at all. :)

poutnikl commented 6 years ago

Aside of the implementation, how would you decide algorithmically ? As there is huge difference in crossing turn parameters, affecting the cost value, mainly traffic, geometry, orientation and priority.

I guess, before serious consideration by the developer, a draft of a crossing turning cost model is IMHO needed.

From other point of view, there is already crossingless turning cost. Proper value, slightly increased above the simple geometrical turncost may eliminate the need of left/right crossing turn cost, as their deviations will cancel each other.

poutnikl commented 6 years ago

E.g if geometrical turncoat was 90, rightturn crossing cost was 150, left one 300, Using effective common turncost somewhere between 120-180 may fit . Optimal value depends on curve/crossing ratio.

abrensch commented 6 years ago

Are you talking about bikes or cars?

The kinematical model for car-routing has already some symmetry-breaking, when crossing straight, the speed constraint may be different whether a street is joing from the left or from the right:

Look here for "leftWaySpeed":

https://github.com/abrensch/brouter/blob/master/brouter-core/src/main/java/btools/router/KinematicPath.java

However, there are not yet assymetric values here, because there' no concpt for left- or right-handes traffic up to now.

lpirl commented 6 years ago

First of all, thanks for joining the discussion. Well, I am obviously not enough into routing to answer all the follow up questions.

I am talking about bicycles. In urban areas, turning left on crossing with traffic lights is very expensive, since you usually have to cross two streets (involves waiting :)). Turning right, in contrast, is usually possible without any waiting at all.

I thought of something like this: Suppose a turn at a crossing has a fixed cost, e.g., 50 {or a cost factor [0;1], e.g., .2}. Now, left turns could have a higher cost (e.g., 60) and right turns a lower cost (e.g., 40) {or factor .3 for right and .1 for left turns}.

Considering the angle here would be more advanced but might be not even needed, since it is just about having to cross approaching traffic.

Oh maybe that would be an alternative: penalties for crossing approaching traffic and penalties for crossing cross traffic. I wouldn't be too sure if it is more expensive with out without traffic lights.

lpirl commented 6 years ago

Regarding the awareness of left- and right-hand traffic: if the routing engine has no understanding of these concepts, the profiles could (with the obvious limitation that profiles for left-hand traffic could not be used for right-hand traffic and vice versa). However, the alternative mentioned above (i.e., "a penalty for crossing other traffic lanes"), would eliminate the need for distinguishing between left. and right-hand traffic, no?

poutnikl commented 6 years ago

Hm , as there is statistically about the same number of both L/R types, 40/60 will be more expensive than 50/50 with about the same result.

As penalties are to be point like, it would not make sense to touch cost factor, related to the way segment length. Rather to be applied in node context. Neither the way initialcost applies easily, as the cost is context dependent.

Profiles are part of the routing engine. They cannot be aware of what the engine cannot be aware of.

lpirl commented 6 years ago

Thanks @poutnikl for the explanations. I am apparently not enough into routing engines (i.e., not at all) to oversee why penalties for crossing other traffic lines could not work well or easily. If you folks don't see any possibility or other approach to take into account (routing-wise) that crossing other traffic tends to be expensive, feel free to close this issue then.

NotAFile commented 2 years ago

This is unfortunately the one area where BRouter delivers suboptimal results for me. It often instructs me to turn left on multi lane roads where I would usually avoid turning left at all costs for safety reasons. I think making that decision well would require better mapping of bicycle turning lanes though.

poutnikl commented 2 years ago

The best is going just straight ahead or turning right, going in clockwise closed cycles.