LineFollowerSimulator
Class PIDregulator

java.lang.Object
  extended by LineFollowerSimulator.PIDregulator
All Implemented Interfaces:
java.lang.Runnable

public class PIDregulator
extends java.lang.Object
implements java.lang.Runnable

Simulation of a PID regulator for a line following robot. The objects creates its own thread that periodicaly scans for line position and updates motor speeds.

Author:
Ondrej Stanek

Constructor Summary
PIDregulator(LineFollowerSimulator.MotorController motorCtrl, LineFollowerSimulator.Sensor sensor)
          Initializes PID regulator.
 
Method Summary
 void run()
          Thread that periodicaly updates motors' speed acording to the line position contains the PID regulator loop itself
 void setD(double d)
          Sets the derivate factor of PID regulator, if 0 is set, the diferencial regulation is supressed.
 void SetFrequency(int freq)
          Set the refresh frequency for PID regulation, e.g. how often the speed of motors is updated.
 void setI(double i)
          Sets the integral factor of PID regulator, if 0 is set, the integral regulation is supressed.
 void setP(double p)
          Sets the proportional factor of PID regulator, if 0 is set, the proportional regulation is supressed.
 void setSpeed(double speed)
          Sets the maximum speed of the robot.
 void StartPIDregulation()
          Runs a thread that periodically obtain line position from a sensor and updates motors' speed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PIDregulator

public PIDregulator(LineFollowerSimulator.MotorController motorCtrl,
                    LineFollowerSimulator.Sensor sensor)
Initializes PID regulator.

Parameters:
motorCtrl - a MotorController that will simulate robot movement
sensor - sensor that will provide line position
Method Detail

StartPIDregulation

public void StartPIDregulation()
Runs a thread that periodically obtain line position from a sensor and updates motors' speed.


SetFrequency

public void SetFrequency(int freq)
Set the refresh frequency for PID regulation, e.g. how often the speed of motors is updated.

Parameters:
freq - refresh frequency in Hz

run

public void run()
Thread that periodicaly updates motors' speed acording to the line position contains the PID regulator loop itself

Specified by:
run in interface java.lang.Runnable

setP

public void setP(double p)
Sets the proportional factor of PID regulator, if 0 is set, the proportional regulation is supressed.

Parameters:
p - positive number

setI

public void setI(double i)
Sets the integral factor of PID regulator, if 0 is set, the integral regulation is supressed.

Parameters:
i - positive number

setD

public void setD(double d)
Sets the derivate factor of PID regulator, if 0 is set, the diferencial regulation is supressed.

Parameters:
d - positive number

setSpeed

public void setSpeed(double speed)
Sets the maximum speed of the robot.

Parameters:
speed - positive number