Apollo 11.0
自动驾驶开放平台
anti_slip_control_task.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 <algorithm>
25#include <memory>
26#include <string>
27#include <vector>
28
29#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
30#include "modules/control/controllers/slope_anti_slip_control_task/proto/antislip_control_task_conf.pb.h"
31
38
40#include "modules/control/control_task_base_extend/proto/params_pipeline.pb.h"
45namespace apollo {
46namespace control {
47
54public:
59
63 virtual ~AntiSlipControlTask() = default;
64
69 common::Status Init(std::shared_ptr<DependencyInjector> injector) override;
70
81 const localization::LocalizationEstimate *localization,
82 const canbus::Chassis *chassis,
83 const planning::ADCTrajectory *trajectory,
84 control::ControlCommand *cmd) override;
85
89 void Stop() override;
90
95 common::Status Reset() override;
96
101 std::string Name() const override;
102
103protected:
104 std::shared_ptr<DependencyInjector> injector_;
105 bool LoadParams(ParamsPipeline *params_pipeline);
106
107private:
108 void SetDigitalFilterPitchAngle();
109 void SetDigitalFilter(double ts, double cutoff_freq, common::DigitalFilter *digital_filter);
110 void InitControlCalibrationTable();
111 bool CheckSlope(double vehicle_pitch);
112 void UseVehicleEpb(const canbus::Chassis *chassis, ControlCommand *control_command);
113 AntiSlipControlTaskConf::VehicleMoveState CheckAccGainPoint(
114 double path_remain_threshold,
115 SimpleLongitudinalDebug *lon_debug,
116 const SimpleLongitudinalDebug *lon_debug_previous);
117 bool DetectHillStartCondition(
118 ControlCommand *control_command,
119 const planning::ADCTrajectory *planning_published_trajectory,
120 const double &current_speed);
121 void CalculateHillStartACCAndBrakeRate(
122 ControlCommand *control_command,
123 const planning::ADCTrajectory *trajectory_message);
124 void CalculateNormalStartACC(ControlCommand *control_command);
125 bool DetectQuitHillStart(ControlCommand *cmd, const double &current_speed);
126 void FindMaxSpeedInPreviewWindow(const planning::ADCTrajectory *planning_published_trajectory);
127 void FindMinSpeedInPreviewWindow(const planning::ADCTrajectory *planning_published_trajectory);
128 void ResetHillStart();
129 void ResetHillUpStop();
130 void DetectObstacle(ControlCommand *cmd, const canbus::Chassis *chassis, const double &current_speed);
131 void ResetDetectObstacleFlags();
132
133private:
134 bool SetCurrentParam(const std::string param_config_name, AntiSlipControlTaskConf &antislip_control_task_conf_);
135 bool ChooseCurrentParam(
136 const planning::ADCTrajectory *trajectory_msg,
137 AntiSlipControlTaskConf &antislip_control_task_conf_);
138 std::string name_;
139 std::string current_param_config_name_ = "";
140 // vehicle parameter
141 common::VehicleParam vehicle_param_;
142 calibration_table calibration_table_;
143 common::DigitalFilter digital_filter_pitch_angle_;
144
145 ParamsPipeline params_pipeline_;
146 std::vector<std::pair<std::string, AntiSlipControlTaskConf>> params_list_;
147
148 const planning::ADCTrajectory *trajectory_message_ = nullptr;
149
150 AntiSlipControlTaskConf antislip_control_task_conf_;
151 std::unique_ptr<Interpolation2D> control_interpolation_;
152 std::unique_ptr<Interpolation1D> slope_pitch_acc_interpolation_;
153
154 double max_path_remain_when_stopped_ = 0.0;
155 bool vehicle_start_up_ = false;
156 double start_path_remian_ = 0.0;
157 bool previous_park_brake_ = false;
158 bool is_brake_hold_ = false;
159 bool enable_acc_gain_ = false;
160
161 bool in_hill_start_condition_ = false;
162 bool in_normal_start_condition_ = false;
163 double quit_hill_start_speed_ = 0.0;
164 int preview_length_ = 0;
165
166 int min_speed_preview_length_ = 0;
167 double min_speed_preview_ = 0.0;
168
169 double hill_start_acc_gain_rate_ = 0.0;
170 double hill_start_brake_dec_rate_ = 0.0;
171
172 int hill_start_window_ = 0;
173 int hill_start_acc_count_ = 0;
174 int hill_start_brake_count_ = 0;
175
176 double previous_hill_start_acc_ = 0.0;
177 double previous_hill_start_brake_ = 0.0;
178 double hill_start_first_acc_ = 0.0;
179
180 double normal_start_tartget_acc_ = 0.0;
181 int normal_start_gain_count_ = 0;
182 int normal_start_maintain_count_ = 0;
183 double normal_start_acc_gain_rate_ = 0.0;
184
185 bool previous_is_auto_ = false;
186 bool from_else_to_auto_ = false;
187
188 bool previous_is_full_stop_ = false;
189 bool form_go_to_full_stop_ = false;
190 bool begin_end_brake_ = false;
191
192 double fullstop_in_brake_ = 0.0;
193 int fullstop_window_count_ = 0;
194 double hillup_fullstop_brake_rate_ = 0.0;
195
196 int unusual_stop_count_ = 0;
197 bool on_obstacle_ = false;
198 int quit_obstacle_count_ = 0;
199 double in_obstacle_throttle_ = 0.0;
200 double previous_obs_throttle_ = 0.0;
201 int min_throttle_count_ = 0;
202 int speed_stable_count_ = 0;
203
204 double previous_downhill_go_brk_ = 0.0;
205
206 bool uphill_too_fast_ = false;
207 bool only_use_brk_downhill_ = false;
208 bool erase_brk_in_go_ = false;
209 bool erase_brk_in_end_ = false;
210 int gear_drive_count_ = 0;
211
212 double pre_cali_down_hill_ = 0.0;
213
214 double slope_start_acc_ = 0.0;
215 std::string anti_stage_ = "none";
216};
217
219
220} // namespace control
221} // 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
Anti-slip in slope condition, to compute brake / throttle values.
common::Status Reset() override
reset demo control task
common::Status Init(std::shared_ptr< DependencyInjector > injector) override
initialize AntiSlipControlTask
std::shared_ptr< DependencyInjector > injector_
void Stop() override
stop AntislipControlTask
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
virtual ~AntiSlipControlTask()=default
destructor
std::string Name() const override
AntiSlipControlTask name
bool LoadParams(ParamsPipeline *params_pipeline)
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.