Go to the documentation of this file.
18 #include "ad/physics/Operation.hpp"
31 static const physics::Distance cMinimumNeighborDistance{0.1};
33 static const physics::Duration cMinimumNeighborDuration{0.05};
35 static const physics::Speed cMinimumSpeed{10.};
49 physics::Distance routeDistance{0.};
50 physics::Duration routeDuration{0.};
51 RoutingCostData costData{};
67 physics::Distance
const &maxDistance,
68 physics::Duration
const &maxDuration,
69 Type const &routingType)
70 :
Route(start, dest, maxDistance, maxDuration, routingType)
139 return origin.first.point.parametricOffset == physics::ParametricValue(0.);
145 return origin.first.point.parametricOffset == physics::ParametricValue(1.);
187 template <
class RoutingCostData>
193 throw std::runtime_error(
"RouteExpander::ExpandNeighbors invalid routing direction!");
202 ((origin.second.routeDistance < mMaxDistance) && (origin.second.routeDuration < mMaxDuration))
206 expandSameLaneNeighbors(lane, origin);
207 expandLongitudinalNeighbors(lane, origin);
208 expandLateralNeighbors(lane, origin);
213 throw std::runtime_error(
"RouteExpander::ExpandNeighbors No lane!");
217 template <
class RoutingCostData>
225 neighbor.first = neighborRoutingParaPoint;
227 physics::Distance neighborDistance{0.};
228 physics::Duration neighborDuration{0.};
230 =
getParametricPoint(*originLane, origin.first.point.parametricOffset, physics::ParametricValue(0.5));
232 =
getParametricPoint(*neighborLane, neighbor.first.point.parametricOffset, physics::ParametricValue(0.5));
234 physics::ParametricRange drivingRange;
235 if (origin.first.point.parametricOffset < neighbor.first.point.parametricOffset)
237 drivingRange.minimum = origin.first.point.parametricOffset;
238 drivingRange.maximum = neighbor.first.point.parametricOffset;
242 drivingRange.minimum = neighbor.first.point.parametricOffset;
243 drivingRange.maximum = origin.first.point.parametricOffset;
246 if (originLane == neighborLane)
248 neighborDuration =
getDuration(*originLane, drivingRange);
252 auto const maxSpeed = std::max(
getMaxSpeed(*originLane, drivingRange), cMinimumSpeed);
253 neighborDuration = neighborDistance / maxSpeed;
255 neighborDistance = std::max(neighborDistance, cMinimumNeighborDistance);
256 neighborDuration = std::max(neighborDuration, cMinimumNeighborDuration);
257 neighbor.second.routeDistance = origin.second.routeDistance + neighborDistance;
258 neighbor.second.routeDuration = origin.second.routeDuration + neighborDuration;
262 template <
class RoutingCostData>
268 neighbor.first = neighborRoutingParaPoint;
269 neighbor.second.routeDistance = origin.second.routeDistance + cMinimumNeighborDistance;
270 neighbor.second.routeDuration = origin.second.routeDuration + cMinimumNeighborDuration;
274 template <
class RoutingCostData>
278 if ((lane->id == getDest().laneId)
279 && ((isPositiveMovement(lane, origin) && (origin.first.point.parametricOffset <= getDest().parametricOffset))
280 || (isNegativeMovement(lane, origin) && (origin.first.point.parametricOffset >= getDest().parametricOffset))))
283 auto const neighbor = createNeighbor(lane, origin, lane, getRoutingDest());
284 addNeighbor(lane, origin, lane, neighbor, ExpandReason::Destination);
286 if (isPositiveMovement(lane, origin) && !isEnd(origin))
288 auto const neighbor = createNeighbor(
289 lane, origin, lane,
createRoutingParaPoint(lane->id, physics::ParametricValue(1.), origin.first.direction));
290 addNeighbor(lane, origin, lane, neighbor, ExpandReason::SameLaneNeighbor);
292 if (isNegativeMovement(lane, origin) && !isStart(origin))
294 auto const neighbor = createNeighbor(
295 lane, origin, lane,
createRoutingParaPoint(lane->id, physics::ParametricValue(0.), origin.first.direction));
296 addNeighbor(lane, origin, lane, neighbor, ExpandReason::SameLaneNeighbor);
300 template <
class RoutingCostData>
305 if (isEnd(origin) && isPositiveMovement(lane, origin))
309 else if (isStart(origin) && isNegativeMovement(lane, origin))
313 for (
auto contactLane : contactLanes)
328 auto const neighbor = createLongitudinalNeighbor(
331 addNeighbor(lane, origin, otherLane, neighbor, ExpandReason::LongitudinalNeighbor);
336 auto const neighbor = createLongitudinalNeighbor(
339 addNeighbor(lane, origin, otherLane, neighbor, ExpandReason::LongitudinalNeighbor);
343 throw std::runtime_error(
"Other lane neither SUCCESSOR not PREDECESSOR!");
349 throw std::runtime_error(
"No other lane!");
354 template <
class RoutingCostData>
358 for (
auto const &contactLane :
370 if (laneDirectionIsIgnored() || (lane->direction == otherLane->direction))
372 auto const neighbor = createNeighbor(
377 addNeighbor(lane, origin, otherLane, neighbor, ExpandReason::LateralNeighbor);
383 throw std::runtime_error(
"No other lane!");
bool isLaneRelevantForExpansion(lane::LaneId const laneId) const
check if lane is relevant for route expander
Definition: RouteExpander.hpp:163
namespace ad
Definition: GeometryStoreItem.hpp:28
virtual ~RouteExpander()=default
destructor.
physics::Duration getDuration(Lane const &lane, physics::ParametricRange const &range)
bool isLaneRelevantForExpansion(lane::LaneId const &laneId, lane::LaneIdSet const &relevantLanes)
Checks if the laneId is relevant for expansion given the set of relevant lanes.
Implements routing support functionality on the lane network.
Definition: RouteExpander.hpp:43
std::vector<::ad::map::lane::ContactLane > ContactLaneList
DataType ContactLaneList.
Definition: ContactLaneList.hpp:42
bool isLaneDirectionNegative(Lane const &lane)
Definition: LaneOperation.hpp:192
RoutingParaPoint createRoutingParaPoint(lane::LaneId const &laneId, physics::ParametricValue const ¶metricOffset, RoutingDirection const &routingDirection=RoutingDirection::DONT_CARE)
create a RoutingParaPoint
Definition: Routing.hpp:89
void expandNeighbors(RoutingPoint const &origin)
Triggers the expansion of the given routing point origin to its valid neighborhood.
Definition: RouteExpander.hpp:188
void expandLateralNeighbors(lane::Lane::ConstPtr lane, RoutingPoint const &origin)
perform the expansion of the neighbor points in lateral (contacts: left/right) lane direction
Definition: RouteExpander.hpp:355
std::pair< RoutingParaPoint, RoutingCost > RoutingPoint
definition of the routing point
Definition: RouteExpander.hpp:54
void clearRelevantLanes()
clear the list of relevant lanes.
Definition: RouteExpander.hpp:101
definition of the routing cost data
Definition: RouteExpander.hpp:47
ContactLocation
DataType ContactLocation.
Definition: ContactLocation.hpp:43
@ SameLaneNeighbor
expand the route by a neighbor point within the same lane
point::ECEFPoint getParametricPoint(Lane const &lane, physics::ParametricValue const &longitudinalOffset, physics::ParametricValue const &lateralOffset)
Calculates parametric point on the lane. Point is calculated by first calculating t_long parametric p...
void setRelevantLanes(::ad::map::lane::LaneIdSet const &relevantLanes)
set the lanes that are relevant for routing All the rest of the lanes in the map are ignored.
Definition: RouteExpander.hpp:93
@ DONT_CARE
Vehicle direction is not relevant.
RouteExpander(const RoutingParaPoint &start, const RoutingParaPoint &dest, physics::Distance const &maxDistance, physics::Duration const &maxDuration, Type const &routingType)
Constructor.
Definition: RouteExpander.hpp:65
void expandSameLaneNeighbors(lane::Lane::ConstPtr lane, RoutingPoint const &origin)
perform the expansion of the neighbor points on the same lane
Definition: RouteExpander.hpp:275
@ NEGATIVE
Vehicle direction is opposite of Lane orientation.
Type
Routing type.
Definition: Route.hpp:59
@ Destination
expand the destination
physics::Distance distance(BoundingSphere const &left, BoundingSphere const &right)
Computes distance between BoundingSpheres.
Definition: BoundingSphereOperation.hpp:29
bool laneDirectionIsIgnored() const
DataType LaneId.
Definition: LaneId.hpp:66
@ LongitudinalNeighbor
expand the route by a longitudinal neighbor lane point
@ LateralNeighbor
expand the route by a lateral neighbor lane point
virtual void addNeighbor(lane::Lane::ConstPtr originLane, RoutingPoint const &origin, lane::Lane::ConstPtr neighborLane, RoutingPoint const &neighbor, ExpandReason const &expandReason)=0
a neighbor is added
bool isLaneDirectionPositive(Lane const &lane)
Definition: LaneOperation.hpp:184
RoutingPoint createNeighbor(lane::Lane::ConstPtr originLane, RoutingPoint const &origin, lane::Lane::ConstPtr neighborLane, RoutingParaPoint neighborRoutingParaPoint)
create neighbor point and calculate the actual distance/duration to reach it
Definition: RouteExpander.hpp:219
void expandLongitudinalNeighbors(lane::Lane::ConstPtr lane, RoutingPoint const &origin)
perform the expansion of the neighbor points in longitudinal (contacts: successor/predecessor) lane d...
Definition: RouteExpander.hpp:301
Lane::ConstPtr getLanePtr(LaneId const &id)
Method to be called to retrieve Lane from the Store.
Implements routing on the lane network.
Definition: Route.hpp:34
@ POSITIVE
Vehicle direction is same as Lane orientation.
bool isPositiveMovement(lane::Lane::ConstPtr lane, RoutingPoint const &origin)
Definition: RouteExpander.hpp:149
bool isLanePartOfAnIntersection(Lane const &lane)
Definition: LaneOperation.hpp:209
bool isRouteable(Lane const &lane)
Definition: LaneOperation.hpp:200
physics::Speed getMaxSpeed(Lane const &lane, physics::ParametricRange const &range)
DataType ECEFPoint.
Definition: ECEFPoint.hpp:45
bool isEnd(RoutingPoint const &origin)
Definition: RouteExpander.hpp:143
RoutingPoint createLongitudinalNeighbor(RoutingPoint const &origin, RoutingParaPoint neighborRoutingParaPoint)
create longitudinal neighbor point with minimal actual distance/duration to reach
Definition: RouteExpander.hpp:264
routing para point
Definition: Routing.hpp:44
::ad::map::lane::LaneIdSet mRelevantLanes
relevant lanes for the routing
Definition: RouteExpander.hpp:184
ContactLaneList getContactLanes(Lane const &lane, ContactLocation const &location)
Find contact lanes at specific relative location.
bool isNegativeMovement(lane::Lane::ConstPtr lane, RoutingPoint const &origin)
Definition: RouteExpander.hpp:156
bool isStart(RoutingPoint const &origin)
Definition: RouteExpander.hpp:137
std::shared_ptr< Lane const > ConstPtr
Smart pointer on constant Lane.
Definition: Lane.hpp:66
ContactLocation getContactLocation(Lane const &lane, LaneId const &to_lane_id)
Check nature of contact between this lane and another lane.
ExpandReason
Definition of the reasons for route expansion.
Definition: RouteExpander.hpp:110