ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
lane_view_provider.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2017-2020 German Aerospace Center (DLR).
3  * Eclipse ADORe, Automated Driving Open Research https://eclipse.org/adore
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License 2.0 which is available at
7  * http://www.eclipse.org/legal/epl-2.0.
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  * Daniel Heß - computation of lane-following-geometry in separate app
13  * Thomas Lobig - adaptions for lane change (left/right) geometry
14  ********************************************************************************/
15 
16 #pragma once
17 
18 #include <adore/env/afactory.h>
19 #include <adore/params/afactory.h>
27 
28 #include <set>
29 
30 namespace adore
31 {
32  namespace apps
33  {
40  {
41  private:
44  // adore::env::BorderBased::LaneFollowingGeometry<20, 200> lfg_left_; /**< object, which constructs lane
45  // following geometry from local road-map */
46  // adore::env::BorderBased::LaneFollowingGeometry<20, 200> lfg_right_; /**< object, which constructs lane
47  // following geometry from local road-map */
62 
67 
68  public:
70  {
84  }
86  {
87  delete ilcg_left_;
88  delete ilcg_right_;
89  }
90 
95  void run()
96  {
97  if (writer_->canWriteMore())
98  {
100 
101  adore::env::BorderBased::BorderID bestMatchFromLastLFG;
102  bool bestMatchFromLastLFGValid = false;
103  bool reset_lane_matching = false;
104  if (reset_reader_->hasUpdate())
105  {
106  reset_reader_->getData(reset_lane_matching);
107  }
108  if(activate_lfg_rematching_ && lfg_.isValid() && !reset_lane_matching)//info from last time
109  {
110  //try to match ego state to old borders: do this before roadmap_.update()!
116  + 0.5 * apVehicle_->get_bodyWidth());
117  if(border!=nullptr)
118  {
119  bestMatchFromLastLFG = border->m_id;
120  bestMatchFromLastLFGValid = true;
121  }
122  }
123 
124  roadmap_.update(bestMatchFromLastLFGValid,bestMatchFromLastLFG);
125  auto current_border = roadmap_.getMatchedBorder();
126  auto ego_state = roadmap_.getEgoState();
127 
128 
129 
131  current_border, roadmap_.getVehicleState(), apLFV_->getLookAhead(),
134 
137 
138  if(lfg_.isValid())
139  {
140  //copy to data object
141  // lfg_.m_centerSmoothed_fct
143 
145  clg.center->centerSmoothed_fct,
146  clg.center->leftDistance_fct,
147  clg.center->rightDistance_fct,
148  clg.center->speedLimit_fct);
149 
151  clg.center->centerSmoothed_fct,
152  clg.center->leftDistance_fct,
153  clg.center->rightDistance_fct,
154  clg.center->left_indicator_hint_fct,
155  clg.center->right_indicator_hint_fct);
156 
157  auto borders_in_lfg = lfg_.getRightBorders()->getBorders();
158  auto current_border_iterator = borders_in_lfg->begin();
159  auto first_border_iterator = borders_in_lfg->begin();
160  auto last_border_iterator = std::next(borders_in_lfg->begin(),borders_in_lfg->size()-1);
161  for(;(*current_border_iterator)!=current_border
162  && current_border_iterator!=borders_in_lfg->end();
163  current_border_iterator++){}
164  double offset_on_current = 0.0;
165 
166  if(current_border->m_path!=nullptr)
167  {
168  double n;
169  offset_on_current = current_border->m_path->getClosestParameter(ego_state.getX(),ego_state.getY(),1,2,n);
170  }
171 
172  if(current_border_iterator!=borders_in_lfg->end())
173  {
182  ilcg_left_->update(offset_on_current,current_border_iterator,first_border_iterator,last_border_iterator);
183  ilcg_right_->update(offset_on_current,current_border_iterator,first_border_iterator,last_border_iterator);
184  if(ilcg_left_->isValid())
185  {
188  clg.left->centerSmoothed_fct,
189  clg.left->leftDistance_fct,
190  clg.left->rightDistance_fct,
191  clg.left->speedLimit_fct);
192 
194  clg.left->centerSmoothed_fct,
195  clg.left->leftDistance_fct,
196  clg.left->rightDistance_fct,
197  clg.left->left_indicator_hint_fct,
198  clg.left->right_indicator_hint_fct);
199  }
200  else
201  {
202  clg.left->isValid = false;
203  clg.leftChange->isValid = false;
204  }
205 
206  if(ilcg_right_->isValid())
207  {
210  clg.right->centerSmoothed_fct,
211  clg.right->leftDistance_fct,
212  clg.right->rightDistance_fct,
213  clg.right->speedLimit_fct);
214 
216  clg.right->centerSmoothed_fct,
217  clg.right->leftDistance_fct,
218  clg.right->rightDistance_fct,
219  clg.right->left_indicator_hint_fct,
220  clg.right->right_indicator_hint_fct);
221  }
222  else
223  {
224  clg.right->isValid = false;
225  clg.rightChange->isValid = false;
226  }
227  }
228 
229  writer_->write(clg);
230  }
231  }
232  }
233 
234  void copy_ilcg(std::shared_ptr<adore::env::BorderBased::LaneGeometryDataProxy> target_geometry,
235  std::shared_ptr<adore::env::BorderBased::LaneChangeDataProxy> target_lcdata,
237  {
238  target_geometry->centerSmoothed_fct = lane->baseline_.position_fct_;
239  target_geometry->centerNormal_fct = lane->baseline_.normal_fct_;
240  target_geometry->centerSmoothedCurvature_fct = lane->baseline_.curvature_fct_;
241  target_geometry->centerSmoothedCurvatureDerivative_fct = lane->baseline_.curvatureDerivative_fct_;
242  target_geometry->navigationCost_fct = lane->navigationCost_fct_;
243  target_geometry->isValid = true;
244  target_lcdata->gate_s0 = lane->getProgressGateOpen();
245  target_lcdata->gate_s1 = lane->getProgressGateClosed();
246  target_lcdata->direction = lane->lcb_.isLCDirectionLeft()
249  target_lcdata->isValid = true;
250  target_lcdata->targetOuterBorderDistance_fct = lane->offsetTargetOuterBorders_;
251  target_lcdata->separatingBorderDistance_fct = lane->offsetSeparatingBorders_;
252  target_lcdata->sourceOuterBorderDistance_fct = lane->offsetSourceOuterBorders_;
253  if(lane->lcb_.isLCDirectionLeft())
254  {
255  target_geometry->leftDistance_fct = lane->offsetTargetOuterBorders_;
256  target_geometry->rightDistance_fct = lane->offsetSeparatingBorders_;
257  }
258  else
259  {
260  target_geometry->leftDistance_fct = lane->offsetSeparatingBorders_;
261  target_geometry->rightDistance_fct = lane->offsetTargetOuterBorders_;
262  }
263  }
264 
265  void copy_lfg_to_lfg_proxy(std::shared_ptr<adore::env::BorderBased::LaneGeometryDataProxy> target,
267  {
268  target->isValid = source.isValid();
269  target->centerSmoothed_fct = source.m_centerSmoothed_fct;
270  target->leftDistance_fct = source.m_leftDistance_fct;
271  target->rightDistance_fct = source.m_rightDistance_fct;
272  target->centerNormal_fct = source.m_centerNormal_fct;
273  target->centerSmoothedCurvature_fct = source.m_centerSmoothedCurvature_fct;
274  target->centerSmoothedCurvatureDerivative_fct = source.m_centerSmoothedCurvatureDerivative_fct;
275  target->navigationCost_fct = source.m_navigationCost_fct;
276 
277  }
278  };
279  } // namespace apps
280 } // namespace adore
A node which computes lanefollowing and lanechange geometry and provides the results to subsequent mo...
Definition: lane_view_provider.h:40
adore::env::IndicatorHintManagement indicatorhint_manager_
Definition: lane_view_provider.h:61
adore::env::BorderBased::LaneChangeGeometry lcg_right_
Definition: lane_view_provider.h:50
void run()
update data, views and recompute maneuver
Definition: lane_view_provider.h:95
adore::env::BorderBased::LaneFollowingGeometry< 20, 200 > lfg_
Definition: lane_view_provider.h:42
void copy_ilcg(std::shared_ptr< adore::env::BorderBased::LaneGeometryDataProxy > target_geometry, std::shared_ptr< adore::env::BorderBased::LaneChangeDataProxy > target_lcdata, adore::env::BorderBased::IndependentLaneChangeGeometry *lane)
Definition: lane_view_provider.h:234
adore::params::APVehicle * apVehicle_
Definition: lane_view_provider.h:57
virtual ~LaneViewProvider()
Definition: lane_view_provider.h:85
adore::env::BorderBased::IndependentLaneChangeGeometry * ilcg_right_
Definition: lane_view_provider.h:64
adore::env::BorderBased::LocalRoadMap roadmap_
Definition: lane_view_provider.h:52
adore::env::BorderBased::LaneChangeGeometry lcg_left_
Definition: lane_view_provider.h:48
adore::params::APLaneFollowingView * apLFV_
Definition: lane_view_provider.h:53
adore::params::APTacticalPlanner * apTacticalPlanner_
Definition: lane_view_provider.h:56
adore::env::AFactory::TLaneGeometryWriter * writer_
Definition: lane_view_provider.h:58
adore::env::SpeedLimitManagement speedlimit_manager_
Definition: lane_view_provider.h:60
adore::params::APLaneChangeView * apLCV_
Definition: lane_view_provider.h:54
LaneViewProvider()
Definition: lane_view_provider.h:69
bool activate_lfg_rematching_
Definition: lane_view_provider.h:66
void copy_lfg_to_lfg_proxy(std::shared_ptr< adore::env::BorderBased::LaneGeometryDataProxy > target, adore::env::BorderBased::LaneFollowingGeometry< 20, 200 > const &source)
Definition: lane_view_provider.h:265
adore::env::AFactory::TResetLaneMatchingReader * reset_reader_
Definition: lane_view_provider.h:59
adore::params::APLateralPlanner * apLateralPlanner_
Definition: lane_view_provider.h:55
adore::env::BorderBased::IndependentLaneChangeGeometry * ilcg_left_
Definition: lane_view_provider.h:63
virtual TResetLaneMatchingReader * getResetLaneMatchingReader()=0
virtual TLaneGeometryWriter * getLaneGeometryWriter()=0
function_type2d normal_fct_
Definition: baseline.h:67
function_type_scalar curvatureDerivative_fct_
Definition: baseline.h:69
function_type_xyz position_fct_
Definition: baseline.h:66
function_type_scalar curvature_fct_
Definition: baseline.h:68
BAContainer * getBorders()
Get the Accumulated Borders.
Definition: borderaccumulator.h:386
A class for computation of the geometric information required to perform lane changes....
Definition: independentlanechangegeometry.h:34
LaneChangeBorders lcb_
Definition: independentlanechangegeometry.h:46
double getProgressGateOpen() const
Definition: independentlanechangegeometry.h:78
void setLookAhead(double value)
Definition: independentlanechangegeometry.h:66
bool isValid() const
Definition: independentlanechangegeometry.h:77
void update(double position_on_current, Iterator current_lf, Iterator first_lf, Iterator last_lf)
constructs a lane change geometry if a gate is available
Definition: independentlanechangegeometry.h:111
function_type_scalar navigationCost_fct_
Definition: independentlanechangegeometry.h:52
double getProgressGateClosed() const
Definition: independentlanechangegeometry.h:79
function_type_scalar offsetSeparatingBorders_
Definition: independentlanechangegeometry.h:49
Baseline baseline_
Definition: independentlanechangegeometry.h:47
void setSmoothness(double value)
Definition: independentlanechangegeometry.h:58
function_type_scalar offsetSourceOuterBorders_
Definition: independentlanechangegeometry.h:50
function_type_scalar offsetTargetOuterBorders_
Definition: independentlanechangegeometry.h:51
void setLookBehind(double value)
Definition: independentlanechangegeometry.h:71
void setMaximumNavCostIncrease(double value)
Definition: independentlanechangegeometry.h:62
bool isLCDirectionLeft()
Definition: lanechangeborders.h:57
A class with a geometry description of a lane next to the current lane.
Definition: lanechangegeometry.h:38
function_type_scalar m_navigationCost_fct
Definition: lanefollowinggeometry.h:61
void update(BorderSet *borderSet, BorderTrace *borderTrace, BorderCostMap *borderCost, Border *start, adore::env::VehicleMotionState9d *ego, double lookahead_distance, double lookbehind_distance, double smoothness=0.05, bool activate_navigation=false)
update the road geometry
Definition: lanefollowinggeometry.h:123
function_type2d m_centerNormal_fct
Definition: lanefollowinggeometry.h:55
BorderAccumulator * getRightBorders()
Get the right borders of the LaneFollowingGeometry.
Definition: lanefollowinggeometry.h:546
function_type_scalar m_centerSmoothedCurvature_fct
Definition: lanefollowinggeometry.h:57
function_type_scalar m_leftDistance_fct
Definition: lanefollowinggeometry.h:59
Border * getBestMatchingBorder(double X, double Y, double max_deviation)
Get the best matching border for a given ego position.
Definition: lanefollowinggeometry.h:564
bool isValid() const
Check whether the LaneFollowingGeometry is valid.
Definition: lanefollowinggeometry.h:606
function_type_xyz m_centerSmoothed_fct
Definition: lanefollowinggeometry.h:52
function_type_scalar m_centerSmoothedCurvatureDerivative_fct
Definition: lanefollowinggeometry.h:58
function_type_scalar m_rightDistance_fct
Definition: lanefollowinggeometry.h:60
Definition: localroadmap.h:38
BorderTrace * getBorderTrace()
Get the BorderTrace.
Definition: localroadmap.h:154
void update(bool matched_lane_proposal_valid=false, BorderID matched_lane_proposal_id=BorderID())
update the local road map
Definition: localroadmap.h:256
bool isNavigationActive()
transfers value of APLocalRoadMap->isNavigationActive is true
Definition: localroadmap.h:181
void updateEgoState()
update only the ego state
Definition: localroadmap.h:246
Border * getMatchedBorder()
Get the matched border.
Definition: localroadmap.h:163
VehicleMotionState9d getEgoState()
Definition: localroadmap.h:117
BorderCostMap * getBorderCostMap()
Get the BorderCostMap object.
Definition: localroadmap.h:172
BorderSet * getBorderSet()
Get the BorderSet object.
Definition: localroadmap.h:123
VehicleMotionState9d * getVehicleState()
Get the VehicleState.
Definition: localroadmap.h:141
static adore::env::AFactory * get()
Definition: afactory.h:236
automatically manage indicator hints based on current vehicle position
Definition: map_indicatorhint_management.h:34
void update(double const &egoX, double const &egoY)
Definition: map_indicatorhint_management.h:79
void const getFunctions(adore::mad::function_type_xyz &centerSmoothed_fct, adore::mad::function_type_scalar &leftOffset_fct, adore::mad::function_type_scalar &rightOffset_fct, adore::mad::function_type_scalar &left_indicator_hint_fct, adore::mad::function_type_scalar &right_indicator_hint_fct)
Definition: map_indicatorhint_management.h:132
automatically manage speed limit information based on current vehicle position
Definition: map_speedlimit_management.h:33
void update(double const &egoX, double const &egoY)
Definition: map_speedlimit_management.h:80
void setDefaultValue(double value)
Definition: map_speedlimit_management.h:79
void const getFunction(adore::mad::function_type_xyz &centerSmoothed_fct, adore::mad::function_type_scalar &leftOffset_fct, adore::mad::function_type_scalar &rightOffset_fct, adore::mad::function_type_scalar &speedLimitOutput_fct)
Definition: map_speedlimit_management.h:133
Definition: com_patterns.h:68
virtual void getData(T &value)=0
virtual bool hasUpdate() const =0
Definition: com_patterns.h:97
virtual void write(const T &value)=0
virtual bool canWriteMore() const =0
virtual APLateralPlanner * getLateralPlanner() const =0
virtual APTacticalPlanner * getTacticalPlanner() const =0
virtual APLaneFollowingView * getLaneFollowingView() const =0
virtual APVehicle * getVehicle() const =0
virtual APLaneChangeView * getLaneChangeView() const =0
abstract class containing parameters for a lane change view
Definition: ap_lane_change_view.h:25
virtual double getMaximumNavCostLoss() const =0
virtual double getLookBehind() const =0
virtual double getBaselineFitSmoothness() const =0
virtual double getLookAhead() const =0
abstract class containing parameters for a lane following view
Definition: ap_lane_following_view.h:25
virtual double getLookBehind() const =0
virtual double getLookAhead() const =0
virtual double getBaselineFitSmoothness() const =0
abstract class containing parameters related to configuring the lateral planner
Definition: ap_lateral_planner.h:26
virtual double getHardSafetyDistanceToLaneBoundary() const =0
getHardSafetyDistanceToLaneBoundary returns the minimum distance between lane boundary and vehicle si...
abstract classs containing parameters to configure aspects and constraints of the tactical planner
Definition: ap_tactical_planner.h:25
virtual double getGlobalSpeedLimit() const =0
abstract class for vehicle configuration related paremeters
Definition: ap_vehicle.h:29
virtual double get_bodyWidth() const =0
static adore::params::AFactory * get()
Definition: afactory.h:103
@ LEFT
Definition: alanechangeview.h:43
@ RIGHT
Definition: alanechangeview.h:43
Definition: areaofeffectconverter.h:20
This struct identifies a Border by the coordinates of the starting and the end point.
Definition: borderid.h:31
The border struct contains data of the smallest.
Definition: border.h:62
BorderID m_id
Definition: border.h:68
Definition: lanecombinedgeometry.h:27
std::shared_ptr< LaneGeometryDataProxy > center
Definition: lanecombinedgeometry.h:29
std::shared_ptr< LaneChangeDataProxy > rightChange
Definition: lanecombinedgeometry.h:35
std::shared_ptr< LaneChangeDataProxy > leftChange
Definition: lanecombinedgeometry.h:33
std::shared_ptr< LaneGeometryDataProxy > right
Definition: lanecombinedgeometry.h:34
std::shared_ptr< LaneGeometryDataProxy > left
Definition: lanecombinedgeometry.h:30
double getX() const
Get the x-coordinate.
Definition: vehiclemotionstate9d.h:54
double getY() const
Get the y-coordinate.
Definition: vehiclemotionstate9d.h:60