Apollo 11.0
自动驾驶开放平台
apollo::control::AntiSlipControlTask类 参考

Anti-slip in slope condition, to compute brake / throttle values. 更多...

#include <anti_slip_control_task.h>

类 apollo::control::AntiSlipControlTask 继承关系图:
apollo::control::AntiSlipControlTask 的协作图:

Public 成员函数

 AntiSlipControlTask ()
 constructor
 
virtual ~AntiSlipControlTask ()=default
 destructor
 
common::Status Init (std::shared_ptr< DependencyInjector > injector) override
 initialize 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
 
void Stop () override
 stop AntislipControlTask
 
common::Status Reset () override
 reset demo control task
 
std::string Name () const override
 AntiSlipControlTask name
 
- Public 成员函数 继承自 apollo::control::ControlTaskExtend
 ControlTaskExtend ()
 constructor
 
virtual ~ControlTaskExtend ()
 destructor
 
std::string Name () const
 reset ControlTaskAgent
 
- Public 成员函数 继承自 apollo::control::ControlTask
 ControlTask ()=default
 constructor
 
virtual ~ControlTask ()=default
 destructor
 

Protected 成员函数

bool LoadParams (ParamsPipeline *params_pipeline)
 
- Protected 成员函数 继承自 apollo::control::ControlTaskExtend
template<typename T >
bool LoadParamsPipelineConfig (T *pipeline_config)
 
bool LoadCalibrationTable (const std::string &calibration_table_path, calibration_table *calibration_table_conf)
 
bool VehicleStatusIdentificationUpdate (const localization::LocalizationEstimate *localization, const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory)
 
bool IsForwardModel ()
 
bool IsEdgeFollow ()
 
bool CheckInPit (double pit_replan_check_time, double pit_replan_check_count, double vehicle_speed, bool replan)
 
bool IsLargeCurvature (const double ref_curvature, const double min_large_ref_curvature, bool *is_in_large_curvature)
 
bool IsLeftCurvature (const double ref_curvature)
 
double GetVehicleSpeed (std::shared_ptr< DependencyInjector > injector, const bool &use_filter, const double &filter_coeff)
 
double ThrottleCmdFilter (const bool &use_filter, const double &filter_coeff, const double &throttle)
 
- Protected 成员函数 继承自 apollo::control::ControlTask
template<typename T >
bool LoadConfig (T *config)
 
bool LoadCalibrationTable (calibration_table *calibration_table_conf)
 

Protected 属性

std::shared_ptr< DependencyInjector > injector_
 

详细描述

Anti-slip in slope condition, to compute brake / throttle values.

在文件 anti_slip_control_task.h 第 53 行定义.

构造及析构函数说明

◆ AntiSlipControlTask()

apollo::control::AntiSlipControlTask::AntiSlipControlTask ( )

constructor

在文件 anti_slip_control_task.cc 第 35 行定义.

35 : name_("Slope Anti-Slip Control Task") {
36 AINFO << "Using " << name_;
37}
#define AINFO
Definition log.h:42

◆ ~AntiSlipControlTask()

virtual apollo::control::AntiSlipControlTask::~AntiSlipControlTask ( )
virtualdefault

destructor

成员函数说明

◆ ComputeControlCommand()

Status apollo::control::AntiSlipControlTask::ComputeControlCommand ( const localization::LocalizationEstimate *  localization,
const canbus::Chassis *  chassis,
const planning::ADCTrajectory *  trajectory,
control::ControlCommand *  cmd 
)
overridevirtual

compute brake / throttle values based on current vehicle status and target trajectory

参数
localizationvehicle location
chassisvehicle status e.g., speed, acceleration
trajectorytrajectory generated by planning
cmdcontrol command
返回
Status computation status

实现了 apollo::control::ControlTask.

在文件 anti_slip_control_task.cc 第 127 行定义.

