Apollo 10.0
自动驾驶开放平台
lon_controller.h
浏览该文件的文档.
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_msgs/chassis_msgs/chassis.pb.h"
29#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
30#include "modules/control/controllers/lon_based_pid_controller/proto/lon_based_pid_controller_conf.pb.h"
31
32#include "cyber/cyber.h"
42
47namespace apollo {
48namespace control {
49
55class LonController : public ControlTask {
56 public:
61
65 virtual ~LonController();
66
72 common::Status Init(std::shared_ptr<DependencyInjector> injector) override;
73
84 const localization::LocalizationEstimate *localization,
85 const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory,
86 control::ControlCommand *cmd) override;
87
92 common::Status Reset() override;
93
97 void Stop() override;
98
103 std::string Name() const override;
104
105 protected:
106 void ComputeLongitudinalErrors(const TrajectoryAnalyzer *trajectory,
107 const double preview_time, const double ts,
109
111
112 std::shared_ptr<DependencyInjector> injector_;
113
114 private:
115 void SetDigitalFilterPitchAngle();
116
117 void InitControlCalibrationTable();
118
119 void SetDigitalFilter(double ts, double cutoff_freq,
120 common::DigitalFilter *digital_filter);
121
122 bool IsStopByDestination(SimpleLongitudinalDebug *debug);
123
124 bool IsPedestrianStopLongTerm(SimpleLongitudinalDebug *debug);
125
126 bool IsFullStopLongTerm(SimpleLongitudinalDebug *debug);
127
128 void SetParkingBrake(const LonBasedPidControllerConf *conf,
129 control::ControlCommand *control_command);
130
131 void CloseLogFile();
132
133 const localization::LocalizationEstimate *localization_ = nullptr;
134 const canbus::Chassis *chassis_ = nullptr;
135
136 std::unique_ptr<Interpolation2D> control_interpolation_;
137 const planning::ADCTrajectory *trajectory_message_ = nullptr;
138 std::unique_ptr<TrajectoryAnalyzer> trajectory_analyzer_;
139
140 std::string name_;
141 bool controller_initialized_ = false;
142
143 double previous_acceleration_ = 0.0;
144 double reference_spd_ = 0.0;
145 double reference_spd_cmd_ = 0.0;
146 double previous_acceleration_reference_ = 0.0;
147
148 PIDController speed_pid_controller_;
149 PIDController station_pid_controller_;
150
151 LeadlagController speed_leadlag_controller_;
152 LeadlagController station_leadlag_controller_;
153
154 FILE *speed_log_file_ = nullptr;
155
156 common::DigitalFilter digital_filter_pitch_angle_;
157
158 LonBasedPidControllerConf lon_based_pidcontroller_conf_;
159 calibration_table calibration_table_;
160
161 // vehicle parameter
162 common::VehicleParam vehicle_param_;
163
164 bool is_stop_by_pedestrian_ = false;
165 bool is_stop_by_pedestrian_previous_ = false;
166 double start_time_ = 0.0;
167 double wait_time_diff_ = 0.0;
168
169 bool is_full_stop_previous_ = false;
170 double is_full_stop_start_time_ = 0.0;
171 double is_full_stop_wait_time_diff_ = 0.0;
172
173 bool epb_on_change_switch_ = true;
174 bool epb_off_change_switch_ = true;
175 int epb_change_count_ = 0;
176 int smode_num_ = 0;
177
178 double standstill_narmal_acceleration_ = 0.0;
179 double stop_gain_acceleration_ = 0.0;
180 double max_path_remain_when_stopped_ = 0.0;
181 bool parking_release_ = false;
182};
183
184// 1.2 当前类声明为插件
187
188} // namespace control
189} // namespace apollo
The DigitalFilter class is used to pass signals with a frequency lower than a certain cutoff frequenc...
A general class to denote the return status of an API call.
Definition status.h:43
A lead/lag controller for speed and steering using defualt integral hold
Longitudinal controller, to compute brake / throttle values.
void GetPathRemain(SimpleLongitudinalDebug *debug)
void Stop() override
stop longitudinal controller
common::Status Reset() override
reset longitudinal controller
virtual ~LonController()
destructor
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
common::Status Init(std::shared_ptr< DependencyInjector > injector) override
initialize Longitudinal Controller
void ComputeLongitudinalErrors(const TrajectoryAnalyzer *trajectory, const double preview_time, const double ts, SimpleLongitudinalDebug *debug)
std::shared_ptr< DependencyInjector > injector_
std::string Name() const override
longitudinal controller name
A proportional-integral-derivative controller for speed and steering using defualt integral hold
process point query and conversion related to trajectory
Defines the Controller base class.
#define CYBER_PLUGIN_MANAGER_REGISTER_PLUGIN(name, base)
Defines the DigitalFilter class.
Functions to generate coefficients for digital filter.
class register implement
Definition arena_queue.h:37
Defines the PIDBCController class.
Defines the TrajectoryAnalyzer class.