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

robot/control/kinematics/IKORController

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: IKORController 1036 2004-02-11 20:48:55Z jungd $
00019   $Revision: 1.11 $
00020   $Date: 2004-02-11 15:48:55 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_CONTROL_KINEMATICS_IKORCONTROLLER_
00026 #define _ROBOT_CONTROL_KINEMATICS_IKORCONTROLLER_
00027 
00028 #include <robot/control/kinematics/kinematics>
00029 
00030 #include <robot/Controller>
00031 #include <robot/Controllable>
00032 #include <robot/Robot>
00033 #include <robot/control/kinematics/InverseKinematicsSolver>
00034 
00035 
00036 namespace robot {
00037 namespace control {
00038 namespace kinematics {
00039 
00040 
00041 /// IKOR (Inverse Kinematics On Redundant systems) Controller.
00042 /**
00043  * An inverse kinematics controller for redundant manipulators.  Can use either a
00044  * least norm solution method (without constraints) or the Full Space Parameterization (FSP)
00045  * method (with a selection of optimization method, criteria and constraints).
00046  *
00047  * Requires the following ControlInterface (:type)
00048  *
00049  *  :JointPositionControl
00050  *   - outputs control the position of a maniulators joints (angle for revolute joints
00051  *     and extension for prismatic joints)
00052  *
00053  * Provides the following ControlInterfaces (name:type)
00054  *
00055  *  manipulatorEEPosition:EndEffectorPositionControl
00056  *   - outputs control the position (and possibly orientation) of the manipulator
00057  *     end-effector (through inverse kinematics).  Inputs give the current EE position.
00058  *
00059  *  manipulatorLinkPositions:LinkOriginPositions
00060  *   - inputs provide the position of the manipulator link origins
00061  *
00062  */
00063 class IKORController : public robot::Controller, public robot::Controllable
00064 {
00065 public:
00066   enum IKMethod { LeastNorm, FSPLagrangian };
00067 
00068   IKORController(IKMethod method, ref<robot::Robot> robot, Int manipulatorIndex,
00069                  bool platformActive = false, bool orientationControl = true,
00070                  base::Orient::Representation orientationRepresentation = base::Orient::EulerRPY);
00071 
00072   virtual String className() const { return String("IKORController"); }
00073 
00074 
00075   /// Requires a "JointPositionControl" ControlInterface type.
00076   virtual void setControlInterface(ref<ControlInterface> controlInterface);
00077 
00078   virtual bool isConnected() const { return (manipulatorInterface!=0); }
00079 
00080   virtual bool iterate(const base::Time& time);
00081 
00082   virtual array<std::pair<String,String> > controlInterfaces() const; 
00083 
00084   virtual ref<ControlInterface> getControlInterface(String interfaceName="") throw(std::invalid_argument);
00085 
00086   /// proximity distance below which obstacle avoidance constraints become active
00087   void setProximityDangerDistance(Real d) { this->d = d; }
00088   
00089 protected:
00090   IKMethod method;                 ///< Inverse Kinematics method to employ (e.g. FSP)
00091   ref<const robot::Robot> robot;   ///< Robot to be controlled 
00092   bool platformActive;             ///< consider first dof(s) to be the platform?
00093   bool orientationControl;         ///< position & orientation control of EE, or just position control?
00094   base::Orient::Representation orientRep;///< representation of the orientation components of the interface inputs/outputs
00095 
00096   robot::KinematicChain manipChain;    ///< kinematic chain of the manipulator (without any tools)
00097 
00098   Real d; // proximity danger distance
00099   
00100   /// Solvers to use for computing IK
00101   ref<InverseKinematicsSolver>     ikSolver;
00102   InverseKinematicsSolver::OptimizationMethod      optMethod;
00103   InverseKinematicsSolver::OptimizationCriterion   optCriterion;
00104   InverseKinematicsSolver::OptimizationConstraints optConstraints;
00105   Vector tx; ///< requested target End-Effector position
00106   mutable Vector x;     ///< temporary to hold last computed EE position/orient 
00107   mutable Vector q;     ///< corresponding joint variables for posEE
00108 
00109   ref<ControlInterface> manipulatorInterface; ///< position ControlInterface for manipulator
00110   ref<ControlInterface> proxInterface;        ///< proximity sensor interface (or 0)
00111 
00112 
00113   /// Calculate the End-Effector position and orientation from the forward kinematics transform
00114   /** caches q & x. Representation of orientation component is orientRep */
00115   void calcEEPositionOrientation();
00116 
00117   
00118   /// ControlInterface provided for controlling the desired End-Effector motion
00119   /** Just holds a ref to IKORController and calls back to its members to do its work */
00120   class EEPositionControlInterface : public robot::ControlInterface
00121   {
00122   public:
00123     EEPositionControlInterface(ref<IKORController> c, const String& interfaceName, const String& interfaceType)
00124       : c(c) { setName(interfaceName); setType(interfaceType); }
00125     EEPositionControlInterface(const EEPositionControlInterface& copy)
00126       : c(copy.c) {}
00127 
00128     virtual String className() const { return String("EEPositionControlInterface"); }
00129     virtual Object& clone() const { return *NewObj EEPositionControlInterface(*this); } 
00130 
00131     Int inputSize() const;
00132     String inputName(Int i) const; 
00133     Real getInput(Int i) const;
00134     const Vector& getInputs() const;
00135     
00136     Int outputSize() const;
00137     String outputName(Int i) const; 
00138     void setOutput(Int i, Real value);
00139     void setOutputs(const Vector& values);
00140    
00141   protected:
00142     ref<IKORController> c;
00143 
00144   };
00145   
00146   /// ControlInterface provided for obtaining the link origin positions
00147   /** Just holds a ref to IKORController and calls back to its members to do its work */
00148   class LinkPositionsControlInterface : public robot::ControlInterface
00149   {
00150   public:
00151     LinkPositionsControlInterface(ref<IKORController> c, const String& interfaceName, const String& interfaceType)
00152       : c(c) { setName(interfaceName); setType(interfaceType); }
00153     LinkPositionsControlInterface(const LinkPositionsControlInterface& copy)
00154       : c(copy.c) {}
00155 
00156     virtual String className() const { return String("LinkPositionsControlInterface"); }
00157     virtual Object& clone() const { return *NewObj LinkPositionsControlInterface(*this); } 
00158 
00159     Int inputSize() const;
00160     String inputName(Int i) const; 
00161     Real getInput(Int i) const;
00162     const Vector& getInputs() const;
00163     
00164     Int outputSize() const;
00165     String outputName(Int i) const; 
00166     void setOutput(Int i, Real value);
00167     void setOutputs(const Vector& values);
00168    
00169   protected:
00170     ref<IKORController> c;
00171 
00172   };
00173 
00174   mutable Vector linkPositions; ///< positions of origins of each link (3*M components - i.e. (x,y,z)*M )
00175 
00176 
00177   static array<String> inputName;  ///< name of EEPositionControlInterface inputs
00178   static array<String> outputName; ///< name of EEPositionControlInterface outputs
00179 
00180   
00181 
00182   friend class EEPositionControlInterface;
00183 };
00184 
00185 
00186 }
00187 }
00188 } // robot::control::kinematics
00189 
00190 #endif

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