131 {
132 trajectory_message_ = planning_published_trajectory;
133 if (planning_published_trajectory->trajectory_type() == ADCTrajectory::OPEN_SPACE) {
134 // if reverse,dont use this task
135 return Status::OK();
136 }
137
138 if (!ChooseCurrentParam(trajectory_message_, antislip_control_task_conf_)) {
139 AERROR << "Fail to load current anti control param!";
140 return Status(ErrorCode::CONTROL_COMPUTE_ERROR, "Fail to load current anti control param!");
141 }
142
143 uphill_too_fast_ = false;
144 only_use_brk_downhill_ = false;
145 erase_brk_in_go_ = false;
146 erase_brk_in_end_ = false;
147
148 // speed filter
149 double current_speed = GetVehicleSpeed(injector_, FLAGS_use_speed_filter, FLAGS_speed_smoothing_factor);
150
151 auto anti_slip_debug_info = injector_->mutable_control_debug_info()->mutable_simple_anti_slope_debug();
152 anti_slip_debug_info->Clear();
153 if (!previous_is_auto_ && chassis->driving_mode() == apollo::canbus::Chassis::COMPLETE_AUTO_DRIVE) {
154 from_else_to_auto_ = true;
155 ADEBUG << "From else to auto!!!";
156 } else {
157 from_else_to_auto_ = false;
158 }
159 if (chassis->driving_mode() == apollo::canbus::Chassis::COMPLETE_AUTO_DRIVE
160 && gear_drive_count_ > antislip_control_task_conf_.gear_drive_count_num()) {
161 previous_is_auto_ = true;
162 } else {
163 previous_is_auto_ = false;
164 }
165
166 if (chassis->gear_location() != canbus::Chassis::GEAR_DRIVE) {
167 gear_drive_count_ = 0;
168 previous_is_auto_ = false;
169 } else {
170 gear_drive_count_++;
171 }
172
173 auto lon_debug = cmd->mutable_debug()->mutable_simple_lon_debug();
174 auto lon_debug_previous = injector_->Get_previous_lon_debug_info();
175 double throttle_cmd = cmd->throttle();
176 double throttle_lowerbound = vehicle_param_.throttle_deadzone();
177 double brake_cmd = cmd->brake();
178 double brake_lowerbound = vehicle_param_.brake_deadzone();
179 if (brake_lowerbound <= antislip_control_task_conf_.brake_minimum_action()) {
180 brake_lowerbound = antislip_control_task_conf_.brake_minimum_action();
181 }
182 double calibration_value = 0.0;
183
184 double max_path_remain_when_stopped
185 = FLAGS_max_path_remain_when_stopped + antislip_control_task_conf_.path_remain_threshold();
186
187 double vehicle_pitch_rad = injector_->vehicle_state()->pitch();
188 double vehicle_pitch = vehicle_pitch_rad * 180 / M_PI + FLAGS_pitch_offset_deg;
189 lon_debug->set_vehicle_pitch(vehicle_pitch);
190 FindMaxSpeedInPreviewWindow(planning_published_trajectory);
191 FindMinSpeedInPreviewWindow(planning_published_trajectory);
192 if (CheckSlope(vehicle_pitch)) {
193 int reverse_flag = 1;
194 if (chassis->gear_location() == canbus::Chassis::GEAR_REVERSE) {
195 reverse_flag = -1;
196 }
197 ADEBUG << "Into anti-slip stop process.";
198 if (((CheckAccGainPoint(max_path_remain_when_stopped, lon_debug, lon_debug_previous)
199 != AntiSlipControlTaskConf::MOVING_DEFAULT_DESTNATION)
200 && !lon_debug->is_full_stop() && !lon_debug->is_full_stop_soft())
201 || enable_acc_gain_) {
202 ADEBUG << "is_full_stop is " << lon_debug->is_full_stop();
203 ADEBUG << "Into acc gain process.";
204 // TODO(ALL): confirm the slope_offset_compensation whether is positive or
205 // not when vehicle move uphill Resume: uphill: + , downhill: -
206 double slope_offset_compensation = antislip_control_task_conf_.use_opposite_slope_compensation() * GRA_ACC
207 * std::sin(vehicle_pitch_rad + FLAGS_pitch_offset_deg * M_PI / 180);
208 if (reverse_flag == 1 && lon_debug->speed_error() < antislip_control_task_conf_.cut_hill_up_throttle_speed()
209 && vehicle_pitch > 0) {
210 slope_offset_compensation
211 = slope_offset_compensation * antislip_control_task_conf_.cut_hill_up_throttle_rate();
212 // uphill forward too fast
213 uphill_too_fast_ = true;
214 } else if (
215 reverse_flag == -1
216 && lon_debug->speed_error() > -1 * antislip_control_task_conf_.cut_hill_up_throttle_speed()
217 && vehicle_pitch < 0) {
218 slope_offset_compensation
219 = slope_offset_compensation * antislip_control_task_conf_.cut_hill_up_throttle_rate();
220 // uphill backward too fast
221 uphill_too_fast_ = true;
222 }
223 if (std::isnan(slope_offset_compensation)) {
224 slope_offset_compensation = 0;
225 }
226 lon_debug->set_slope_offset_compensation(slope_offset_compensation);
227 anti_slip_debug_info->set_slope_offset_compensation(slope_offset_compensation);
228 double acceleration_cmd = lon_debug->acceleration_cmd_closeloop()
229 + lon_debug->preview_acceleration_reference()
230 + antislip_control_task_conf_.enable_slope_offset() * slope_offset_compensation;
231 ADEBUG << "[acc gain process] acceleration_cmd gain to: " << acceleration_cmd;
232 ADEBUG << "[acc gain process] close loop: " << lon_debug->acceleration_cmd_closeloop();
233 ADEBUG << "[acc gain process] acceleration_preview_acceleration_reference "
234 "to: "
235 << lon_debug->preview_acceleration_reference();
236 ADEBUG << "[acc gain process] acceleration_compensation_ to: "
237 << antislip_control_task_conf_.enable_slope_offset() * slope_offset_compensation;
238 ADEBUG << "[acc gain process] compensation_ to: " << slope_offset_compensation;
239 ADEBUG << "[acc gain process] pitch = " << vehicle_pitch;
240
241 double acceleration_lookup = (chassis->gear_location() == canbus::Chassis::GEAR_REVERSE) ? -acceleration_cmd
242 : acceleration_cmd;
243 anti_slip_debug_info->set_anti_acc_lookup(acceleration_lookup);
244 // acceleration_lookup > 0: THROTTLE
245 // acceleration_lookup < 0: BRAKE
246 calibration_value
247 = control_interpolation_->Interpolate(std::make_pair(chassis->speed_mps(), acceleration_lookup));
248 anti_slip_debug_info->set_calibration_value_anti(calibration_value);
249 if (acceleration_lookup >= 0) {
250 if (calibration_value >= 0) {
251 throttle_cmd = std::max(calibration_value, throttle_lowerbound);
252 anti_stage_ = "acc lookup and cali > 0, stage1";
253 } else {
254 throttle_cmd = throttle_lowerbound;
255 anti_stage_ = "acc lookup > 0 ,cali < 0, stage2";
256 }
257 brake_cmd = 0.0;
258 previous_downhill_go_brk_ = 0.0;
259 pre_cali_down_hill_ = 0.0;
260 } else {
261 // the car is going downhill,acceleration_lookup < 0DetectObstacle
262 throttle_cmd = 0.0;
263 if (calibration_value >= 0) {
264 brake_cmd = brake_lowerbound;
265 throttle_cmd = 0.0;
266 previous_downhill_go_brk_ = 0.0;
267 pre_cali_down_hill_ = 0.0;
268 anti_stage_ = "acc lookup < 0 and cali > 0, stage3";
269 } else {
270 // use only brake to go downhill
271 only_use_brk_downhill_ = true;
272 if ((std::fabs(lon_debug->acceleration_cmd_closeloop()) < std::fabs(slope_offset_compensation))
273 && (vehicle_pitch * reverse_flag < 0)) {
274 brake_cmd = std::max(-calibration_value, brake_lowerbound);
275
276 if (reverse_flag == 1 && (vehicle_pitch < 0)) {
277 // TODO:
278 // it is a method to avoid the being too fast or too slow,but it can be cancled ,cause it
279 // may stop the car suddendly
280
281 // if (lon_debug->speed_error() > antislip_control_task_conf_.downhill_cut_brake_v_err()) {
282 // // should kill brake ,too slow
283 // previous_downhill_go_brk_ = previous_downhill_go_brk_
284 // - antislip_control_task_conf_.downhill_brake_change();
285 // }
286 // if (lon_debug->speed_error()
287 // < (-1) * antislip_control_task_conf_.downhill_cut_brake_v_err()) {
288 // // should add brake,car is too fast
289 // previous_downhill_go_brk_ = previous_downhill_go_brk_
290 // + antislip_control_task_conf_.downhill_brake_change();
291 // }
292 // if ((lon_debug->speed_error() <= antislip_control_task_conf_.downhill_cut_brake_v_err())
293 // && (lon_debug->speed_error()
294 // >= (-1) * antislip_control_task_conf_.downhill_cut_brake_v_err())) {
295 // previous_downhill_go_brk_ = previous_downhill_go_brk_;
296 // }
297
298 // else {
299 // brake_cmd = brake_cmd + previous_downhill_go_brk_;
300 // }
301 if (std::fabs(current_speed) < antislip_control_task_conf_.maintain_min_speed()) {
302 brake_cmd = 0.0;
303 anti_stage_ = "acc lookup < 0 and cali < 0, stage4";
304 }
305 if (lon_debug->speed_error()
306 < -1 * antislip_control_task_conf_.downhill_cut_brake_v_err()) {
307 if (brake_cmd - pre_cali_down_hill_
308 > antislip_control_task_conf_.downhill_brake_change_max()) {
309 brake_cmd = pre_cali_down_hill_
310 + 2 * antislip_control_task_conf_.downhill_brake_change_max();
311 }
312 } else {
313 if (brake_cmd - pre_cali_down_hill_
314 > antislip_control_task_conf_.downhill_brake_change_max()) {
315 brake_cmd = pre_cali_down_hill_
316 + antislip_control_task_conf_.downhill_brake_change_max();
317 }
318 }
319 if (brake_cmd == 0.0) {
320 pre_cali_down_hill_
321 = pre_cali_down_hill_ * antislip_control_task_conf_.downhill_brake_rate();
322 } else {
323 pre_cali_down_hill_ = brake_cmd;
324 }
325 }
326
327 // TODO: the method when car go reversely
328 // if (reverse_flag == -1 && (vehicle_pitch > 0)) {
329 // if (lon_debug->speed_error()
330 // < (-1) * antislip_control_task_conf_.downhill_cut_brake_v_err()) {
331 // brake_cmd = previous_downhill_go_brk_
332 // - antislip_control_task_conf_.downhill_brake_change();
333 // }
334 // if (lon_debug->speed_error() > antislip_control_task_conf_.downhill_cut_brake_v_err()) {
335 // brake_cmd = previous_downhill_go_brk_
336 // + antislip_control_task_conf_.downhill_brake_change();
337 // }
338 // if ((lon_debug->speed_error() <= antislip_control_task_conf_.downhill_cut_brake_v_err())
339 // && (lon_debug->speed_error()
340 // >= (-1) * antislip_control_task_conf_.downhill_cut_brake_v_err())) {
341 // brake_cmd = previous_downhill_go_brk_;
342 // }
343 // }
344 }
345
346 if (brake_cmd <= 0) {
347 anti_stage_ = "brk < 0, set brk 0 stage5";
348 brake_cmd = 0.0;
349 }
350 ADEBUG << "usr brk to go,cmd = " << brake_cmd << "calibration_value = " << calibration_value;
351 ADEBUG << "acceleration_lookup = " << acceleration_lookup;
352 // previous_downhill_go_brk_ = brake_cmd;
353 }
354 }
355
356 if ((std::fabs(current_speed) < antislip_control_task_conf_.maintain_min_speed())
357 && (lon_debug->speed_error() > antislip_control_task_conf_.cut_unusual_brk_speed_error())) {
358 if ((!in_hill_start_condition_) && (!in_normal_start_condition_) && (!on_obstacle_)
359 && (planning_published_trajectory->trajectory_type() != ADCTrajectory::OPEN_SPACE)) {
360 brake_cmd = 0.0;
361 erase_brk_in_go_ = true;
362 }
363 }
364
365 if ((vehicle_pitch <= antislip_control_task_conf_.uphill_start_pitch())
366 && (vehicle_pitch >= antislip_control_task_conf_.normal_start_pitch())
367 && (planning_published_trajectory->trajectory_type() != ADCTrajectory::OPEN_SPACE)) {
368 if (lon_debug->path_remain() > antislip_control_task_conf_.cncl_brake_min_path()
369 && lon_debug->path_remain() <= antislip_control_task_conf_.cncl_brake_max_path()) {
370 if ((!in_hill_start_condition_) && (!in_normal_start_condition_) && (!on_obstacle_)
371 && (min_speed_preview_ < antislip_control_task_conf_.preview_min_speed_threshold())
372 && (lon_debug->preview_acceleration_reference()
373 > antislip_control_task_conf_.emergency_acc())) {
374 if (lon_debug->speed_error() < antislip_control_task_conf_.cut_hill_up_throttle_speed()) {
375 if (cmd->brake() > antislip_control_task_conf_.cncl_max_brake()) {
376 brake_cmd = antislip_control_task_conf_.cncl_max_brake();
377 }
378 } else {
379 brake_cmd = 0.0;
380 erase_brk_in_end_ = true;
381 }
382 }
383 }
384 }
385
386 if ((!in_hill_start_condition_) && (!in_normal_start_condition_)
387 && DetectHillStartCondition(cmd, planning_published_trajectory, current_speed)) {
388 ADEBUG << "in hill start condition,pitch = " << vehicle_pitch;
389 if (vehicle_pitch >= antislip_control_task_conf_.uphill_start_pitch()
390 && antislip_control_task_conf_.enable_hill_start()) {
391 ADEBUG << "uphill!!!!!! start condition";
392 in_hill_start_condition_ = true;
393 CalculateHillStartACCAndBrakeRate(cmd, planning_published_trajectory);
394 previous_hill_start_acc_ = hill_start_first_acc_;
395 previous_hill_start_brake_ = antislip_control_task_conf_.epb_brake_cmd();
396 }
397 if ((vehicle_pitch >= antislip_control_task_conf_.normal_start_pitch())
398 && (vehicle_pitch < antislip_control_task_conf_.uphill_start_pitch())
399 && antislip_control_task_conf_.enable_normal_start()) {
400 in_normal_start_condition_ = true;
401 previous_hill_start_acc_ = hill_start_first_acc_;
402 ADEBUG << "in normal start condition,normal start !!!!!!!!";
403 CalculateNormalStartACC(cmd);
404 }
405 } else {
406 if (FLAGS_use_vehicle_epb) {
407 UseVehicleEpb(chassis, cmd);
408 ADEBUG << "[anti-slip stop in condition]: Into vehicle epb, parking "
409 "brake true.";
410 } else if (lon_debug->is_full_stop_soft() || lon_debug->is_full_stop()) {
411 brake_cmd = std::max(brake_cmd, antislip_control_task_conf_.epb_brake_cmd());
412 ADEBUG << "[anti-slip stop in condition]: Into non vehicle epb, "
413 "throttle cmd is 0, brake cmd is "
414 << brake_cmd;
415 lon_debug->set_is_epb_brake(true);
416 ADEBUG << "anti slip brake triggered in slope: " << lon_debug->is_epb_brake();
417 } else {
418 lon_debug->set_is_epb_brake(false);
419 ADEBUG << "[anti-slip stop out condition]: anti slip brake is not "
420 "triggered in slope.";
421 }
422 }
423
424 if (in_hill_start_condition_) {
425 if (chassis->gear_location() == canbus::Chassis::GEAR_DRIVE && !chassis->parking_brake()) {
426 // hill start control begin:
427 if (hill_start_acc_count_ > antislip_control_task_conf_.hill_start_acc_window()) {
428 hill_start_acc_gain_rate_ = 0;
429 ADEBUG << "flag over set acc gain to 0";
430 }
431 slope_start_acc_ = hill_start_acc_gain_rate_ + previous_hill_start_acc_;
432 previous_hill_start_acc_ = slope_start_acc_;
433 double hill_start_throttle = control_interpolation_->Interpolate(
434 std::make_pair(chassis->speed_mps(), slope_start_acc_));
435 throttle_cmd = std::max(hill_start_throttle, throttle_lowerbound);
436
437 if (hill_start_brake_count_ >= antislip_control_task_conf_.hill_start_brake_window()) {
438 brake_cmd = 0.0;
439 } else if (
440 hill_start_brake_count_ >= antislip_control_task_conf_.hill_start_brake_standby_window()) {
441 brake_cmd = previous_hill_start_brake_ - hill_start_brake_dec_rate_;
442 previous_hill_start_brake_ = brake_cmd;
443 } else {
444 brake_cmd = antislip_control_task_conf_.epb_brake_cmd();
445 }
446 hill_start_acc_count_++;
447 hill_start_brake_count_++;
448 }
449 if (chassis->gear_location() == canbus::Chassis::GEAR_NEUTRAL || chassis->parking_brake()) {
450 brake_cmd = antislip_control_task_conf_.epb_brake_cmd();
451 }
452 }
453
454 if (in_normal_start_condition_) {
455 if (chassis->gear_location() == canbus::Chassis::GEAR_DRIVE && !chassis->parking_brake()) {
456 brake_cmd = 0.0;
457 if (normal_start_gain_count_ >= antislip_control_task_conf_.normal_start_gain_window()) {
458 normal_start_acc_gain_rate_ = 0.0;
459 }
460 slope_start_acc_ = normal_start_acc_gain_rate_ + previous_hill_start_acc_;
461 if (slope_start_acc_ < 0) {
462 slope_start_acc_ = 0.0;
463 }
464 if (slope_start_acc_ >= normal_start_tartget_acc_) {
465 slope_start_acc_ = normal_start_tartget_acc_;
466 }
467 previous_hill_start_acc_ = slope_start_acc_;
468 double hill_start_throttle = control_interpolation_->Interpolate(
469 std::make_pair(chassis->speed_mps(), slope_start_acc_));
470 throttle_cmd = std::max(hill_start_throttle, throttle_lowerbound)
471 * antislip_control_task_conf_.normal_acc_rate();
472 ADEBUG << "set normal throttle_cmd" << throttle_cmd;
473 ADEBUG << "now acc = " << slope_start_acc_;
474 normal_start_gain_count_++;
475 normal_start_maintain_count_++;
476 }
477 }
478
479 if (DetectQuitHillStart(cmd, current_speed)) {
480 ADEBUG << "quit hill start,clear flags";
481 in_hill_start_condition_ = false;
482 in_normal_start_condition_ = false;
483 hill_start_acc_count_ = 0;
484 hill_start_brake_count_ = 0;
485 previous_hill_start_acc_ = 0.0;
486 previous_hill_start_brake_ = 0.0;
487 hill_start_acc_gain_rate_ = 0.0;
488 hill_start_brake_dec_rate_ = 0.0;
489 quit_hill_start_speed_ = 0.0;
490 hill_start_first_acc_ = 0.0;
491 normal_start_tartget_acc_ = 0.0;
492 normal_start_gain_count_ = 0;
493 normal_start_maintain_count_ = 0;
494 normal_start_acc_gain_rate_ = 0.0;
495 preview_length_ = 0;
496 slope_start_acc_ = 0.0;
497 }
498
499 ADEBUG << "out put acc = " << acceleration_cmd;
500 lon_debug->set_acceleration_cmd(acceleration_cmd);
501 lon_debug->set_acceleration_lookup(acceleration_lookup);
502 if (!lon_debug->is_full_stop() && !lon_debug->is_full_stop_soft()) {
503 throttle_cmd
504 = ThrottleCmdFilter(FLAGS_use_throttle_filter, FLAGS_throttle_smoothing_factor, throttle_cmd);
505 cmd->set_throttle(throttle_cmd);
506 cmd->set_brake(brake_cmd);
507 } else {
508 previous_is_auto_ = false;
509 }
510 }
511 } else {
512 ResetHillStart();
513 ADEBUG << "Not into anti-slip stop process because out of enable threshold: "
514 << antislip_control_task_conf_.slope_offset_threhold();
515 }
516 DetectObstacle(cmd, chassis, current_speed);
517 if (on_obstacle_) {
518 quit_obstacle_count_++;
519 ADEBUG << "[obstacle] overcome obstacle,throttle = " << previous_obs_throttle_;
520 previous_obs_throttle_ = previous_obs_throttle_ + antislip_control_task_conf_.obs_throttle_add_rate();
521 if (!lon_debug->is_full_stop() && !lon_debug->is_full_stop_soft()) {
522 // previous_obs_throttle_ = ThrottleCmdFilter(FLAGS_use_throttle_filter, FLAGS_throttle_smoothing_factor,
523 // previous_obs_throttle_);
524 if (previous_obs_throttle_ > 99.0) {
525 previous_obs_throttle_ = 99.0;
526 }
527 cmd->set_throttle(previous_obs_throttle_);
528 }
529 }
530 previous_park_brake_ = cmd->parking_brake();
531
532 if (chassis->gear_location() == canbus::Chassis::GEAR_NEUTRAL
533 || (chassis->gear_location() != trajectory_message_->gear())) {
534 brake_cmd = antislip_control_task_conf_.epb_brake_cmd();
535 throttle_cmd = 0.0;
536 cmd->set_throttle(throttle_cmd);
537 cmd->set_brake(brake_cmd);
538 }
539
540 auto control_interactive_info = injector_->mutable_control_interactive_info();
541 if (antislip_control_task_conf_.judge_safety_check()) {
542 if (lon_debug->is_full_stop() || lon_debug->is_full_stop_soft()
543 || (lon_debug->acceleration_reference() > antislip_control_task_conf_.cancle_safety_check_acc()
544 && current_speed < antislip_control_task_conf_.cancle_safety_check_speed())
545 || (std::fabs(vehicle_pitch) > antislip_control_task_conf_.cancle_safety_check_pitch())) {
546 // situations dont use safety check
547 // 0 use cancle fullstop
548 // 1 fullstop(soft)
549 // 2 accpreviwe > thres && v < thres(car is starting)
550 // 3 vehicle pitch toobig toosmall
551 control_interactive_info->set_is_need_safety_check(false);
552 } else {
553 control_interactive_info->set_is_need_safety_check(true);
554 }
555 } else {
556 control_interactive_info->set_is_need_safety_check(true);
557 }
558
559 // set some debug info
560 anti_slip_debug_info->set_hill_start_window(hill_start_window_);
561 anti_slip_debug_info->set_preview_length(preview_length_);
562 anti_slip_debug_info->set_quit_hill_start_speed(quit_hill_start_speed_);
563 anti_slip_debug_info->set_normal_start_tartget_acc(normal_start_tartget_acc_);
564 anti_slip_debug_info->set_in_hill_start_condition(in_hill_start_condition_);
565 anti_slip_debug_info->set_in_normal_start_condition(in_normal_start_condition_);
566 anti_slip_debug_info->set_hill_start_acc_gain_rate(hill_start_acc_gain_rate_);
567 anti_slip_debug_info->set_normal_start_acc_gain_rate(normal_start_acc_gain_rate_);
568 anti_slip_debug_info->set_on_obstacle(on_obstacle_);
569 anti_slip_debug_info->set_from_else_to_auto(from_else_to_auto_);
570 anti_slip_debug_info->set_previous_is_auto(previous_is_auto_);
571 anti_slip_debug_info->set_uphill_too_fast(uphill_too_fast_);
572 anti_slip_debug_info->set_only_use_brk_downhill(only_use_brk_downhill_);
573 anti_slip_debug_info->set_erase_brk_in_go(erase_brk_in_go_);
574 anti_slip_debug_info->set_erase_brk_in_end(erase_brk_in_end_);
575 anti_slip_debug_info->set_anti_cmd_brake(brake_cmd);
576 anti_slip_debug_info->set_anti_cmd_throttle(throttle_cmd);
577 anti_slip_debug_info->set_hill_start_first_acc(hill_start_first_acc_);
578 anti_slip_debug_info->set_slope_start_acc(slope_start_acc_);
579 anti_slip_debug_info->set_anti_stage(anti_stage_);
580
581 return Status::OK();
582}
static Status OK()
generate a success status.
Definition status.h:60
std::shared_ptr< DependencyInjector > injector_
double ThrottleCmdFilter(const bool &use_filter, const double &filter_coeff, const double &throttle)
double GetVehicleSpeed(std::shared_ptr< DependencyInjector > injector, const bool &use_filter, const double &filter_coeff)
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
constexpr double GRA_ACC
optional apollo::canbus::Chassis::GearPosition gear

