Apollo  6.0
Open source self driving car software
lon_controller.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2017 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
22 #pragma once
23 
24 #include <memory>
25 #include <string>
26 #include <vector>
27 
28 #include "modules/common/configs/proto/vehicle_config.pb.h"
36 
41 namespace apollo {
42 namespace control {
43 
49 class LonController : public Controller {
50  public:
54  LonController();
55 
59  virtual ~LonController();
60 
66  common::Status Init(std::shared_ptr<DependencyInjector> injector,
67  const ControlConf *control_conf) override;
68 
79  const localization::LocalizationEstimate *localization,
80  const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory,
81  control::ControlCommand *cmd) override;
82 
87  common::Status Reset() override;
88 
92  void Stop() override;
93 
98  std::string Name() const override;
99 
100  protected:
101  void ComputeLongitudinalErrors(const TrajectoryAnalyzer *trajectory,
102  const double preview_time, const double ts,
103  SimpleLongitudinalDebug *debug);
104 
105  void GetPathRemain(SimpleLongitudinalDebug *debug);
106 
107  private:
108  void SetDigitalFilterPitchAngle(const LonControllerConf &lon_controller_conf);
109 
110  void LoadControlCalibrationTable(
111  const LonControllerConf &lon_controller_conf);
112 
113  void SetDigitalFilter(double ts, double cutoff_freq,
114  common::DigitalFilter *digital_filter);
115 
116  void CloseLogFile();
117 
118  const localization::LocalizationEstimate *localization_ = nullptr;
119  const canbus::Chassis *chassis_ = nullptr;
120 
121  std::unique_ptr<Interpolation2D> control_interpolation_;
122  const planning::ADCTrajectory *trajectory_message_ = nullptr;
123  std::unique_ptr<TrajectoryAnalyzer> trajectory_analyzer_;
124 
125  std::string name_;
126  bool controller_initialized_ = false;
127 
128  double previous_acceleration_ = 0.0;
129  double previous_acceleration_reference_ = 0.0;
130 
131  PIDController speed_pid_controller_;
132  PIDController station_pid_controller_;
133 
134  LeadlagController speed_leadlag_controller_;
135  LeadlagController station_leadlag_controller_;
136 
137  FILE *speed_log_file_ = nullptr;
138 
139  common::DigitalFilter digital_filter_pitch_angle_;
140 
141  const ControlConf *control_conf_ = nullptr;
142 
143  // vehicle parameter
144  common::VehicleParam vehicle_param_;
145 
146  std::shared_ptr<DependencyInjector> injector_;
147 };
148 } // namespace control
149 } // namespace apollo
Defines the PIDBCController class.
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
common::Status Init(std::shared_ptr< DependencyInjector > injector, const ControlConf *control_conf) override
initialize Longitudinal Controller
void Stop() override
stop longitudinal controller
std::string Name() const override
longitudinal controller name
base class for all controllers.
Definition: controller.h:46
void ComputeLongitudinalErrors(const TrajectoryAnalyzer *trajectory, const double preview_time, const double ts, SimpleLongitudinalDebug *debug)
process point query and conversion related to trajectory
Definition: trajectory_analyzer.h:44
Defines the DigitalFilter class.
void GetPathRemain(SimpleLongitudinalDebug *debug)
Defines the Controller base class.
Functions to generate coefficients for digital filter.
A lead/lag controller for speed and steering using defualt integral hold.
Definition: leadlag_controller.h:38
The DigitalFilter class is used to pass signals with a frequency lower than a certain cutoff frequenc...
Definition: digital_filter.h:40
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
common::Status ComputeControlCommand(const localization::LocalizationEstimate *localization, const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory, control::ControlCommand *cmd) override
compute brake / throttle values based on current vehicle status and target trajectory ...
A proportional-integral-derivative controller for speed and steering using defualt integral hold...
Definition: pid_controller.h:38
Longitudinal controller, to compute brake / throttle values.
Definition: lon_controller.h:49
common::Status Reset() override
reset longitudinal controller
virtual ~LonController()
destructor
Defines the TrajectoryAnalyzer class.