Now you can download a copy of these docs so you can use them offline! Download now
PIDSubsystem.cpp
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 #include "Commands/PIDSubsystem.h" 00008 #include "SmartDashboard/SendablePIDController.h" 00009 #include "float.h" 00010 00011 // XXX max and min are not used? 00012 00013 PIDSubsystem::PIDSubsystem(const char *name, double p, double i, double d) : 00014 Subsystem(name) 00015 { 00016 m_max = DBL_MAX; 00017 m_min = DBL_MIN; 00018 m_controller = new SendablePIDController(p, i, d, this, this); 00019 } 00020 00021 PIDSubsystem::PIDSubsystem(const char *name, double p, double i, double d, 00022 double period) : 00023 Subsystem(name) 00024 { 00025 m_max = DBL_MAX; 00026 m_min = DBL_MIN; 00027 m_controller = new SendablePIDController(p, i, d, this, this, period); 00028 } 00029 00030 PIDSubsystem::PIDSubsystem(double p, double i, double d) : 00031 Subsystem("PIDSubsystem") 00032 { 00033 m_max = DBL_MAX; 00034 m_min = DBL_MIN; 00035 m_controller = new SendablePIDController(p, i, d, this, this); 00036 } 00037 00038 PIDSubsystem::PIDSubsystem(double p, double i, double d, double period) : 00039 Subsystem("PIDSubsystem") 00040 { 00041 m_max = DBL_MAX; 00042 m_min = DBL_MIN; 00043 m_controller = new SendablePIDController(p, i, d, this, this, period); 00044 } 00045 00046 PIDSubsystem::~PIDSubsystem() 00047 { 00048 delete m_controller; 00049 } 00050 00051 void PIDSubsystem::Enable() 00052 { 00053 m_controller->Enable(); 00054 } 00055 00056 void PIDSubsystem::Disable() 00057 { 00058 m_controller->Disable(); 00059 } 00060 00061 std::string PIDSubsystem::GetType() 00062 { 00063 return "PIDSubsystem"; 00064 } 00065 00066 NetworkTable *PIDSubsystem::GetControllerTable() 00067 { 00068 return m_controller->GetTable(); 00069 } 00070 00071 PIDController *PIDSubsystem::GetPIDController() 00072 { 00073 return m_controller; 00074 } 00075 00076 void PIDSubsystem::SetSetpoint(double setpoint) 00077 { 00078 m_controller->SetSetpoint(setpoint); 00079 } 00080 00081 void PIDSubsystem::SetSetpointRelative(double deltaSetpoint) 00082 { 00083 SetSetpoint(GetSetpoint() + deltaSetpoint); 00084 } 00085 00086 double PIDSubsystem::GetSetpoint() 00087 { 00088 return m_controller->GetSetpoint(); 00089 } 00090 00091 double PIDSubsystem::GetPosition() 00092 { 00093 return ReturnPIDInput(); 00094 } 00095 00096 void PIDSubsystem::SetSetpointRange(double a, double b) 00097 { 00098 if (a <= b) 00099 { 00100 m_min = a; 00101 m_max = b; 00102 } 00103 else 00104 { 00105 m_min = b; 00106 m_max = a; 00107 } 00108 } 00109 00110 void PIDSubsystem::PIDWrite(float output) 00111 { 00112 UsePIDOutput(output); 00113 } 00114 00115 double PIDSubsystem::PIDGet() 00116 { 00117 return ReturnPIDInput(); 00118 }
Generated on Thu Jan 12 2012 22:35:23 for WPILibC++ by
1.7.1