Open fselius opened 9 years ago
Ok the PID module 1st version is now in the navigation/PID folder
@efiShtain @fselius
https://github.com/fselius/qtcopter/blob/0fe8d4b5c1ba65911804490475c468e5eb935be1/src/qtcopter/src/qtcopter/navigation/PID/PIDModule.py#L28 The differential controller acts on the the differential of the error it self -> error_dot = (error[t]-error[t-1])/dt Comment the code properly :smile:
Since the input for the RC Override values start at 1000, lets add an offset
variable.
Output would be pid output + offset
.
About the integral, assuming we get the error and we don't need to calculate it, and in order to fix the windup effect, the integral is calculated in line 23, is that what you meant? or i just need to divide by dt?
The integrator looks fine as far as I can tell, windup included (Needs testing of course). I was only referring to the differential part, you need the derivative of the error for that.
Uploaded pid.html
to the google drive folder, have a look.
(You need to download the file and open it with Chrome/Firefox)
Implement a generic PID controller with a constant loop rate. Take care of output limiters and how they affect the integral controller (Windup). Suggestion - a secondary thread would acquire data from relevant topics (Sensors or image processing) and store values in a local data structure. Every loop iteration the main thread would grab values from the local data structure, pass them to controller as measurements, calculate PID output, publish said output using an RC Override message.