pid.h

Go to the documentation of this file.
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.12  2009/08/12 10:26:47  der
00024  *   tau instead of alpha
00025  *
00026  *   Revision 1.11  2009/05/11 15:43:22  martius
00027  *   new velocity controlling servo motors
00028  *
00029  *   Revision 1.10  2007/07/03 13:01:41  martius
00030  *   new pid formulas, with stepsize
00031  *   we use clipped sum for integral term
00032  *   and clipped derivative value
00033  *
00034  *   Revision 1.9  2007/04/03 16:27:50  der
00035  *   no stepD anymore
00036  *
00037  *   Revision 1.8  2007/01/26 12:04:15  martius
00038  *   servos combinied into OneAxisServo
00039  *
00040  *   Revision 1.7  2006/07/14 12:23:32  martius
00041  *   selforg becomes HEAD
00042  *
00043  *   Revision 1.6.4.3  2006/02/07 15:51:56  martius
00044  *   axis, setpower
00045  *
00046  *   Revision 1.6.4.2  2006/01/10 14:48:59  martius
00047  *   indentation
00048  *   #ifdef clausel
00049  *
00050  *   Revision 1.6.4.1  2005/12/20 17:53:42  martius
00051  *   changed to Joints from joint.h
00052  *   new servos for universal and hinge2
00053  *
00054  *   Revision 1.6  2005/11/09 14:08:48  martius
00055  *   *** empty log message ***
00056  *
00057  *   Revision 1.5  2005/11/09 13:28:24  fhesse
00058  *   GPL added
00059  *                                                                * 
00060  ***************************************************************************/
00061 #ifndef __PID_H
00062 #define __PID_H
00063 
00064 namespace lpzrobots {
00065     
00066   class PID
00067   {
00068     //*********************attributes***************
00069     //private:
00070   public:
00071                 
00072     double position;
00073     double lastposition;
00074     double last2position;
00075                 
00076     double error;
00077     double lasterror;
00078     double derivative;
00079     double targetposition;
00080                 
00081     double KP;
00082     double KI;
00083     double KD;
00084     double tau;
00085                 
00086     double P;
00087     double D;
00088     double I;
00089         
00090     double force;
00091     double lasttime;  // last update time (to calc stepsize)
00092 
00093     //*********************methods******************
00094   public :
00095     /// KP is used as a general koefficient. KI and KD can be tuned without dependence of KP
00096     PID ( double KP = 100 , double KI = 2.0 , double KD = 0.3 );
00097  
00098     void setKP(double KP);
00099  
00100     void setTargetPosition ( double newpos );
00101                 
00102     double getTargetPosition ();
00103                 
00104     double step ( double newsensorval, double time);
00105     double stepNoCutoff ( double newsensorval, double time);
00106   };
00107 
00108 }
00109 
00110 #endif

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7