-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[not ready] Left hand driving #2670
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
@routing @testbot @sidebias | ||
Feature: Testbot - side bias | ||
|
||
Scenario: Left hand bias | ||
Given the profile "lhs" | ||
And the node map | ||
| a | | b | | c | | ||
| | | | | | | ||
| | | d | | | | ||
And the ways | ||
| nodes | | ||
| ab | | ||
| bc | | ||
| bd | | ||
|
||
When I route I should get | ||
| from | to | route | time | | ||
| d | a | bd,ab,ab | 82s +-1 | | ||
| d | c | bd,bc,bc | 100s +-1 | | ||
|
||
Scenario: Right hand bias | ||
Given the profile "rhs" | ||
And the node map | ||
| a | | b | | c | | ||
| | | | | | | ||
| | | d | | | | ||
And the ways | ||
| nodes | | ||
| ab | | ||
| bc | | ||
| bd | | ||
|
||
When I route I should get | ||
| from | to | route | time | | ||
| d | a | bd,ab,ab | 100s +-1 | | ||
| d | c | bd,bc,bc | 82s +-1 | | ||
|
||
Scenario: Roundabout exit counting for left sided driving | ||
Given the profile "lhs" | ||
And a grid size of 10 meters | ||
And the node map | ||
| | | a | | | | ||
| | | b | | | | ||
| h | g | | c | d | | ||
| | | e | | | | ||
| | | f | | | | ||
And the ways | ||
| nodes | junction | | ||
| ab | | | ||
| cd | | | ||
| ef | | | ||
| gh | | | ||
| bcegb | roundabout | | ||
|
||
When I route I should get | ||
| waypoints | route | turns | | ||
| a,d | ab,cd,cd | depart,roundabout-exit-1,arrive | | ||
| a,f | ab,ef,ef | depart,roundabout-exit-2,arrive | | ||
| a,h | ab,gh,gh | depart,roundabout-exit-3,arrive | | ||
|
||
Scenario: Mixed Entry and Exit | ||
Given the profile "lhs" | ||
And a grid size of 10 meters | ||
And the node map | ||
| | c | | a | | | ||
| j | | b | | f | | ||
| | k | | e | | | ||
| l | | h | | d | | ||
| | g | | i | | | ||
|
||
And the ways | ||
| nodes | junction | oneway | | ||
| cba | | yes | | ||
| fed | | yes | | ||
| ihg | | yes | | ||
| lkj | | yes | | ||
| behkb | roundabout | yes | | ||
|
||
When I route I should get | ||
| waypoints | route | turns | | ||
| c,a | cba,cba,cba | depart,roundabout-exit-1,arrive | | ||
| l,a | lkj,cba,cba | depart,roundabout-exit-2,arrive | | ||
| i,a | ihg,cba,cba | depart,roundabout-exit-3,arrive | |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,8 @@ class BaseDataFacade | |
|
||
virtual bool GetContinueStraightDefault() const = 0; | ||
|
||
virtual bool UseLeftSideDriving() const = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (try with |
||
|
||
virtual BearingClassID GetBearingClassID(const NodeID id) const = 0; | ||
|
||
virtual util::guidance::BearingClass | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- Testbot, with turn penalty | ||
-- Used for testing turn penalties | ||
|
||
require 'testbot' | ||
|
||
properties.left_hand_driving = true | ||
|
||
local turn_penalty = 500 | ||
local turn_bias = properties.left_hand_driving and 1/1.2 or 1.2 | ||
|
||
function turn_function (angle) | ||
---- compute turn penalty as angle^2, with a left/right bias | ||
k = turn_penalty/(90.0*90.0) | ||
if angle>=0 then | ||
return angle*angle*k/turn_bias | ||
else | ||
return angle*angle*k*turn_bias | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- Testbot, with turn penalty | ||
-- Used for testing turn penalties | ||
|
||
require 'testbot' | ||
|
||
properties.left_hand_driving = false | ||
|
||
local turn_penalty = 500 | ||
local turn_bias = properties.left_hand_driving and 1/1.2 or 1.2 | ||
|
||
function turn_function (angle) | ||
---- compute turn penalty as angle^2, with a left/right bias | ||
k = turn_penalty/(90.0*90.0) | ||
if angle>=0 then | ||
return angle*angle*k/turn_bias | ||
else | ||
return angle*angle*k*turn_bias | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,7 +501,7 @@ void collapseTurnAt(std::vector<RouteStep> &steps, | |
|
||
// Works on steps including silent and invalid instructions in order to do lane anticipation for | ||
// roundabouts which later on get collapsed into a single multi-hop instruction. | ||
std::vector<RouteStep> anticipateLaneChangeForRoundabouts(std::vector<RouteStep> steps) | ||
std::vector<RouteStep> anticipateLaneChangeForRoundabouts(std::vector<RouteStep> steps, const datafacade::BaseDataFacade &facade) | ||
{ | ||
using namespace util::guidance; | ||
|
||
|
@@ -517,17 +517,24 @@ std::vector<RouteStep> anticipateLaneChangeForRoundabouts(std::vector<RouteStep> | |
|
||
// Although the enter instruction may be a left/right turn, for right-sided driving the | ||
// roundabout is counter-clockwise and therefore we need to always set it to a left turn. | ||
// FIXME: assumes right-side driving (counter-clockwise roundabout flow) | ||
const auto enter_direction = enter.maneuver.instruction.direction_modifier; | ||
|
||
if (util::guidance::isRightTurn(enter.maneuver.instruction)) | ||
enter.maneuver.instruction.direction_modifier = | ||
mirrorDirectionModifier(enter_direction); | ||
if (facade.UseLeftSideDriving()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove FIXME comment above about right-sided assumptions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (also below in this file) |
||
{ | ||
if (util::guidance::isLeftTurn(enter.maneuver.instruction)) | ||
enter.maneuver.instruction.direction_modifier = | ||
mirrorDirectionModifier(enter_direction); | ||
} | ||
else | ||
{ | ||
if (util::guidance::isRightTurn(enter.maneuver.instruction)) | ||
enter.maneuver.instruction.direction_modifier = | ||
mirrorDirectionModifier(enter_direction); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to test this it would be great to have clockwise-flowing roundabouts modeled as Cucumber scenarios, you can take this one as example which assumes right-sided driving (and therefore counter-clockwise roundabout flow): https://github.com/Project-OSRM/osrm-backend/blob/master/features/guidance/anticipate-lanes.feature#L317 |
||
|
||
auto enterAndLeave = anticipateLaneChange({enter, leave}); | ||
|
||
// Undo flipping direction on a right turn in a right-sided counter-clockwise roundabout. | ||
// FIXME: assumes right-side driving (counter-clockwise roundabout flow) | ||
enterAndLeave[0].maneuver.instruction.direction_modifier = enter_direction; | ||
|
||
std::swap(*roundabout.first, enterAndLeave[0]); | ||
|
@@ -579,7 +586,7 @@ std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> steps) | |
// They are required for maintenance purposes. We can calculate the number | ||
// of exits to pass in a roundabout and the number of intersections | ||
// that we come across. | ||
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps) | ||
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps, const datafacade::BaseDataFacade &facade) | ||
{ | ||
// the steps should always include the first/last step in form of a location | ||
BOOST_ASSERT(steps.size() >= 2); | ||
|
@@ -589,7 +596,7 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps) | |
// Before we invalidate and remove silent instructions, we handle roundabouts (before they're | ||
// getting collapsed into a single multi-hop instruction) by back-propagating exit lane | ||
// constraints already to a roundabout's enter instruction. | ||
steps = anticipateLaneChangeForRoundabouts(std::move(steps)); | ||
steps = anticipateLaneChangeForRoundabouts(std::move(steps), facade); | ||
|
||
// Count Street Exits forward | ||
bool on_roundabout = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot to change the expected
lanes
output here fromslight right
to slight left.If you take a look at the way
ab
anddc
above, they only haveslight left
lanes.Counterclockwise vs clockwise does not change the turn lane's direction.
It only changes lane anticipation's behavior in keeping the user to the left/right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, here must be
slight left
, but the test fails because query returns an empty result, so i settodo
state and kept the original expecation, because had no idea what should be be the expected result.I will try to find out the reason during the next week. @MoKob showed me the starting place https://github.com/Project-OSRM/osrm-backend/blob/master/src/extractor/guidance/turn_lane_matcher.cpp#L54-L103