-
Notifications
You must be signed in to change notification settings - Fork 704
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
Enhanced turn lane processing #1859
Conversation
…anes for the specified turn lane direction. Also, added unit tests for ActivateTurnLanes
…into more_turn_lanes
…into more_turn_lanes
…ind an internal edge or not.
…into more_turn_lanes
…into more_turn_lanes
…into more_turn_lanes
…into more_turn_lanes
// Skip opposing directed edge and any edge that is not a road. Skip any | ||
// edges that are not driveable outbound. | ||
if (i == directededge.opp_local_idx() || !(diredge->forwardaccess() & kAutoAccess) || | ||
(directededge.restrictions() & (1 << diredge->localedgeidx())) != 0) { |
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.
skip any edges that are restricted too
// to check if the last edge is internal or not. If it is internal, we remove the | ||
// turn lanes from the last edge and leave them on the prior. | ||
if (edge.attributes.way_prior) | ||
directededge.set_internal(true); |
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.
} | ||
} | ||
|
||
// Update the rightmost lane as needed. |
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.
This is where we enhance the lanes by adding right lane information where the user added none. We only add slight rights when the through lanes have be accounted for in the turn types.
} | ||
|
||
// Update the leftmost lane as needed. | ||
void EnhanceLeftLane(const DirectedEdge directededge, |
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.
This is where we enhance the lanes by adding left lane information where the user added none. We only add slight lefts when the through lanes have be accounted for in the turn types.
} | ||
|
||
// update turn lanes vector | ||
bool ProcessLanes(bool isLeft, bool endOnTurn, std::vector<uint16_t>& enhanced_tls) { |
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.
ProcessLanes handles the majority of the lane enhancements.
GraphTileBuilder& tilebuilder, | ||
GraphReader& reader, | ||
std::mutex& lock, | ||
std::vector<TurnLanes>& turn_lanes) { | ||
|
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.
Some lambdas to check for right and left turns.
} | ||
|
||
// Is the next edge from the end node of the directededge is internal or not. | ||
bool IsNextEdgeInternal(const DirectedEdge directededge, |
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.
Used to determine if we delete the lane info on the prior edge or on the last edge
@@ -1102,6 +1464,47 @@ void enhance(const boost::property_tree::ptree& pt, | |||
GraphId startnode(id, local_level, i); | |||
NodeInfo& nodeinfo = tilebuilder.node_builder(i); | |||
|
|||
// Get headings of the edges - set in NodeInfo. Set driveability info |
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.
Some refactoring as we needed the heading info for checking for internal lanes.
@@ -1344,14 +1706,42 @@ void enhance(const boost::property_tree::ptree& pt, | |||
} | |||
} | |||
|
|||
// since the internal flag is set, we are at either the prior or the next edge and we need to |
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.
For the next few lines of code, this is where we either leave or toss the lane information based on if the next edge is internal or not.
|
||
uint32_t size = static_cast<uint32_t>(edges.size()); | ||
if (!edge.attributes.way_begin) | ||
size += 1; |
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.
what is this doing?
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.
can some one just describe in general the changes to this function. at a high level i cant quite grok them by looking at the code. like what do the changes accomplish for the sake of lane processing
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.
The changes are we need to flag the edge after the beginning and the edge prior to the last so that we can temporary set the internal flag.
if (((*it & kTurnLaneLeft) || (*it & kTurnLaneSharpLeft) || (*it & kTurnLaneSlightLeft) || | ||
(*it & kTurnLaneThrough)) && | ||
(previous == 0u || (previous & kTurnLaneLeft) || (previous & kTurnLaneSharpLeft) || | ||
(previous & kTurnLaneSlightLeft) || (previous & kTurnLaneThrough))) { |
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.
no mere human can read this if
statement
@@ -17,6 +18,8 @@ using namespace valhalla::midgard; | |||
using namespace valhalla::baldr; | |||
|
|||
namespace { | |||
constexpr float kShortRemainingDistanceThreshold = 0.402f; // Kilometers (~quarter mile) |
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.
used to determine if specific lane should be activated
} | ||
|
||
uint16_t | ||
EnhancedTripLeg_Edge::ActivateTurnLanes(uint16_t turn_lane_direction, |
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.
determines which lanes should be activated based on intersection, current maneuver, and next maneuver
@@ -660,6 +767,145 @@ std::string EnhancedTripLeg_Edge::ToString() const { | |||
return str; | |||
} | |||
|
|||
std::string EnhancedTripLeg_Edge::TurnLanesToString( |
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.
output for debug in specific order
@@ -1245,6 +1361,22 @@ bool EnhancedTripLeg_Node::HasTraversableOutboundIntersectingEdge( | |||
return false; | |||
} | |||
|
|||
bool EnhancedTripLeg_Node::HasSpecifiedTurnXEdge(const Turn::Type turn_type, |
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.
return true if an intersecting edge of the specified turn type exists
@@ -1298,6 +1430,72 @@ uint32_t EnhancedTripLeg_Node::GetStraightestIntersectingEdgeTurnDegree(uint32_t | |||
return staightest_turn_degree; | |||
} | |||
|
|||
uint32_t EnhancedTripLeg_Node::GetRightMostTurnDegree(uint32_t turn_degree, |
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.
will replace constants with this issue
return right_most_turn_degree; | ||
} | ||
|
||
uint32_t EnhancedTripLeg_Node::GetLeftMostTurnDegree(uint32_t turn_degree, |
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.
will replace constants with this issue
@@ -2322,6 +2342,130 @@ void ManeuversBuilder::EnhanceSignlessInterchnages(std::list<Maneuver>& maneuver | |||
} | |||
} | |||
|
|||
uint16_t ManeuversBuilder::GetExpectedTurnLaneDirection(Maneuver& maneuver) const { |
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.
logic to determine which turn lane to expect based on the maneuver - will continue to iterate/refactor as needed
maneuver.text_instruction() % maneuver.length() % units) | ||
.str(), | ||
" [NARRATIVE] "); | ||
|
||
// Turn lanes | ||
// Only for driving and no start/end maneuvers | ||
if ((maneuver.travel_mode() == valhalla::DirectionsLeg_TravelMode_kDrive) && |
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.
Output the turn lanes for RAD testing
Issue
Needed to add logic to interpret
none
orempty
turn lanes.Needed to add logic to assign turn lanes at intersections and activate proper lane direction
Tasklist