apollo icon indicating copy to clipboard operation
apollo copied to clipboard

How to Tune PID, LQR and MPC Control Parameters (matiex_q, reverse_matrix_q and Kp, Ki, Kd) for real car in COMPELTE_AUTO_DRIVE?

Open Addi2020 opened this issue 6 years ago • 5 comments

I read an understand the procedure of control Tuning, but i have few question. Tune control parameter for actual car。。

  1. The car should be in (AUTO_DRIVE_MODE)?
  2. If auto drive mode then it required proper planning trajectory.
  3. How to change values of (matiex_q, reverse_matrix_q and Kp, Ki, Kd) in real time when the car is moving on auto drive mode? or we need to stop the car and change the value every time.
  4. These vales can only be change by hit and trial rule?

Addi2020 avatar Apr 16 '20 06:04 Addi2020

I am not sure if I really understand your question.

Use PID control for an example, the PID control param is use to just vertical control. And horizontal control used LQR.

  1. You need to drive a vehicle to get several sets of parameters, this is not on automatic driving mode. The parameters is in "apollo\modules\control\conf\calibration_table.pb.txt".
calibration {
  speed: 0.0
  acceleration: -1.43
  command: -35.0
}
calibration {
  speed: 0.0
  acceleration: -1.28
  command: -27.0
}
...
...
  1. When you get there parameters means you make the pid output more easy. For example, if your pid output wants the car to rise from 20km/h to 30km/h, how much throttle should you give? If there is a table, you search from it to get the value. Then the output of the pid is very simple, which means that you fit the car's dynamic curve through the table.

  2. Then you adjust the pid param and test the automatic driving mode. Which you said set the car in automatic driving mode and test the param and stop then adjust the param.

  station_pid_conf {
    integrator_enable: false
    integrator_saturation_level: 0.3
    kp: 0.2
    ki: 0.0
    kd: 0.0
  }
  low_speed_pid_conf {
    integrator_enable: true
    integrator_saturation_level: 0.3
    kp: 2.0
    ki: 0.3
    kd: 0.0
  }
  high_speed_pid_conf {
    integrator_enable: true
    integrator_saturation_level: 0.3
    kp: 1.0
    ki: 0.3
    kd: 0.0
  }
  1. I'm not so sure about the "matrix_q" param, Can anyone else help?

daohu527 avatar Apr 18 '20 06:04 daohu527

@daohu527, Thanks for response. You are right.

  1. First , I drive a vehicle to get several sets of parameters by using python data_collector.py. for exp: throttle speed break 15 5 -15 17 5 -17 20 5 -20 25 5 -25 up to 80 5 -80
  2. second, I create the calibration table by using python files (module/tools/vehicle_callibration) which contains the default values of Kp, Ki, Kd for longitudinal and lateral control. e.g. matrix_q: 0.05 matrix_q: 0.0 matrix_q: 1.0 matrix_q: 0.0 reverse_matrix_q: 0.5 reverse_matrix_q: 0.0 reverse_matrix_q: 0.4 reverse_matrix_q: 0.0

station_pid_conf { integrator_enable: false integrator_saturation_level: 0.3 kp: 0.2 ki: 0.0 kd: 0.0 } low_speed_pid_conf { integrator_enable: true integrator_saturation_level: 0.3 kp: 0.5 ki: 0.3 kd: 0.0 } high_speed_pid_conf { integrator_enable: true integrator_saturation_level: 0.3 kp: 1.0 ki: 0.3 kd: 0.0 } e.g. calibration_table { calibration { speed: 0.0 acceleration: -6.67 command: -50.0 }

QUESTION:

  1. How do we know which values for Kp. Ki, Kd have better performance for auto_drive?
  2. Now how to do we change the vales of control gains/ param (matiex_q, reverse_matrix_q and Kp, Ki, Kd)?

Addi2020 avatar Apr 20 '20 06:04 Addi2020

@daohu527 How to record a good calibration data? I try many different commands (which start the car and then stop after it reach to speed 5m/s) for e.g. (fix speed) (throttle speed break) 3 5 -3 4 5 -4 5 5 -5 7 5 -7 10 5 -10 12 5 -12 up-to 50 5 -50

But after getting the data and creating calibration table, the Auto Drive car cannot start. what is the problem in calibration file?

Addi2020 avatar Apr 21 '20 10:04 Addi2020

Here is a guide How to Tune Control Parameters

daohu527 avatar Apr 22 '20 01:04 daohu527

@daohu527 , Thank you , we can tune the control parameters in (mosules/control/conf/control_conf.pb.txt) file and restart the Auto Drive car.

Addi2020 avatar Apr 22 '20 04:04 Addi2020