fselius / qtcopter

2 stars 0 forks source link

PID Controller #3

Open fselius opened 9 years ago

fselius commented 9 years ago

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.

noamyogev84 commented 9 years ago

Ok the PID module 1st version is now in the navigation/PID folder

  1. not tested.
  2. let's sit and discuss this.

@efiShtain @fselius

fselius commented 9 years ago

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:

fselius commented 9 years ago

Since the input for the RC Override values start at 1000, lets add an offset variable. Output would be pid output + offset.

efiShtain commented 9 years ago

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?

fselius commented 9 years ago

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.

fselius commented 9 years ago

Uploaded pid.html to the google drive folder, have a look. (You need to download the file and open it with Chrome/Firefox)