compute brake / throttle values based on current vehicle status and target trajectory
309 {
310 localization_ = localization;
311 chassis_ = chassis;
312 trajectory_message_ = planning_published_trajectory;
313
314 auto debug = cmd->mutable_debug()->mutable_simple_lon_debug();
315 debug->Clear();
316 auto lon_debug_info =
injector_->mutable_control_debug_info()->mutable_simple_lon_debug();
317 lon_debug_info->Clear();
318
319
320 double vehicle_speed_ori =
injector_->vehicle_state()->linear_velocity();
321 lon_debug_info->set_vehicle_speed(vehicle_speed_ori);
322
324 lon_debug_info->set_vehicle_speed_filter(current_speed);
325
327 AERROR <<
"Fail to update the vehicle status identification!";
328 return Status(ErrorCode::CONTROL_COMPUTE_ERROR,
"Fail to update the vehicle status identification!");
329 }
330
331 if (trajectory_analyzer_ == nullptr
333 trajectory_analyzer_.reset(new TrajectoryAnalyzer(trajectory_message_));
334 }
335
336 if (!ChooseCurrentParam(trajectory_message_, current_speed, current_lon_based_pidcontroller_conf_)) {
337 AERROR <<
"Fail to load current lon control param!";
338 return Status(ErrorCode::CONTROL_COMPUTE_ERROR,
"Fail to load current lon control param!");
339 }
340
341 if (!ChooseCurrentCalibrationTable(calibration_table_)) {
342 AERROR <<
"Fail to load the current lon control calibration table!";
343 return Status(ErrorCode::CONTROL_COMPUTE_ERROR,
"Fail to load the current lon control calibration table!!");
344 }
345
346 if (calibration_table_.calibration_size() != previous_calibration_table_size_) {
347 AINFO <<
"Update the calibration table, init the new calibration table.";
348 InitControlCalibrationTable(calibration_table_);
349 previous_calibration_table_size_ = calibration_table_.calibration_size();
350 }
351
352 if (!control_interpolation_) {
353 AERROR <<
"Fail to initialize calibration table.";
354 return Status(ErrorCode::CONTROL_COMPUTE_ERROR,
"Fail to initialize calibration table.");
355 }
356
357 double brake_cmd = 0.0;
358 double throttle_cmd = 0.0;
359 double ts = current_lon_based_pidcontroller_conf_.ts();
360 double preview_time = current_lon_based_pidcontroller_conf_.preview_window() * ts;
361 bool enable_leadlag = current_lon_based_pidcontroller_conf_.enable_reverse_leadlag_compensation();
362
363 standstill_narmal_acceleration_
364 = -std::fabs(current_lon_based_pidcontroller_conf_.standstill_narmal_acceleration());
365 stop_gain_acceleration_ = -std::fabs(current_lon_based_pidcontroller_conf_.stop_gain_acceleration());
366
367 if (preview_time < 0.0) {
368 const auto error_msg = absl::StrCat("Preview time set as: ", preview_time, " less than 0");
370 return Status(ErrorCode::CONTROL_COMPUTE_ERROR, error_msg);
371 }
372
373 station_leadlag_controller_.
SetLeadlagConf(current_lon_based_pidcontroller_conf_.speed_leadlag_conf());
374 speed_leadlag_controller_.
SetLeadlagConf(current_lon_based_pidcontroller_conf_.speed_leadlag_conf());
375
376 CheckFinishToElse(planning_published_trajectory);
378
379 double station_error_limit = current_lon_based_pidcontroller_conf_.station_error_limit();
380 double station_error_limited = 0.0;
381 if (current_lon_based_pidcontroller_conf_.enable_speed_station_preview()) {
382 station_error_limited
383 =
common::math::Clamp(debug->preview_station_error(), -station_error_limit, station_error_limit);
384 } else {
385 station_error_limited =
common::math::Clamp(debug->station_error(), -station_error_limit, station_error_limit);
386 }
387
388 auto station_pid_conf = current_lon_based_pidcontroller_conf_.station_pid_conf();
389 CalcultePidParams(std::fabs(current_speed), station_pid_conf);
390 station_pid_controller_.
SetPID(station_pid_conf);
391 auto speed_pid_conf = current_lon_based_pidcontroller_conf_.speed_pid_conf();
392 CalcultePidParams(std::fabs(current_speed), speed_pid_conf);
393 speed_pid_controller_.
SetPID(speed_pid_conf);
394
395 current_trajectory_timestamp_ = planning_published_trajectory->header().timestamp_sec();
396 if ((current_trajectory_timestamp_ - pre_trajectory_timestamp_ > 1e-4)
397 && planning_published_trajectory->is_replan()) {
400 ADEBUG <<
"Reset the pid controller integral because of re-planning.";
401 }
402 pre_trajectory_timestamp_ = current_trajectory_timestamp_;
403
404 double speed_offset = station_pid_controller_.
Control(station_error_limited, ts);
405 if (enable_leadlag) {
406 speed_offset = station_leadlag_controller_.
Control(speed_offset, ts);
407 }
408
409 double speed_controller_input = 0.0;
410 double speed_controller_input_limit = current_lon_based_pidcontroller_conf_.speed_controller_input_limit();
411 double speed_controller_input_limited = 0.0;
412 if (current_lon_based_pidcontroller_conf_.enable_speed_station_preview()) {
413 speed_controller_input = speed_offset + debug->preview_speed_error();
414 } else {
415 speed_controller_input = speed_offset + debug->speed_error();
416 }
417 speed_controller_input_limited
418 =
common::math::Clamp(speed_controller_input, -speed_controller_input_limit, speed_controller_input_limit);
419
420 double acceleration_cmd_closeloop = 0.0;
421
422 acceleration_cmd_closeloop = speed_pid_controller_.
Control(speed_controller_input_limited, ts);
424 if (enable_leadlag) {
425 acceleration_cmd_closeloop = speed_leadlag_controller_.
Control(acceleration_cmd_closeloop, ts);
427 }
428
432 }
433
434 double vehicle_pitch_rad =
injector_->vehicle_state()->pitch();
435 double vehicle_pitch = vehicle_pitch_rad * 180 / M_PI + FLAGS_pitch_offset_deg;
436 ADEBUG <<
"[LON]vehicle_pitch is " << vehicle_pitch;
437 debug->set_vehicle_pitch(vehicle_pitch);
438
439
440
441 double slope_offset_compensation = current_lon_based_pidcontroller_conf_.use_opposite_slope_compensation() *
GRA_ACC
442 * std::sin(vehicle_pitch_rad + FLAGS_pitch_offset_deg * M_PI / 180);
443
444 if (std::isnan(slope_offset_compensation)) {
445 slope_offset_compensation = 0;
446 }
447
448 debug->set_slope_offset_compensation(slope_offset_compensation);
449 double acceleration_cmd = acceleration_cmd_closeloop + debug->preview_acceleration_reference();
450
451
452
453
454 double current_steer_interval = cmd->steering_target() - chassis->steering_percentage();
455 if (current_lon_based_pidcontroller_conf_.use_steering_check()
457 && std::abs(current_steer_interval) > current_lon_based_pidcontroller_conf_.steer_cmd_interval()) {
458 ADEBUG <<
"steering_target is " << cmd->steering_target() <<
" steering_percentage is "
459 << chassis->steering_percentage();
460 ADEBUG <<
"Steer cmd interval is larger than " << current_lon_based_pidcontroller_conf_.steer_cmd_interval();
461
464 acceleration_cmd = 0;
465 debug->set_is_wait_steer(true);
466 } else {
467 debug->set_is_wait_steer(false);
468 }
469 debug->set_current_steer_interval(current_steer_interval);
470
471
472
473 debug->set_is_full_stop(false);
474 debug->set_is_full_stop_soft(false);
475
476 auto previous_full_stop =
injector_->Get_previous_lon_debug_info()->is_full_stop()
477 ||
injector_->Get_previous_lon_debug_info()->is_full_stop_soft();
479 IsStopByDestination(debug);
480 IsPedestrianStopLongTerm(debug);
481 if (current_lon_based_pidcontroller_conf_.use_preview_reference_check()
482 && (std::fabs(debug->preview_acceleration_reference()) <= FLAGS_max_acceleration_when_stopped)
485 if (debug->is_stop_reason_by_destination() || debug->is_stop_reason_by_prdestrian()) {
486 debug->set_is_full_stop(true);
487 ADEBUG <<
"Into full stop within preview acc and reference speed, " <<
"is_full_stop is "
488 << debug->is_full_stop();
489 } else {
490 debug->set_is_full_stop_soft(true);
491 ADEBUG <<
"Into full stop soft within preview acc and reference speed, " <<
"is_full_stop_soft is "
492 << debug->is_full_stop_soft();
493 }
494 }
495
496 double path_remain_add = 0.0;
497 if (vehicle_pitch < current_lon_based_pidcontroller_conf_.pitch_path_remain_param_min()
498 && fabs(current_speed) > current_lon_based_pidcontroller_conf_.downhill_full_stop_min_speed()
500 path_remain_add = fabs(
501 sin(vehicle_pitch * M_PI / 180) * current_lon_based_pidcontroller_conf_.pitch_path_remain_param());
502 }
503
504 if (!previous_full_stop) {
505 max_path_remain_when_stopped_ = current_lon_based_pidcontroller_conf_.path_remain() + path_remain_add;
506 } else {
507 max_path_remain_when_stopped_ = current_lon_based_pidcontroller_conf_.path_remain()
508 + current_lon_based_pidcontroller_conf_.full_stop_path_remain_gain() + path_remain_add;
509 }
510 ADEBUG <<
"current max_path_remain_when_stopped_ is " << max_path_remain_when_stopped_;
511
512 if (((
IsForwardModel() && debug->path_remain() < max_path_remain_when_stopped_)
513 || (!
IsForwardModel() && debug->path_remain() > -max_path_remain_when_stopped_))) {
514 ADEBUG <<
"Into full stop decision by path remain.";
515 if (debug->is_stop_reason_by_destination() || debug->is_stop_reason_by_prdestrian()) {
516 debug->set_is_full_stop(true);
517 ADEBUG <<
"Current path remain distance: " << debug->path_remain()
518 << " is within max_path_remain threshold: " << max_path_remain_when_stopped_
519 << ", into full stop because vehicle is in destination: " << debug->is_stop_reason_by_destination()
520 << " or pedestrian is in long time stop: " << debug->is_stop_reason_by_prdestrian()
521 << "is_full_stop flag: " << debug->is_full_stop();
522 } else {
523 debug->set_is_full_stop_soft(true);
524 ADEBUG <<
"Current path remain distance: " << debug->path_remain()
525 << " is within max_path_remain threshold: " << max_path_remain_when_stopped_
526 << ", but not into full stop because stop not in destination: "
527 << debug->is_stop_reason_by_destination()
528 << " or pedestrian is not long time stop: " << debug->is_stop_reason_by_prdestrian()
529 << "is_full_stop_soft flag: " << debug->is_full_stop_soft();
530 }
532 && debug->is_stop_reason_by_prdestrian()) {
533 ADEBUG <<
"Current stop is for long time pedestrian stop, " << debug->is_stop_reason_by_prdestrian();
534 debug->set_is_full_stop(true);
535 }
536 } else {
537 ADEBUG <<
"Not into full stop decision by path remain.";
538 }
539
540 if (!debug->is_full_stop() && !debug->is_full_stop_soft()) {
541 is_full_stop_wait_time_diff_ = 0;
542 ResetNewFullStop();
543 } else {
544 if (!previous_is_full_stop_ && (debug->is_full_stop() || debug->is_full_stop_soft())) {
545 ADEBUG <<
"from go into full stop";
546 previous_is_full_stop_ = true;
547 form_go_to_full_stop_ = true;
548 }
549 }
550
551 double throttle_lowerbound = std::max(
552 vehicle_param_.
throttle_deadzone(), current_lon_based_pidcontroller_conf_.throttle_minimum_action());
553 double brake_lowerbound
554 = std::max(vehicle_param_.
brake_deadzone(), current_lon_based_pidcontroller_conf_.brake_minimum_action());
555 double calibration_value = 0.0;
556 double acceleration_lookup = (!
IsForwardModel()) ? -acceleration_cmd : acceleration_cmd;
557
559 + current_lon_based_pidcontroller_conf_.enable_slope_offset() * debug->slope_offset_compensation();
560 double acceleration_lookup_limit = 0.0;
561
562 if (current_lon_based_pidcontroller_conf_.use_acceleration_lookup_limit()) {
563 acceleration_lookup_limit = (acceleration_lookup > acceleration_lookup_limited) ? acceleration_lookup_limited
564 : acceleration_lookup;
565 }
566
567 if (FLAGS_use_preview_speed_for_table) {
568 if (current_lon_based_pidcontroller_conf_.use_acceleration_lookup_limit()) {
569 calibration_value = control_interpolation_->Interpolate(
570 std::make_pair(debug->preview_speed_reference(), acceleration_lookup_limit));
571 } else {
572 calibration_value = control_interpolation_->Interpolate(
573 std::make_pair(debug->preview_speed_reference(), acceleration_lookup));
574 }
575 } else {
576 if (current_lon_based_pidcontroller_conf_.use_acceleration_lookup_limit()) {
577 calibration_value = control_interpolation_->Interpolate(
578 std::make_pair(std::fabs(current_speed), acceleration_lookup_limit));
579 } else {
580 calibration_value = control_interpolation_->Interpolate(
581 std::make_pair(std::fabs(current_speed), acceleration_lookup));
582 }
583 }
584
585 if (acceleration_lookup >= 0) {
586 if (calibration_value >= 0) {
587 throttle_cmd = std::max(calibration_value, throttle_lowerbound);
588 } else {
589 throttle_cmd = throttle_lowerbound;
590 }
591 brake_cmd = 0.0;
592 } else {
593 throttle_cmd = 0.0;
594 if (calibration_value >= 0) {
595 brake_cmd = brake_lowerbound;
596 } else {
597 brake_cmd = std::max(-calibration_value, brake_lowerbound);
598 }
599 }
600
601 if (form_go_to_full_stop_ && (debug->is_full_stop() || debug->is_full_stop_soft())) {
602 ADEBUG <<
"from go to full stop in to control";
603 ADEBUG <<
"now brake = " << cmd->brake();
604 throttle_cmd = 0.0;
605 openspace_speed_control_throttle_cmd_ = 0.0;
606 if (debug->acceleration_reference() < current_lon_based_pidcontroller_conf_.emergency_quit_fullstop_mindec()) {
607 ADEBUG <<
"[NewFullStop] emergency stop, use acc before fullstop.";
608 } else {
609 if (((std::fabs(current_speed) < current_lon_based_pidcontroller_conf_.release_end_brake_speed())
610 || (std::fabs(debug->path_remain()) < current_lon_based_pidcontroller_conf_.fullstop_pathremain()))
611 && !begin_end_brake_) {
612 begin_end_brake_ = true;
613 fullstop_in_brake_ = cmd->brake();
614 double start_brake = current_lon_based_pidcontroller_conf_.full_stop_pitch_brake_param()
615 * fabs(std::sin(vehicle_pitch_rad + FLAGS_pitch_offset_deg * M_PI / 180));
616 if (start_brake > fullstop_in_brake_) {
617 fullstop_in_brake_ = start_brake;
618 }
619 hillup_fullstop_brake_rate_ = std::max(
620 current_lon_based_pidcontroller_conf_.full_stop_max_brake()
621 / (current_lon_based_pidcontroller_conf_.fullstop_window()
622 - current_lon_based_pidcontroller_conf_.full_stop_pitch_window_param()
623 * fabs(std::sin(vehicle_pitch_rad + FLAGS_pitch_offset_deg * M_PI / 180))),
624 0.0);
625 ADEBUG <<
"======brake rate = " << hillup_fullstop_brake_rate_;
626 ADEBUG <<
"brake cal window = "
627 << current_lon_based_pidcontroller_conf_.fullstop_window()
628 - fabs(std::sin(vehicle_pitch_rad + FLAGS_pitch_offset_deg * M_PI / 180));
629 }
631 double station_err = (debug->station_error() < 0) ? debug->station_error() : 0.0;
632 hillup_fullstop_brake_rate_ = hillup_fullstop_brake_rate_
633 + fabs(station_err) * current_lon_based_pidcontroller_conf_.full_stop_station_err_rate();
634 if (hillup_fullstop_brake_rate_
635 > current_lon_based_pidcontroller_conf_.max_brk_downhill_change_rate()) {
636 hillup_fullstop_brake_rate_ = current_lon_based_pidcontroller_conf_.max_brk_downhill_change_rate();
637 }
638 }
639
640 if (begin_end_brake_) {
641 fullstop_in_brake_ = fullstop_in_brake_ + hillup_fullstop_brake_rate_;
642 if ((fullstop_window_count_ > current_lon_based_pidcontroller_conf_.fullstop_window())
643 && (fullstop_in_brake_ > current_lon_based_pidcontroller_conf_.full_stop_max_brake()
644 + current_lon_based_pidcontroller_conf_.full_stop_pitch_brake_param()
645 * fabs(std::sin(vehicle_pitch_rad + FLAGS_pitch_offset_deg * M_PI / 180)))) {
646 hillup_fullstop_brake_rate_ = 0;
647 }
648 if (fullstop_in_brake_ >= 100.0) {
649 fullstop_in_brake_ = 100.0;
650 }
651 brake_cmd = fullstop_in_brake_;
652 ADEBUG <<
"=======now brkcmd===AL== = " << fullstop_in_brake_;
653 fullstop_window_count_++;
654 }
655 }
656
659 }
660
661 if (FLAGS_use_vehicle_epb) {
662 ADEBUG <<
"Into use vehicle epb.";
663 if ((debug->is_full_stop() && IsFullStopLongTerm(debug))
664 || (debug->is_full_stop() && debug->is_stop_reason_by_prdestrian())) {
665 cmd->set_parking_brake(true);
666 if (chassis->parking_brake()) {
667 brake_cmd = 0.0;
668 ResetNewFullStop();
669 }
670 } else {
671 cmd->set_parking_brake(false);
672 if (chassis->parking_brake()) {
673 ADEBUG <<
"Into park brake release.";
674 SetParkingBrake(¤t_lon_based_pidcontroller_conf_, cmd);
675 }
676 }
677 }
678
679
680
681 bool is_previous_replan =
injector_->previous_control_debug_mutable()->mutable_replan_debug()->is_need_replan();
682 if (is_previous_replan) {
684 }
686 || debug->is_full_stop_soft() || is_previous_replan) {
687 openspace_speed_control_throttle_cmd_ = 0.0;
688 openspace_count_ = 0;
689 }
690
692 && current_lon_based_pidcontroller_conf_.use_parking_speed_control()
693 && std::fabs(debug->path_remain()) > current_lon_based_pidcontroller_conf_.speed_path_remain()) {
695 && (debug->acceleration_reference()
696 <= (-1) * current_lon_based_pidcontroller_conf_.speed_itfc_dcc_emergency()))
698 && (debug->acceleration_reference()
699 >= current_lon_based_pidcontroller_conf_.speed_itfc_dcc_emergency()))) {
700
701 ADEBUG <<
"=======use speed control.";
702 openspace_count_++;
703 if (std::fabs(current_speed) <= current_lon_based_pidcontroller_conf_.openspace_r_std_v()) {
704 openspace_speed_control_throttle_cmd_ = openspace_speed_control_throttle_cmd_
705 + current_lon_based_pidcontroller_conf_.openspace_cmd_change();
706 }
707 if (std::fabs(current_speed) >= current_lon_based_pidcontroller_conf_.openspace_r_std_v()
708 + current_lon_based_pidcontroller_conf_.openspace_r_err()) {
709 if ((openspace_speed_control_throttle_cmd_
710 >= current_lon_based_pidcontroller_conf_.openspace_start_throttle())
711 && current_lon_based_pidcontroller_conf_.use_maintain_throttle()) {
712 openspace_speed_control_throttle_cmd_
713 = current_lon_based_pidcontroller_conf_.openspace_maintain_throttle();
714 } else {
715 openspace_speed_control_throttle_cmd_ = openspace_speed_control_throttle_cmd_
716 - current_lon_based_pidcontroller_conf_.openspace_cmd_change();
717 }
718 }
719 if ((std::fabs(current_speed) >= current_lon_based_pidcontroller_conf_.openspace_r_std_v()
720 - current_lon_based_pidcontroller_conf_.openspace_r_err())
721 && (std::fabs(current_speed) <= current_lon_based_pidcontroller_conf_.openspace_r_std_v()
722 + current_lon_based_pidcontroller_conf_.openspace_r_err())
723 && current_lon_based_pidcontroller_conf_.use_maintain_throttle()) {
724 openspace_speed_control_throttle_cmd_
725 = current_lon_based_pidcontroller_conf_.openspace_maintain_throttle();
726 }
727 if (vehicle_pitch <= current_lon_based_pidcontroller_conf_.speed_control_pitch_thres()
728 && openspace_speed_control_throttle_cmd_ < current_lon_based_pidcontroller_conf_.pitch_start_throttle()
729 && std::fabs(current_speed) < current_lon_based_pidcontroller_conf_.speed_control_min_speed()
730 && openspace_count_ < current_lon_based_pidcontroller_conf_.openspace_start_num()) {
731 openspace_speed_control_brake_cmd_ = current_lon_based_pidcontroller_conf_.epb_brake();
732 } else {
733 if (std::fabs(current_speed) >= current_lon_based_pidcontroller_conf_.openspace_r_std_v()
734 + current_lon_based_pidcontroller_conf_.openspace_r_err_big()) {
735 openspace_speed_control_brake_cmd_ = openspace_speed_control_brake_cmd_
736 + current_lon_based_pidcontroller_conf_.openspace_brk_change();
737 if (openspace_speed_control_brake_cmd_
738 > current_lon_based_pidcontroller_conf_.openspace_max_brk()) {
739 openspace_speed_control_brake_cmd_ = current_lon_based_pidcontroller_conf_.openspace_max_brk();
740 }
741 } else {
742 openspace_speed_control_brake_cmd_ = 0.0;
743 }
744 }
745
746 if (openspace_speed_control_throttle_cmd_ <= 0.0) {
747 openspace_speed_control_throttle_cmd_ = 0.0;
748 }
749
750 brake_cmd = openspace_speed_control_brake_cmd_;
751 if (brake_cmd > 0.0) {
752 throttle_cmd = 0.0;
753 } else {
754 throttle_cmd = openspace_speed_control_throttle_cmd_;
755 }
756 }
757 }
758
760 if (brake_cmd > current_lon_based_pidcontroller_conf_.full_stop_max_brake()) {
761 brake_cmd = current_lon_based_pidcontroller_conf_.full_stop_max_brake();
762 }
763 }
764
765
766 if (chassis->gear_location() != trajectory_message_->
gear()) {
769 throttle_cmd = 0.0;
770 brake_cmd = current_lon_based_pidcontroller_conf_.epb_brake();
771 }
772
773 debug->set_throttle_cmd(throttle_cmd);
774 debug->set_brake_cmd(brake_cmd);
775
776 throttle_cmd =
ThrottleCmdFilter(FLAGS_use_throttle_filter, FLAGS_throttle_smoothing_factor, throttle_cmd);
777 lon_debug_info->set_throttle_cmd_filter(throttle_cmd);
778
779 cmd->set_throttle(throttle_cmd);
780 cmd->set_brake(brake_cmd);
781 if (current_lon_based_pidcontroller_conf_.use_acceleration_lookup_limit()) {
782 cmd->set_acceleration(acceleration_lookup_limit);
783 previous_acc_output_ = acceleration_lookup_limit;
784 } else {
785 cmd->set_acceleration(acceleration_cmd);
786 previous_acc_output_ = acceleration_cmd;
787 }
788
790 || chassis->gear_location() == trajectory_message_->
gear()
792 cmd->set_gear_location(trajectory_message_->
gear());
793 } else {
794 cmd->set_gear_location(chassis->gear_location());
795 }
796
797 if (current_lon_based_pidcontroller_conf_.use_speed_itfc()) {
798 reference_spd_cmd_ = reference_spd_ + debug->speed_offset();
799 if ((reference_spd_ <= current_lon_based_pidcontroller_conf_.speed_itfc_full_stop_speed())
801 if ((debug->path_remain() >= current_lon_based_pidcontroller_conf_.speed_itfc_path_remain_min())
802 && (debug->preview_acceleration_reference()
803 >= current_lon_based_pidcontroller_conf_.speed_itfc_dcc_emergency())
804 && (debug->path_remain() <= current_lon_based_pidcontroller_conf_.speed_itfc_path_remain_max())) {
805 if (debug->preview_acceleration_reference()
806 <= current_lon_based_pidcontroller_conf_.speed_itfc_acc_thres()) {
807 if (reference_spd_ > current_lon_based_pidcontroller_conf_.speed_itfc_stop_speed()) {
808 reference_spd_cmd_ = current_lon_based_pidcontroller_conf_.speed_itfc_speed_cmd();
809 }
810 }
811 }
812 }
813 cmd->set_speed(reference_spd_cmd_);
814 if ((debug->is_full_stop() || debug->is_full_stop_soft())
816 cmd->set_speed(0.0);
817 }
818 }
819
820 debug->set_station_error_limited(station_error_limited);
821 debug->set_speed_offset(speed_offset);
822 debug->set_speed_controller_input_limited(speed_controller_input_limited);
823 debug->set_acceleration_cmd(acceleration_cmd);
824 debug->set_acceleration_lookup(acceleration_lookup);
825 debug->set_acceleration_lookup_limit(acceleration_lookup_limit);
826 debug->set_speed_lookup(current_speed);
827 debug->set_calibration_value(calibration_value);
828 debug->set_acceleration_cmd_closeloop(acceleration_cmd_closeloop);
829
830 lon_debug_info->set_path_remain_add(path_remain_add);
831 lon_debug_info->set_max_path_remain_when_stopped(max_path_remain_when_stopped_);
832 lon_debug_info->set_form_go_to_full_stop(form_go_to_full_stop_);
833 lon_debug_info->set_begin_end_brake(begin_end_brake_);
834 lon_debug_info->set_hillup_fullstop_brake_rate(hillup_fullstop_brake_rate_);
835 lon_debug_info->set_control_task_name(name_);
836
837 if (FLAGS_enable_csv_debug && speed_log_file_ != nullptr) {
838 fprintf(speed_log_file_,
839 "%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f,"
840 "%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %d,\r\n",
841 debug->station_reference(),
842 debug->station_error(),
843 station_error_limited,
844 debug->preview_station_error(),
845 debug->speed_reference(),
846 debug->speed_error(),
847 speed_controller_input_limited,
848 debug->preview_speed_reference(),
849 debug->preview_speed_error(),
850 debug->preview_acceleration_reference(),
851 acceleration_cmd_closeloop,
852 acceleration_cmd,
853 debug->acceleration_lookup(),
854 debug->acceleration_lookup_limit(),
855 debug->speed_lookup(),
856 calibration_value,
857 throttle_cmd,
858 brake_cmd,
859 debug->is_full_stop());
860 }
861
863}
static Status OK()
generate a success status.
double ThrottleCmdFilter(const bool &use_filter, const double &filter_coeff, const double &throttle)
bool VehicleStatusIdentificationUpdate(const localization::LocalizationEstimate *localization, const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory)
double GetVehicleSpeed(std::shared_ptr< DependencyInjector > injector, const bool &use_filter, const double &filter_coeff)
int InnerstateSaturationStatus() const
get saturation status
virtual double Control(const double error, const double dt)
compute control value based on the error
void SetLeadlagConf(const LeadlagConf &leadlag_conf)
alpha, beta and tau
std::shared_ptr< DependencyInjector > injector_
void ComputeLongitudinalErrors(const TrajectoryAnalyzer *trajectory, const double preview_time, const double ts, const double vehicle_speed, SimpleLongitudinalDebug *debug)
void GetPathRemain(SimpleLongitudinalDebug *debug)
void Reset_integral()
reset integral for pid controller
virtual double Control(const double error, const double dt)
compute control value based on the error
int IntegratorSaturationStatus() const
get saturation status
void SetPID(const PidPlusConf &pid_plus_conf)
set pid controller coefficients for the proportional, integral, and derivative
T Clamp(const T value, T bound1, T bound2)
Clamp a value between two bounds.
optional double throttle_deadzone
optional double max_acceleration
optional float max_abs_speed_when_stopped
optional double brake_deadzone
optional TrajectoryType trajectory_type
optional apollo::canbus::Chassis::GearPosition gear
optional apollo::common::Header header