hingeservo.cpp

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: hingeservo.cpp,v $
00023  *   Revision 1.1.4.4  2006/02/07 15:51:56  martius
00024  *   axis, setpower
00025  *
00026  *   Revision 1.1.4.3  2006/01/10 14:47:57  martius
00027  *   *** empty log message ***
00028  *
00029  *   Revision 1.1.4.2  2006/01/02 08:24:12  fhesse
00030  *   getAngle() changed to getPosition1();
00031  *   the same with angle rate
00032  *
00033  *   Revision 1.1.4.1  2005/12/20 17:53:42  martius
00034  *   changed to Joints from joint.h
00035  *   new servos for universal and hinge2
00036  *
00037  *   Revision 1.1  2005/09/12 00:08:45  martius
00038  *   servo for hinges
00039  *
00040  *                                                                 *
00041  ***************************************************************************/
00042 #include "hingeservo.h"
00043 #include <assert.h>
00044 
00045 namespace lpzrobots {
00046 
00047   HingeServo::HingeServo(HingeJoint* joint, double min, double max, double power)
00048     : pid(power, 2.0, 0.3 ), joint(joint)
00049   {
00050     assert(min <= 0 && min <= max);
00051     this->min = min;
00052     this->max = max;
00053   }
00054 
00055   void HingeServo::set(double pos){ 
00056     if(pos > 0){ 
00057       pos *= max; 
00058     }else{
00059       pos *= -min;
00060     }
00061     pid.setTargetPosition(pos);  
00062     double force = pid.stepWithD(joint->getPosition1(), joint->getPosition1Rate());
00063     joint->addTorque(force);
00064   }
00065 
00066   double HingeServo::get(){
00067     double pos = joint->getPosition1();    
00068     if(pos > 0){
00069       pos /= max; 
00070     }else{
00071       pos /= -min;
00072     }
00073     return pos;
00074   }
00075 
00076   void HingeServo::setPower(double power){
00077     pid.setKP(power);
00078   }
00079 
00080   
00081 }

Generated on Tue Apr 4 19:05:03 2006 for Robotsystem from Robot Group Leipzig by  doxygen 1.4.5