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