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

robot/control/kinematics/InverseKinematicsSolver

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: InverseKinematicsSolver 1034 2004-02-11 20:48:29Z jungd $
00019   $Revision: 1.7 $
00020   $Date: 2004-02-11 15:48:29 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_CONTROL_KINEMATICS_INVERSEKINEMATICSSOLVER_
00026 #define _ROBOT_CONTROL_KINEMATICS_INVERSEKINEMATICSSOLVER_
00027 
00028 #include <robot/control/kinematics/kinematics>
00029 
00030 #include <base/ReferencedObject>
00031 #include <base/Matrix>
00032 #include <base/Orient>
00033 
00034 #include <bitset>
00035 
00036 
00037 namespace robot {
00038 namespace control {
00039 namespace kinematics {
00040 
00041 
00042 /// Abstract Inverse Kinematics Solver
00043 /**
00044  * Abstract base class for concrete classes that implement specific
00045  * method for solving the inverse kinematics problem (required joint 
00046  * parameter changes (dq) to achieve end-effector motions specificed in 
00047  * task space (dx) )
00048  */
00049 class InverseKinematicsSolver : public base::ReferencedObject
00050 {
00051 public:
00052 
00053   enum OptimizationMethod { DefaultMethod, PseudoInv, Lagrangian, BangBang, Simplex };
00054   enum OptimizationCriterion { DefaultCriterion, LeastNorm, LeastFlow  };
00055   enum OptimizationConstraint { DefaultConstraints, JointLimits, ObstacleAvoidance, 
00056                                 Acceleration, EndEffectorImpact  };
00057 
00058   typedef std::bitset<sizeof(Int)*8> OptimizationConstraints;
00059 
00060   /// Solve inverse kinematics.
00061   /**
00062    *  Takes current the joint parameters (q), end-effector position (x), and the required change in
00063    *  end-effector position (dx) and returns the changes in joint parameters (dq) that will achieve
00064    *  the requested dx.
00065    * 
00066    *   @param dx                        An vector specifiying the required change in end-effector
00067    *                                    position (in N-dim task space)
00068    *
00069    *   @param x                         An vector specifiying the current end-effector position (in N-dim task space)
00070    *
00071    *   @param q                         An M-dim vector representing the current joint parameters. 
00072    *
00073    *   @param J                         An NxM Jacobian expression for the system, evaluated at q.
00074    *
00075    *   @param optMethod                 Optimization method employed to narrow the solution space to a single
00076    *                                    vector (if necessary).  Values are specific to concrete subclasses.
00077    *
00078    *   @param optCriterion              Optimization criteria for the optimization method. Values are specific
00079    *                                    to concrete subclasses.
00080    *
00081    *   @param optConstraints            Optimization constraints (if any). Values are specific to concrete
00082    *                                    subclasses.
00083    *
00084    *   @param orientationRepresentation The representation used in [d]x to specify the [change in] orientation
00085    *                                    in task-space.  If N=6, it is assumed to specify a [delta] position
00086    *                                    and a orientation in R3.  The first 3 components of [d]x represent
00087    *                                    a ([d]x,[d]y,[d]z) [delta] position, and the remaining components represent
00088    *                                    a [delta] orientation in the specified representation.  For example,
00089    *                                    EulerRPY specifies that the [d]x(3,4,6) components represent the [delta] Roll,
00090    *                                    Pith and Yaw angles.  Quat specifies that the [d]x(3,4,5,6) components 
00091    *                                    represent a [delta] orientation via a quaternion.  The delta orientation
00092    *                                    components are typically converted to angular velocity (omega) using
00093    *                                    Orient::getBInv().
00094    *
00095    *   @return                          An M-dim Vector dq which represents the joint parameters changes that
00096    *                                    will result in the specific dx changes in the end-effector (i.e. a
00097    *                                    solution dq to dx = J(q)dq )
00098    *
00099    *   @exception                       Specific to concrete subclasses.
00100    * \todo why is x necessary?
00101    */
00102   virtual Vector solve(const Vector& dx, const Vector& x, const Vector& q,
00103                        const base::Matrix& J,
00104                        OptimizationMethod      optMethod      = DefaultMethod,
00105                        OptimizationCriterion   optCriterion   = DefaultCriterion,
00106                        OptimizationConstraints optConstraints = OptimizationConstraints(DefaultConstraints),
00107                        base::Orient::Representation  orientationRepresentation = base::Orient::EulerRPY) = 0;
00108 
00109   /// query if a particular constraint type is supported by this solver for a specific method & criterion
00110   virtual bool isConstraintTypeSupported(OptimizationConstraint  optConstraint,
00111                                          OptimizationMethod      optMethod      = DefaultMethod,
00112                                          OptimizationCriterion   optCriterion   = DefaultCriterion)
00113                  { return false; }                 
00114                        
00115                        
00116   // Set constraint specific data for solver (these are typically called before solve() as appropriate)
00117   //  Not all solvers support all constraint types, in which case the data will just be ignored
00118                        
00119   /// Data for proximity sensors (used to generate obstacle collision avoidance constraints)
00120   struct LinkProximityData {
00121     LinkProximityData() : distance(consts::maxInt+1) {}
00122     
00123     Real    distance;   ///< distance to detected obstacle (or > maxInt if none or no sensor corresponding to this parameter)
00124     Vector  direction;  ///< direction to detected obstacle
00125     Real    intercept;  ///< sensor distance from link origin
00126   };
00127 
00128   /// set proximity sensor data (array indices correspond to parameter elements of q)
00129   ///  d - is 'danger distance' within which a constraint becomes active
00130   virtual void setProximitySensorData(const array<LinkProximityData>& proximityData, Real d) {}
00131   
00132   
00133   
00134   
00135   
00136   /// Set implementation specific parameters.  Unknown names will throw a std::invald_argument exception
00137   virtual void setParameter(const String& name, Real value) 
00138     { throw std::invalid_argument(Exception("unknown parameter name")); }
00139 
00140 };
00141 
00142 
00143 } // namespace kinematics
00144 } // namespace control
00145 } // namespace robot
00146 
00147 #endif

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