◆ Init()

Status apollo::control::AntiSlipControlTask::Init ( std::shared_ptr< DependencyInjector >  injector)
overridevirtual

initialize AntiSlipControlTask

返回
Status initialization status

实现了 apollo::control::ControlTask.

在文件 anti_slip_control_task.cc 第 39 行定义.

39 {
40 // hook: Apollo License Verification: v_apollo_park
41 if (!ControlTask::LoadConfig<AntiSlipControlTaskConf>(&antislip_control_task_conf_)) {
42 AERROR << "Failed to load control task conf";
43 return Status(ErrorCode::CONTROL_INIT_ERROR, "Failed to load slop anti-slip control task conf");
44 }
45 if (!ControlTaskExtend::LoadParamsPipelineConfig<ParamsPipeline>(&params_pipeline_)) {
46 AERROR << "failed to load anti params pipeline config";
47 return Status(ErrorCode::CONTROL_INIT_ERROR, "failed to load anti params pipeline config");
48 }
49 if (!LoadParams(&params_pipeline_)) {
50 AERROR << "failed to load anti controller params.";
51 return Status(ErrorCode::CONTROL_INIT_ERROR, "failed to load anti anti controller params.");
52 }
53 if (!ControlTask::LoadCalibrationTable(&calibration_table_)) {
54 AERROR << "failed to load calibration table";
55 return Status(ErrorCode::CONTROL_INIT_ERROR, "lon failed to load calibration table");
56 }
57 injector_ = injector;
58 SetDigitalFilterPitchAngle();
59 InitControlCalibrationTable();
60 enable_acc_gain_ = antislip_control_task_conf_.enable_slope_offset();
61 vehicle_param_.CopyFrom(common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param());
62 hill_start_window_ = antislip_control_task_conf_.hill_start_preview_window();
63 return Status::OK();
64}
bool LoadParams(ParamsPipeline *params_pipeline)
bool LoadCalibrationTable(calibration_table *calibration_table_conf)

