org.lejon
Class PIDController

java.lang.Object
  extended byorg.lejon.PIDController

public class PIDController
extends java.lang.Object

This is an implementation of a PID controller to control and compensate the steering error of a DD. We use the rotation differential of the left and right wheel, i.e. the difference between the ticks of the left and the right rotation sensor, as input to the controller.

The setpoint given by the user is the constant ticks difference measured after a period of TIMEBASE, wich is the (constant) time between two successive calls to controlPID(). The setpoint is compared against the actual input and the error is calculated.

Then the error is amplified by the PID constants where the amplified error forms the output of the PID. The PID output is then actuated. The error is transformed in an equivalent power differential for the left and right motor wich compensates the measured error.


Constructor Summary
PIDController()
           
 
Method Summary
 float controlPID(int ticksLeft, int ticksRight)
          Calls the control algorithm of the PID with inputs y=(ticksLeft - ticksRight) and r=setpoint set by reset().
 void init(DriveParameters params)
          Intialize the PID with the PID constants and the MaxTicksPerTimeBase from DriveParameters
 void reset(float newSetpoint)
          Reset the PID with a new setpoint
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PIDController

public PIDController()
Method Detail

init

public void init(DriveParameters params)
Intialize the PID with the PID constants and the MaxTicksPerTimeBase from DriveParameters

Parameters:
params - the specific drive parameters

reset

public void reset(float newSetpoint)
Reset the PID with a new setpoint

Parameters:
newSetpoint - the new setpoint

controlPID

public float controlPID(int ticksLeft,
                        int ticksRight)
Calls the control algorithm of the PID with inputs y=(ticksLeft - ticksRight) and r=setpoint set by reset().

Parameters:
ticksLeft - amount of TICKS from left wheel
ticksRight - amount of TICKS from right wheel
Returns:
the current setpoint error e which is controlled now