ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
trajectory_planner_lm.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ß - trajectory planner for lane following maneuvers
13  ********************************************************************************/
14 
15 
16 #pragma once
17 
18 #include <adore/fun/afactory.h>
19 #include <adore/env/afactory.h>
20 #include <adore/params/afactory.h>
31 
32 
33 namespace adore
34 {
35  namespace apps
36  {
42  {
43  private:
47  TEmergencyPlanner* emergency_planner_;//switched direction wrt to lc
48 
65  int id_;
66  std::string plannerName_;
68  public:
70  {
71  delete nominal_planner_;
72  delete emergency_planner_;
73  }
74  TrajectoryPlannerLM(bool directionLeft,std::string name,int id):
75  connectionSet_(adore::env::EnvFactoryInstance::get()->getVehicleMotionStateReader(),
76  adore::env::EnvFactoryInstance::get()->getControlledConnectionFeed()),
77  checkPointSet_(adore::env::EnvFactoryInstance::get()->getVehicleMotionStateReader(),
78  adore::env::EnvFactoryInstance::get()->getCheckPointFeed()),
79  ngo_(adore::env::EnvFactoryInstance::get(),three_lanes_.getCurrentLane(),0,0),
80  prediction_(),
82  directionLeft_(directionLeft)
83  {
84  id_ = id;
85  plannerName_ = name;
94  auto lcv = directionLeft
97  //create nominal planner and add additional constraints
99  lcv,
100  &ngo_,
103  pLongitudinalPlanner,
104  pLateralPlanner,
105  pTacticalPlanner,
106  pvehicle_,
108 
109  //create emergency planner
111  pLateralPlanner,
112  pTacticalPlanner,
113  pvehicle_,
120 
121  }
126  virtual void computeTrajectory(const adore::fun::PlanningRequest& planning_request, adore::fun::PlanningResult& planning_result) override
127  {
128  //document planner result
129  planning_result.id = id_;
130  planning_result.name = plannerName_;
132  planning_result.iteration = planning_request.iteration;
133  planning_result.nominal_maneuver_valid = false;
134  planning_result.combined_maneuver_valid = false;
135 
137  ngo_.update();
142  auto current = three_lanes_.getCurrentLane();
143  auto lcv = directionLeft_
146  auto target = lcv->getSourceLane();//(switched direction wrt to lc)
147  auto source = lcv->getTargetLane();//(switched direction wrt to lc)
148 
149  if(!current->isValid())
150  {
151  planning_result.status_string = "target lane invalid";
152  return;
153  }
154  if(!source->isValid())
155  {
156  planning_result.status_string = "source lane invalid";
157  return;
158  }
159  if(lcv->getNavigationCostDifference()<0)
160  {
161  planning_result.status_string = "lm not required for navigation";
162  return;
163  }
164 
166 
169  {
170  planning_result.status_string = "nominal maneuver planning failed, "+ nominal_planner_->getStatus();
171  return;
172  }
173 
175 
177  if(!re.isValid(planning_result.nominal_maneuver))
178  {
179  planning_result.status_string = "not restarting, maneuver too short";
180  return;
181  }
182 
183 
184  planning_result.nominal_maneuver_valid = true;
186  bool valid_em_found = false;
187 
188  emergency_planner_->compute(x0em.toMotionState());
190  {
192  planning_result.combined_maneuver.removeAfter(planning_request.t_emergency_start);
193  planning_result.combined_maneuver.setPoints.back().tEnd = planning_request.t_emergency_start;
195  if(collision_detection_.isValid(planning_result.combined_maneuver))
196  {
197  valid_em_found = true;
198  }
199  else
200  {
201  planning_result.combined_maneuver.setPoints.clear();
202  }
203 
204  }
205 
206  if(!valid_em_found)
207  {
208  planning_result.status_string += "emergency maneuver planning failed";
209  return;
210  }
211 
213  if(planning_result.combined_maneuver.setPoints.size()==0)
214  {
215  planning_result.status_string = "stopping";
216  return;
217  }
218 
219  planning_result.combined_maneuver_valid = true;
220  int laneid = directionLeft_?1:-1;
222  planning_result.objective_values.insert({navcostOnLane.getName(),
223  navcostOnLane.getCost(planning_result.nominal_maneuver)});
224 
226  planning_result.objective_values.insert({navcostNormalized.getName(),
227  navcostNormalized.getCost(planning_result.nominal_maneuver)});
228 
230  planning_result.objective_values.insert({lacccost.getName(),
231  lacccost.getCost(planning_result.nominal_maneuver)});
232 
234  planning_result.objective_values.insert({ljerkcost.getName(),
235  ljerkcost.getCost(planning_result.nominal_maneuver)});
236 
238  planning_result.objective_values.insert({progressLoss.getName(),
239  progressLoss.getCost(planning_result.nominal_maneuver)});
240  }
241  };
242  }
243 }
Base class for different trajectory planners: Handles communication w/ decision making module....
Definition: trajectory_planner_base.h:31
Decoupled trajectory planner, which uses TrajectoryPlannerBase to compute and provide a PlanningResul...
Definition: trajectory_planner_lm.h:42
TNominalPlanner * nominal_planner_
Definition: trajectory_planner_lm.h:46
bool directionLeft_
Definition: trajectory_planner_lm.h:67
adore::fun::BasicMergePlanner< 20, 5 > TNominalPlanner
Definition: trajectory_planner_lm.h:44
adore::env::ThreeLaneViewDecoupled three_lanes_
Definition: trajectory_planner_lm.h:57
std::string plannerName_
Definition: trajectory_planner_lm.h:66
adore::fun::SPRInvariantCollisionFreedom collision_detection_
Definition: trajectory_planner_lm.h:63
adore::env::NavigationGoalObserver ngo_
Definition: trajectory_planner_lm.h:52
adore::params::APVehicle * pvehicle_
Definition: trajectory_planner_lm.h:49
adore::env::ConnectionsOnLane * checkPointsOnLane_
Definition: trajectory_planner_lm.h:56
adore::params::APTrajectoryGeneration * pTrajectoryGeneration_
Definition: trajectory_planner_lm.h:51
adore::fun::MergeMRMPlanner< 20, 5 > TEmergencyPlanner
Definition: trajectory_planner_lm.h:45
adore::params::APTacticalPlanner * pTacticalPlanner_
Definition: trajectory_planner_lm.h:50
adore::env::ConnectionsOnLane * connectionsOnLane_
Definition: trajectory_planner_lm.h:55
adore::env::DecoupledTrafficPredictionView prediction_
Definition: trajectory_planner_lm.h:58
virtual void computeTrajectory(const adore::fun::PlanningRequest &planning_request, adore::fun::PlanningResult &planning_result) override
update data, views and recompute maneuver
Definition: trajectory_planner_lm.h:126
adore::env::ControlledConnectionSet4Ego connectionSet_
Definition: trajectory_planner_lm.h:53
adore::env::ControlledConnectionSet4Ego checkPointSet_
Definition: trajectory_planner_lm.h:54
int id_
Definition: trajectory_planner_lm.h:65
TEmergencyPlanner * emergency_planner_
Definition: trajectory_planner_lm.h:47
TrajectoryPlannerLM(bool directionLeft, std::string name, int id)
Definition: trajectory_planner_lm.h:74
virtual ~TrajectoryPlannerLM()
Definition: trajectory_planner_lm.h:69
Definition: connectionsonlane.h:33
void update()
Definition: connectionsonlane.h:82
Specialization of ControlledConnectionSet: Filters connections in range of ego.
Definition: controlledconnection.h:232
virtual void update()
Definition: controlledconnection.h:243
Definition: decoupledtrafficpredictionview.h:24
void update()
Definition: decoupledtrafficpredictionview.h:43
Definition: navigationgoalobserver.h:31
void update()
Definition: navigationgoalobserver.h:56
Definition: threelaneviewdecoupled.h:32
virtual adore::view::ALaneChangeView * getLeftLaneChange()
Definition: threelaneviewdecoupled.h:412
virtual adore::view::ALaneChangeView * getRightLaneChange()
Definition: threelaneviewdecoupled.h:419
virtual adore::view::ALane * getCurrentLane()
Definition: threelaneviewdecoupled.h:405
void update()
Definition: threelaneviewdecoupled.h:373
Definition: basicmergeplanner.h:38
virtual const SetPointRequest * getSetPointRequest() const override
Definition: decoupled_lflc_planner.h:491
std::string getStatus()
Definition: decoupled_lflc_planner.h:348
virtual bool hasValidPlan() const override
Definition: decoupled_lflc_planner.h:484
virtual void compute(const VehicleMotionState9d &initial_state) override
Definition: decoupled_lflc_planner.h:372
virtual const SetPointRequest * getSetPointRequest() const
Definition: mrmplanner.h:273
void setAMin(double value)
Definition: mrmplanner.h:55
void setTStall(double value)
Definition: mrmplanner.h:53
virtual void compute(const VehicleMotionState9d &initial_state)
Definition: mrmplanner.h:175
void setJMax(double value)
Definition: mrmplanner.h:52
void setAStall(double value)
Definition: mrmplanner.h:54
void setSecondAttempt(bool value)
Definition: mrmplanner.h:56
virtual bool hasValidPlan() const
Definition: mrmplanner.h:266
Plans minimum risk maneuver to cancel lane change.
Definition: mergemrmplanner.h:35
Definition: basicsetpointrequestevaluators.h:423
virtual bool isValid(const adore::fun::SetPointRequest &spr) const override
Definition: basicsetpointrequestevaluators.h:433
Definition: basicsetpointrequestevaluators.h:148
virtual double getCost(const adore::fun::SetPointRequest &spr) const override
Definition: basicsetpointrequestevaluators.h:155
virtual std::string getName() const override
Definition: basicsetpointrequestevaluators.h:154
Definition: basicsetpointrequestevaluators.h:32
virtual bool isValid(const adore::fun::SetPointRequest &spr) const override
Definition: basicsetpointrequestevaluators.h:46
Definition: basicsetpointrequestevaluators.h:364
virtual std::string getName() const override
Definition: basicsetpointrequestevaluators.h:366
virtual double getCost(const adore::fun::SetPointRequest &spr) const override
Definition: basicsetpointrequestevaluators.h:367
Definition: basicsetpointrequestevaluators.h:378
virtual double getCost(const adore::fun::SetPointRequest &spr) const override
Definition: basicsetpointrequestevaluators.h:381
virtual std::string getName() const override
Definition: basicsetpointrequestevaluators.h:380
Definition: basicsetpointrequestevaluators.h:178
virtual std::string getName() const override
Definition: basicsetpointrequestevaluators.h:189
virtual double getCost(const adore::fun::SetPointRequest &spr) const override
Definition: basicsetpointrequestevaluators.h:190
Definition: basicsetpointrequestevaluators.h:256
virtual double getCost(const adore::fun::SetPointRequest &spr) const override
Definition: basicsetpointrequestevaluators.h:268
virtual std::string getName() const override
Definition: basicsetpointrequestevaluators.h:267
void cropAfterFirstStop(double vxslow)
remove SetPoints after first stop Method looks for first downward zero crossing of vx and removes all...
Definition: setpointrequest.h:412
SetPoint interpolateSetPoint(double t, adore::params::APVehicle *p) const
Definition: setpointrequest.h:145
void removeAfter(double t)
Definition: setpointrequest.h:211
void copyTo(SetPointRequest &destination) const
Definition: setpointrequest.h:293
std::vector< SetPoint > setPoints
Definition: setpointrequest.h:38
VehicleMotionState9d toMotionState() const
Definition: setpoint.h:46
virtual APLateralPlanner * getLateralPlanner() const =0
virtual APTacticalPlanner * getTacticalPlanner() const =0
virtual APTrajectoryGeneration * getTrajectoryGeneration() const =0
virtual APVehicle * getVehicle() const =0
virtual APLongitudinalPlanner * getLongitudinalPlanner() const =0
abstract classs containing parameters to configure aspects and constraints of the tactical planner
Definition: ap_tactical_planner.h:25
virtual double getTerminateAfterFirstStopThresholdSpeed() const =0
abstract class containing parameters to configure the behaviour of trajectory generation
Definition: ap_trajectory_generation.h:26
abstract class for vehicle configuration related paremeters
Definition: ap_vehicle.h:29
static adore::params::AFactory * get()
Definition: afactory.h:103
virtual ALane * getSourceLane()=0
Definition: areaofeffectconverter.h:20
Definition: planning_request.h:22
double t_emergency_start
Definition: planning_request.h:26
SetPoint initial_state
Definition: planning_request.h:27
long long int iteration
Definition: planning_request.h:23
Definition: planning_result.h:29
bool combined_maneuver_valid
Definition: planning_result.h:64
std::string name
Definition: planning_result.h:32
static const int NOMINAL_DRIVING
Definition: planning_result.h:75
std::string status_string
Definition: planning_result.h:65
std::unordered_map< std::string, double > objective_values
Definition: planning_result.h:68
int id
Definition: planning_result.h:30
int maneuver_type
Definition: planning_result.h:72
bool nominal_maneuver_valid
Definition: planning_result.h:63
int iteration
Definition: planning_result.h:31
SetPointRequest nominal_maneuver
Definition: planning_result.h:33
SetPointRequest combined_maneuver
Definition: planning_result.h:35