◆ LoadParams()

bool apollo::control::AntiSlipControlTask::LoadParams ( ParamsPipeline *  params_pipeline)
protected

在文件 anti_slip_control_task.cc 第 66 行定义.

66 {
67 for (int i = 0; i < params_pipeline->params_declare_size(); i++) {
68 AntiSlipControlTaskConf param_config;
69 auto param_config_path = params_pipeline->params_declare(i).config_path();
70 std::string param_config_path_relative = absl::StrCat("conf", "/", param_config_path);
71 AINFO << "Param config_path_relative is " << param_config_path_relative;
72 std::string param_config_path_absolute
74 "apollo::control::AntiSlipControlTask", param_config_path_relative);
75 AINFO << "Param config_path_absolute is " << param_config_path_absolute;
76 if (!apollo::cyber::common::GetProtoFromFile(param_config_path_absolute, &param_config)) {
77 AERROR << "Load config: " << params_pipeline->params_declare(i).config_name() << " param failed!";
78 return false;
79 }
80 AINFO << "Load the config file successfully, param file name: " << param_config_path;
81 params_list_.push_back(std::make_pair(params_pipeline->params_declare(i).config_name(), param_config));
82 }
83 return true;
84}
ControlTask()=default
constructor
std::string GetPluginConfPath(const std::string &class_name, const std::string &conf_name)
get plugin configuration file location
static PluginManager * Instance()
get singleton instance of PluginManager
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132

