Robotsystem of the Robot Group Leipzig: pid.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

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