Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

robot/control/ManipulatorPIDPositionController

Go to the documentation of this file.
00001 /* **-*-c++-*-**************************************************************
00002   Copyright (C)2002 David Jung <opensim@pobox.com>
00003 
00004   This program/file is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008         
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details. (http://www.gnu.org)
00013         
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018   $Id: ManipulatorPIDPositionController 1037 2004-02-11 20:50:18Z jungd $
00019   $Revision: 1.9 $
00020   $Date: 2004-02-11 15:50:18 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_MANIPULATORPIDPOSITIONCONTROLLER_
00026 #define _ROBOT_MANIPULATORPIDPOSITIONCONTROLLER_
00027 
00028 #include <robot/control/control>
00029 
00030 #include <robot/Controller>
00031 #include <robot/Controllable>
00032 #include <robot/KinematicChain>
00033 
00034 
00035 namespace robot {
00036 namespace control {
00037 
00038 /**
00039  * Controls the inputs of a Robot's serial manipulator to maintain a
00040  *  reference position. 
00041  *
00042  * Requires the following ControlInterface (:type)
00043  *
00044  *  :JointVelocityControl
00045  *   - outputs control manipulator joint velocity and corresponding inputs give joint position
00046  *
00047  * Provides the following ControlInterface (name:type)
00048  *
00049  *  manipulatorPosition:JointPositionControl
00050  *   - outputs control the position of a maniulators joints (angle for revolute joints
00051  *     and extension for prismatic joints)
00052  *
00053  * \todo later this should be changed to require :JointForceControl instead.
00054  *
00055  */
00056 class ManipulatorPIDPositionController : public robot::Controller, public robot::Controllable
00057 {
00058 public:
00059   ManipulatorPIDPositionController(const robot::KinematicChain& chain);
00060   ManipulatorPIDPositionController(const ManipulatorPIDPositionController& c)
00061     : chain(c.chain), manipInterface(c.manipInterface), positionInterface(c.positionInterface)
00062     {}
00063 
00064   virtual String className() const { return String("ManipulatorPIDPositionController"); }
00065   virtual Object& clone() const { return *NewObj ManipulatorPIDPositionController(*this); } 
00066 
00067 
00068   virtual void setControlInterface(ref<ControlInterface> controlInterface);
00069 
00070   virtual bool isConnected() const;
00071 
00072   virtual bool iterate(const base::Time& time); 
00073 
00074   virtual ref<ControlInterface> getControlInterface(String interfaceName="") throw(std::invalid_argument);
00075 
00076   
00077   void setCoeffs(Real Kp, Real Ki=0, Real Kd=0)
00078     { this->Kp = Kp; this->Ki = Ki; this->Kd = Kd; }
00079   
00080 protected:
00081 
00082   class PositionInterface : public robot::ControlInterface
00083   {
00084   public:
00085     PositionInterface(ref<ManipulatorPIDPositionController> c)
00086       : c(c) { setName("manipulatorPosition"); setType("JointPositionControl"); }
00087     PositionInterface(const PositionInterface& i)
00088       : c(i.c) {}
00089 
00090     virtual String className() const { return String("PositionInterface"); }
00091     virtual Object& clone() const { return *NewObj PositionInterface(*this); } 
00092 
00093     Int inputSize() const;
00094     String inputName(Int i) const;
00095     Real getInput(Int i) const;
00096     const Vector& getInputs() const;
00097     
00098     Int outputSize() const;
00099     String outputName(Int i) const;
00100     void setOutput(Int i, Real value);
00101     void setOutputs(const Vector& values);
00102 
00103   protected:
00104     ref<ManipulatorPIDPositionController> c;
00105   };
00106 
00107   
00108   robot::KinematicChain chain; ///< kinematic chain of the manipulator we're controlling
00109 
00110   ref<robot::ControlInterface>  manipInterface; ///< interface for joint control of manipulator
00111   ref<PositionInterface>     positionInterface; ///< interface we return for joint position control
00112 
00113   Int lastInputSize;  ///< size of input on previous iteration
00114   Int lastOutputSize; ///< size of output on previous iteration
00115 
00116   Real Kp;
00117   Real Ki;
00118   Real Kd;
00119 
00120   Vector R;  // reference position
00121   Vector pe; // previous error e
00122   Vector s; // sum of error e
00123 
00124   
00125 
00126 };
00127 
00128 
00129 }
00130 } // robot::control
00131 
00132 #endif

Generated on Thu Jul 29 15:56:34 2004 for OpenSim by doxygen 1.3.6