00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 * * 00022 * $Log: pid.h,v $ 00023 * Revision 1.6.4.3 2006/02/07 15:51:56 martius 00024 * axis, setpower 00025 * 00026 * Revision 1.6.4.2 2006/01/10 14:48:59 martius 00027 * indentation 00028 * #ifdef clausel 00029 * 00030 * Revision 1.6.4.1 2005/12/20 17:53:42 martius 00031 * changed to Joints from joint.h 00032 * new servos for universal and hinge2 00033 * 00034 * Revision 1.6 2005/11/09 14:08:48 martius 00035 * *** empty log message *** 00036 * 00037 * Revision 1.5 2005/11/09 13:28:24 fhesse 00038 * GPL added 00039 * * 00040 ***************************************************************************/ 00041 #ifndef __PID_H 00042 #define __PID_H 00043 00044 namespace lpzrobots { 00045 00046 class PID 00047 { 00048 //*********************attributes*************** 00049 //private: 00050 public: 00051 00052 double position; 00053 double lastposition; 00054 double last2position; 00055 00056 double error; 00057 double lasterror; 00058 00059 double targetposition; 00060 00061 double KP; 00062 double KD; 00063 double KI; 00064 double alpha; 00065 00066 double P; 00067 double D; 00068 double I; 00069 00070 double force; 00071 00072 //*********************methods****************** 00073 public : 00074 /// KP is used as a general koefficient. KI and KD can be tuned without dependence of KP 00075 PID ( double KP = 100 , double KI = 2.0 , double KD = 0.3 ); 00076 00077 void setKP(double KP); 00078 00079 void setTargetPosition ( double newpos ); 00080 00081 double getTargetPosition (); 00082 00083 double step ( double newsensorval ); 00084 double stepWithD ( double newsensorval, double derivative ); 00085 }; 00086 00087 } 00088 00089 #endif