◆ Name()

std::string apollo::control::AntiSlipControlTask::Name ( ) const
overridevirtual

AntiSlipControlTask name

返回
string controller name in string

实现了 apollo::control::ControlTask.

在文件 anti_slip_control_task.cc 第 894 行定义.

894 {
895 return name_;
896}

◆ Reset()

Status apollo::control::AntiSlipControlTask::Reset ( )
overridevirtual

reset demo control task

返回
Status reset status

实现了 apollo::control::ControlTask.

在文件 anti_slip_control_task.cc 第 873 行定义.

873 {
874 previous_is_auto_ = false;
875 in_hill_start_condition_ = false;
876 in_normal_start_condition_ = false;
877 hill_start_acc_count_ = 0;
878 hill_start_brake_count_ = 0;
879 previous_hill_start_acc_ = 0.0;
880 previous_hill_start_brake_ = 0.0;
881 hill_start_acc_gain_rate_ = 0.0;
882 hill_start_brake_dec_rate_ = 0.0;
883 quit_hill_start_speed_ = 0.0;
884 hill_start_first_acc_ = 0.0;
885 normal_start_tartget_acc_ = 0.0;
886 normal_start_gain_count_ = 0;
887 normal_start_maintain_count_ = 0;
888 normal_start_acc_gain_rate_ = 0.0;
889 preview_length_ = 0;
890 slope_start_acc_ = 0.0;
891 return Status::OK();
892}

◆ Stop()

void apollo::control::AntiSlipControlTask::Stop ( )
overridevirtual

stop AntislipControlTask

实现了 apollo::control::ControlTask.

在文件 anti_slip_control_task.cc 第 871 行定义.

871{}

类成员变量说明

◆ injector_

std::shared_ptr<DependencyInjector> apollo::control::AntiSlipControlTask::injector_
protected

在文件 anti_slip_control_task.h 第 104 行定义.


该类的文档由以下文件生成: