ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
test_trajectory_planner.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ß - initial implementation
13  ********************************************************************************/
14 
15 #pragma once
16 
17 #include <adore/view/alane.h>
18 #include <adore/fun/afactory.h>
20 #include <adore/env/afactory.h>
21 #include <adore/params/afactory.h>
25 
26 namespace adore
27 {
28  namespace apps
29  {
35  {
36  private:
50  public:
52  adore::fun::AFactory* funFactory,
53  adore::params::AFactory* PARAMS_Factory)
54  :envFactory_(envFactory),funFactory_(funFactory),paramsFactory_(PARAMS_Factory),
55  roadmap_(envFactory,paramsFactory_),trafficMap_(roadmap_.getBorderSet(),envFactory),
57  {
59  pTacticalPlanner_ = PARAMS_Factory->getTacticalPlanner();
60  planner_ = new TPlanner(&lfv_,nullptr,nullptr,nullptr,
61  PARAMS_Factory->getLongitudinalPlanner(),
62  PARAMS_Factory->getLateralPlanner(),
63  PARAMS_Factory->getTacticalPlanner(),
64  pvehicle_,
65  PARAMS_Factory->getTrajectoryGeneration());
66  xreader_ = funFactory->getVehicleMotionStateReader();
67  wwriter_ = funFactory->getSetPointRequestWriter();
68  }
73  void run()
74  {
75  roadmap_.update();
77  lfv_.update();
79  auto x_replan = x_;
80  bool reset = true;
81  if(planner_->hasValidPlan())
82  {
83  auto spr = planner_->getSetPointRequest();
84  double t = x_.getTime();
85  if( spr->isActive(t) )
86  {
87  auto x_ref = spr->interpolateReference(t,pvehicle_);
88  double dx = x_.getX()-x_ref.getX();
89  double dy = x_.getY()-x_ref.getY();
90  if(dx*dx+dy*dy<pTacticalPlanner_->getResetRadius())
91  {
92  x_replan.setX(x_ref.getX());
93  x_replan.setY(x_ref.getY());
94  x_replan.setPSI(x_ref.getPSI());
95  x_replan.setvx(x_ref.getvx());
96  x_replan.setvy(x_ref.getvy());
97  x_replan.setOmega(x_ref.getOmega());
98  x_replan.setAx(x_ref.getAx());
99  x_replan.setDelta(x_ref.getDelta());
100  reset = false;
101  }
102  }
103  }
104  if(reset)std::cout<<"TestTrajectoryPlanner: Reset initial state.\n";
105  planner_->compute(x_replan);
107  }
109  {
110  return planner_->hasValidPlan();
111  }
113  {
114  return planner_->getProgressSolver();
115  }
117  {
118  return planner_->getOffsetSolver();
119  }
121  {
122  return planner_->getSetPointRequest();
123  }
125  {
127  }
128  };
129  }
130 }
test implementation of a lane following trajectory planner
Definition: test_trajectory_planner.h:35
TPlanner * planner_
Definition: test_trajectory_planner.h:49
adore::params::APVehicle * pvehicle_
Definition: test_trajectory_planner.h:41
adore::fun::VehicleMotionState9d x_
Definition: test_trajectory_planner.h:48
adore::fun::DecoupledLFLCPlanner< 20, 5 >::TProgressSolver & getProgressSolver()
Definition: test_trajectory_planner.h:112
adore::mad::AWriter< adore::fun::SetPointRequest > * wwriter_
Definition: test_trajectory_planner.h:47
TestTrajectoryPlanner(adore::env::AFactory *envFactory, adore::fun::AFactory *funFactory, adore::params::AFactory *PARAMS_Factory)
Definition: test_trajectory_planner.h:51
const adore::fun::SetPointRequest * getSetPointRequest()
Definition: test_trajectory_planner.h:120
adore::env::BorderBased::LocalRoadMap roadmap_
Definition: test_trajectory_planner.h:43
void run()
update function of the trajectory planner
Definition: test_trajectory_planner.h:73
adore::env::traffic::TrafficMap trafficMap_
Definition: test_trajectory_planner.h:44
adore::params::AFactory * paramsFactory_
Definition: test_trajectory_planner.h:40
adore::params::APTacticalPlanner * pTacticalPlanner_
Definition: test_trajectory_planner.h:42
adore::env::BorderBased::LaneFollowingView lfv_
Definition: test_trajectory_planner.h:45
adore::fun::RoadCoordinateConverter & getRoadCoordinateConverter()
Definition: test_trajectory_planner.h:124
adore::fun::DecoupledLFLCPlanner< 20, 5 >::TOffsetSolver & getOffsetSolver()
Definition: test_trajectory_planner.h:116
bool hasValidPlan()
Definition: test_trajectory_planner.h:108
adore::mad::AReader< adore::fun::VehicleMotionState9d > * xreader_
Definition: test_trajectory_planner.h:46
adore::fun::BasicLaneFollowingPlanner< 20, 5 > TPlanner
Definition: test_trajectory_planner.h:37
adore::fun::AFactory * funFactory_
Definition: test_trajectory_planner.h:39
adore::env::AFactory * envFactory_
Definition: test_trajectory_planner.h:38
abstract factory for adore::env communication
Definition: afactory.h:41
virtual TVehicleMotionStateReader * getVehicleMotionStateReader()=0
LaneFollowingview provides traffic related information for the current lane.
Definition: lanefollowingview.h:42
void update()
update the LaneFollowingView
Definition: lanefollowingview.h:87
Definition: localroadmap.h:38
void update(bool matched_lane_proposal_valid=false, BorderID matched_lane_proposal_id=BorderID())
update the local road map
Definition: localroadmap.h:256
Definition: trafficmap.h:36
void update()
Update the TrafficMap.
Definition: trafficmap.h:126
Definition: basiclanefollowingplanner.h:37
virtual const SetPointRequest * getSetPointRequest() const override
Definition: decoupled_lflc_planner.h:491
TProgressSolver & getProgressSolver()
Definition: decoupled_lflc_planner.h:335
virtual bool hasValidPlan() const override
Definition: decoupled_lflc_planner.h:484
TOffsetSolver & getOffsetSolver()
Definition: decoupled_lflc_planner.h:339
RoadCoordinateConverter & getRoadCoordinateConverter()
Definition: decoupled_lflc_planner.h:343
virtual void compute(const VehicleMotionState9d &initial_state) override
Definition: decoupled_lflc_planner.h:372
Definition: roadcoordinates.h:46
Definition: setpointrequest.h:35
virtual void getData(T &value)=0
virtual void write(const T &value)=0
Definition: lq_oc_single_shooting.h:61
abstract factory for adore::params classes
Definition: afactory.h:54
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
abstract class for vehicle configuration related paremeters
Definition: ap_vehicle.h:29
Definition: areaofeffectconverter.h:20
This struct holds the motion state of the vehicle in 9d.
Definition: vehiclemotionstate9d.h:39
double getX() const
Get the x-coordinate.
Definition: vehiclemotionstate9d.h:54
double getY() const
Get the y-coordinate.
Definition: vehiclemotionstate9d.h:60
double getTime() const
Get the time.
Definition: vehiclemotionstate9d.h:48