Apollo 11.0
自动驾驶开放平台
lon_plus_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/control/control_task_base_extend/proto/pid_plus_conf.pb.h"
29
30#include "modules/common_msgs/chassis_msgs/chassis.pb.h"
31#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
32#include "modules/control/controllers/lon_based_pid_plus_controller/proto/lon_based_pid_plus_controller_conf.pb.h"
33#include "modules/control/control_task_base_extend/proto/params_pipeline.pb.h"
34
35#include "cyber/cyber.h"
47
52namespace apollo {
53namespace control {
54
61public:
66
70 virtual ~LonPlusController();
71
77 common::Status Init(std::shared_ptr<DependencyInjector> injector) override;
78
89 const localization::LocalizationEstimate *localization,
90 const canbus::Chassis *chassis,
91 const planning::ADCTrajectory *trajectory,
92 control::ControlCommand *cmd) override;
93
98 common::Status Reset() override;
99
103 void Stop() override;
104
109 std::string Name() const override;
110
111protected:
112 bool LoadParams(ParamsPipeline *params_pipeline);
113
115 const TrajectoryAnalyzer *trajectory,
116 const double preview_time,
117 const double ts,
118 const double vehicle_speed,
120
122
123 std::shared_ptr<DependencyInjector> injector_;
124
125private:
126 void SetDigitalFilterPitchAngle();
127
128 void InitControlCalibrationTable(calibration_table calibration_table);
129
130 void SetDigitalFilter(double ts, double cutoff_freq, common::DigitalFilter *digital_filter);
131
132 bool SetCurrentParam(
133 const std::string param_config_name,
134 LonBasedPidPlusControllerConf &current_lon_based_pidcontroller_conf);
135
136 bool ChooseCurrentParam(
137 const planning::ADCTrajectory *trajectory_msg,
138 const double vehicle_speed,
139 LonBasedPidPlusControllerConf &current_lon_based_pidcontroller_conf);
140
141 bool SetCurrentCalibrationTable(
142 const std::string calibration_table_config_name,
143 calibration_table &current_calibration_table_conf);
144
145 bool ChooseCurrentCalibrationTable(calibration_table &current_calibration_table_conf);
146
147 bool IsStopByDestination(SimpleLongitudinalDebug *debug);
148
149 bool IsPedestrianStopLongTerm(SimpleLongitudinalDebug *debug);
150
151 bool IsFullStopLongTerm(SimpleLongitudinalDebug *debug);
152
153 void SetParkingBrake(const LonBasedPidPlusControllerConf *conf, control::ControlCommand *control_command);
154
155 void CloseLogFile();
156
157 void CalcultePidParams(const double &speed, PidPlusConf &pid_plus_conf);
158 void NewFullStop(SimpleLongitudinalDebug *debug, double &acceleration_cmd);
159 void check_slip();
160 void ResetNewFullStop();
161 void CheckFinishToElse(const planning::ADCTrajectory *trajectory_message);
162
163 double calculte_speed_enter_stop(SimpleLongitudinalDebug *debug);
164
165 const localization::LocalizationEstimate *localization_ = nullptr;
166 const canbus::Chassis *chassis_ = nullptr;
167
168 std::unique_ptr<Interpolation2D> control_interpolation_;
169 const planning::ADCTrajectory *trajectory_message_ = nullptr;
170 std::unique_ptr<TrajectoryAnalyzer> trajectory_analyzer_;
171
172 std::string name_;
173 bool controller_initialized_ = false;
174
175 double previous_acceleration_ = 0.0;
176 double previous_acceleration_reference_ = 0.0;
177
178 PIDPlusController speed_pid_controller_;
179 PIDPlusController station_pid_controller_;
180
181 LeadlagPlusController speed_leadlag_controller_;
182 LeadlagPlusController station_leadlag_controller_;
183
184 FILE *speed_log_file_ = nullptr;
185
186 common::DigitalFilter digital_filter_pitch_angle_;
187
188 calibration_table calibration_table_;
189 std::vector<std::pair<std::string, calibration_table>> calibration_table_list_;
190 double previous_calibration_table_size_ = 0.0;
191 std::string current_calibration_table_config_name_ = "";
192
193 ParamsPipeline params_pipeline_;
194 std::vector<std::pair<std::string, LonBasedPidPlusControllerConf>> params_list_;
195 LonBasedPidPlusControllerConf lon_based_pidcontroller_conf_;
196 LonBasedPidPlusControllerConf current_lon_based_pidcontroller_conf_;
197 std::string current_param_config_name_ = "";
198
199 // vehicle parameter
200 common::VehicleParam vehicle_param_;
201
202 bool is_stop_by_pedestrian_ = false;
203 bool is_stop_by_pedestrian_previous_ = false;
204 double start_time_ = 0.0;
205 double wait_time_diff_ = 0.0;
206
207 bool is_full_stop_previous_ = false;
208 double is_full_stop_start_time_ = 0.0;
209 int is_full_stop_wait_time_diff_ = 0;
210
211 bool epb_on_change_switch_ = true;
212 bool epb_off_change_switch_ = true;
213 int epb_change_count_ = 0;
214 int smode_num_ = 0;
215
216 double standstill_narmal_acceleration_ = 0.0;
217 double stop_gain_acceleration_ = 0.0;
218 double max_path_remain_when_stopped_ = 0.0;
219 bool parking_release_ = false;
220
221 double dec_hold_on_slope_ = 0.0;
222 bool is_slipping_ = false;
223 bool enable_stop_control_ = false;
224 double stop_dec_square_error_ = 0.0;
225 double acc_control_rate_ = 0.0;
226 double previous_acc_output_ = 0.0;
227
228 bool previous_is_full_stop_ = false;
229 bool form_go_to_full_stop_ = false;
230 bool begin_end_brake_ = false;
231
232 double fullstop_in_brake_ = 0.0;
233 int fullstop_window_count_ = 0;
234 double hillup_fullstop_brake_rate_ = 0.0;
235
236 double reference_spd_ = 0.0;
237 double reference_spd_cmd_ = 0.0;
238
239 bool from_finish_to_else_ = false;
240 bool previous_is_finish_ = false;
241 bool is_need_restart_pedestrian_init_time_ = true;
242
243 double openspace_speed_control_throttle_cmd_ = 0.0;
244 double openspace_speed_control_brake_cmd_ = 0.0;
245 int openspace_count_ = 0;
246
247 double current_trajectory_timestamp_ = -1.0;
248 double pre_trajectory_timestamp_ = -1.0;
249
250 double last_speed_ = 0.0;
251};
252
253// 1.2 当前类声明为插件
255
256} // namespace control
257} // 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
Longitudinal controller, to compute brake / throttle values.
bool LoadParams(ParamsPipeline *params_pipeline)
std::shared_ptr< DependencyInjector > injector_
void ComputeLongitudinalErrors(const TrajectoryAnalyzer *trajectory, const double preview_time, const double ts, const double vehicle_speed, SimpleLongitudinalDebug *debug)
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 Reset() override
reset longitudinal controller
std::string Name() const override
longitudinal controller name
void GetPathRemain(SimpleLongitudinalDebug *debug)
common::Status Init(std::shared_ptr< DependencyInjector > injector) override
initialize Longitudinal Controller
void Stop() override
stop longitudinal controller
A proportional-integral-derivative controller for speed and steering using defualt integral hold
process point query and conversion related to trajectory
Math-related util functions.
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 TrajectoryAnalyzer class.