MOOS 0.2375
|
00001 00002 // 00003 // MOOS - Mission Oriented Operating Suite 00004 // 00005 // A suit of Applications and Libraries for Mobile Robotics Research 00006 // Copyright (C) 2001-2005 Massachusetts Institute of Technology and 00007 // Oxford University. 00008 // 00009 // This software was written by Paul Newman at MIT 2001-2002 and Oxford 00010 // University 2003-2005. email: pnewman@robots.ox.ac.uk. 00011 // 00012 // This file is part of a MOOS Core Component. 00013 // 00014 // This program is free software; you can redistribute it and/or 00015 // modify it under the terms of the GNU General Public License as 00016 // published by the Free Software Foundation; either version 2 of the 00017 // License, or (at your option) any later version. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 // General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00030 // ScalarPID.h: interface for the CScalarPID class. 00031 // 00033 00034 #if !defined(AFX_SCALARPID_H__0DC4321A_A987_4499_8902_AAE9F515E921__INCLUDED_) 00035 #define AFX_SCALARPID_H__0DC4321A_A987_4499_8902_AAE9F515E921__INCLUDED_ 00036 00037 #if _MSC_VER > 1000 00038 #pragma once 00039 #endif // _MSC_VER > 1000 00040 00041 #include <string> 00042 #include <list> 00043 #include <fstream> 00044 //using namespace std; 00045 00046 class CScalarPID 00047 { 00048 public: 00049 bool SetGoal(double dfGoal); 00050 bool SetLogPath(std::string & sPath); 00051 bool SetLog(bool bLog); 00052 bool SetName(std::string sName); 00053 void SetLimits(double dfIntegralLimit, double dfOutputLimit); 00054 bool Run(double dfeIn,double dfErrorTime,double & dfOut); 00055 unsigned int m_nHistorySize; 00056 00057 std::list<double> m_DiffHistory; 00058 CScalarPID(); 00059 CScalarPID( double dfKp, 00060 double dfKd, 00061 double dfKi, 00062 double dfIntegralLimit, 00063 double dfOutputLimit); 00064 00065 virtual ~CScalarPID(); 00066 00067 void SetGains(double dfKp,double dfKd,double dfKi); 00068 00069 protected: 00070 00071 double m_dfKi; 00072 double m_dfKd; 00073 double m_dfKp; 00074 double m_dfe; 00075 double m_dfeSum; 00076 double m_dfeOld; 00077 double m_dfeDiff; 00078 double m_dfDT; 00079 double m_dfOldTime; 00080 double m_dfOut; 00081 double m_dfIntegralLimit; 00082 double m_dfOutputLimit; 00083 00084 00085 protected: 00086 bool Log(); 00087 std::string m_sName; 00088 std::string m_sLogPath; 00089 00090 //note this is just for loggin purposes... 00091 double m_dfGoal; 00092 int m_nIterations; 00093 bool m_bLog; 00094 std::ofstream m_LogFile; 00095 }; 00096 00097 #endif // !defined(AFX_SCALARPID_H__0DC4321A_A987_4499_8902_AAE9F515E921__INCLUDED_)