Skip to content
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

Merged
merged 65 commits into from
Jun 27, 2019
Merged

Enhanced turn lane processing #1859

merged 65 commits into from
Jun 27, 2019

Conversation

dgearhart
Copy link
Member

@dgearhart dgearhart commented Jun 24, 2019

Issue

Needed to add logic to interpret none or empty turn lanes.
Needed to add logic to assign turn lanes at intersections and activate proper lane direction

Tasklist

  • Add tests
  • Review - you must request approval to merge any PR to master
  • Generally use squash merge to rebase and clean comments before merging
  • Update the changelog

gknisely and others added 30 commits May 31, 2019 13:33
…anes for the specified turn lane direction.

Also, added unit tests for ActivateTurnLanes
@dgearhart dgearhart self-assigned this Jun 24, 2019
// 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) {
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lane

}
}

// Update the rightmost lane as needed.
Copy link
Member

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,
Copy link
Member

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) {
Copy link
Member

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) {

Copy link
Member

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,
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this doing?

Copy link
Member

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

Copy link
Member

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))) {
Copy link
Member

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)
Copy link
Member Author

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,
Copy link
Member Author

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(
Copy link
Member Author

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,
Copy link
Member Author

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,
Copy link
Member Author

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,
Copy link
Member Author

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 {
Copy link
Member Author

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) &&
Copy link
Member Author

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

kevinkreiser
kevinkreiser previously approved these changes Jun 27, 2019
@dgearhart dgearhart merged commit db3a99f into master Jun 27, 2019
@dgearhart dgearhart deleted the more_turn_lanes branch June 27, 2019 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants