During the last week I made some improvements on the code that I need to report here in order to avoid any oversights after the upcoming vacations…
- Added a function to tune manually the P,I and D on the run.
- in pid.py added a function to calculate an average during the D_correction calculation. This help to have a smoother value.
- Display results every 0.2 sec, instead every cycle (trying to reduce cpu load).
- improved log
- Calculation of the angular speed (roll_rate, pitch_rate and yaw_rate) in the sensor_py. Those values are coming from the derivate of the roll,pitch and yaw already filtered with the complementary filter. they are not the row roll_rate,pithc_rate and yaw rate from the gyroscope.
The main improvement has been the introduction of the PID for the roll_rate.I did a new module called beta2.py where I put two PIDs in series. This is a typical approach in the quadcopter controller. The first PID returns the Roll_correction. (this number represent the angle variation that I ‘d like to have in one step).
Dividing the Roll_correction for the cycletime, it represent the angular speed (roll_rate) I’d like to have in one step.It is the target for my new roll_rate PID.The feedback is the angular speed calculated in the sensor.py.The result is a really more stable quadcopter, less nervous and more quick on the response.
Below the graph that show the current state of the tuning.
As you can see, there is still an oscillation, but it is between +/- 1 degree.Where I need to work is fact that the system never reach the target.(now I have a very simple roll_Pid , with I=0 and D=0. I’m thinking to set a v alue for the I also).