WPILib 2012
WPILibRoboticsLibraryforFRC
Commands/PIDSubsystem.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_SUBSYSTEM_H__
00008 #define __PID_SUBSYSTEM_H__
00009 
00010 #include "Commands/Subsystem.h"
00011 #include "PIDController.h"
00012 #include "PIDSource.h"
00013 #include "PIDOutput.h"
00014 
00015 class NetworkTable;
00016 class SendablePIDController;
00017 
00018 class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource
00019 {
00020 public:
00021         PIDSubsystem(const char *name, double p, double i, double d);
00022         PIDSubsystem(const char *name, double p, double i, double d, double period);
00023         PIDSubsystem(double p, double i, double d);
00024         PIDSubsystem(double p, double i, double d, double period);
00025         virtual ~PIDSubsystem();
00026         
00027         void Enable();
00028         void Disable();
00029         NetworkTable *GetControllerTable();
00030 
00031         // SmartDashboardData interface
00032         virtual std::string GetType();
00033 
00034         // PIDOutput interface
00035         virtual void PIDWrite(float output);
00036 
00037         // PIDSource interface
00038         virtual double PIDGet();
00039         void SetSetpoint(double setpoint);
00040         void SetSetpointRelative(double deltaSetpoint);
00041         double GetSetpoint();
00042         double GetPosition();
00043         void SetSetpointRange(double a, double b);
00044 
00045 protected:
00046         PIDController *GetPIDController();
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