WPILib 2012
WPILibRoboticsLibraryforFRC
Commands/PIDCommand.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2011. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef __PID_COMMAND_H__
00008 #define __PID_COMMAND_H__
00009 
00010 #include "Commands/Command.h"
00011 #include "PIDSource.h"
00012 #include "PIDOutput.h"
00013 
00014 class NetworkTable;
00015 class PIDController;
00016 class SendablePIDController;
00017 
00018 class PIDCommand : public Command, public PIDOutput, public PIDSource
00019 {
00020 public:
00021         PIDCommand(const char *name, double p, double i, double d);
00022         PIDCommand(const char *name, double p, double i, double d, double period);
00023         PIDCommand(double p, double i, double d);
00024         PIDCommand(double p, double i, double d, double period);
00025         virtual ~PIDCommand();
00026         
00027         void SetSetpointRelative(double deltaSetpoint);
00028 
00029         // PIDOutput interface
00030         virtual void PIDWrite(float output);
00031 
00032         // PIDSource interface
00033         virtual double PIDGet();
00034 
00035         NetworkTable *GetControllerTable();
00036 
00037         virtual std::string GetType();
00038 protected:
00039         PIDController *GetPIDController();
00040         virtual void _Initialize();
00041         virtual void _Interrupted();
00042         virtual void _End();
00043         void SetSetpoint(double setpoint);
00044         double GetSetpoint();
00045         double GetPosition();
00046         void SetSetpointRange(double a, double b);
00047 
00048         virtual double ReturnPIDInput() = 0;
00049         virtual void UsePIDOutput(double output) = 0;
00050 
00051 private:        
00053         double m_max;
00055         double m_min;
00057         SendablePIDController *m_controller;
00058 };
00059 
00060 #endif
00061 
 All Classes Functions Variables