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

robot/control/kinematics/IKOR

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: IKOR 1080 2004-07-28 19:51:26Z jungd $
00019   $Revision: 1.14 $
00020   $Date: 2004-07-28 15:51:26 -0400 (Wed, 28 Jul 2004) $
00021   $Author: jungd $
00022 
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_CONTROL_KINEMATICS_IKOR_
00026 #define _ROBOT_CONTROL_KINEMATICS_IKOR_
00027 
00028 #include <robot/control/kinematics/kinematics>
00029 
00030 #include <sstream>
00031 
00032 #include <robot/KinematicChain>
00033 #include <robot/control/kinematics/InverseKinematicsSolver>
00034 #include <robot/control/kinematics/FullSpaceSolver>
00035 #include <robot/control/kinematics/BetaFormConstraints>
00036 
00037 
00038 
00039 namespace robot {
00040 namespace control {
00041 namespace kinematics {
00042 
00043 
00044 /// IKOR inverse kinematics solver.
00045 /** \todo test.
00046  */
00047 class IKOR : public InverseKinematicsSolver
00048 {
00049 public:
00050   IKOR(const robot::KinematicChain& chain, const Vector& jointWeights = Vector(),
00051        bool nonHolonomicPlatformActive=false, Real platformL=0);
00052 
00053   virtual String className() const { return String("IKOR"); }
00054 
00055 
00056   /// call to use a different solver, before using solve()
00057   void setFullSpaceSolver(ref<FullSpaceSolver> fsp) { solver=fsp; }
00058 
00059 
00060   class JointLimitBetaConstraint : public BetaFormConstraints::BetaFormConstraint
00061   {
00062   public:
00063     JointLimitBetaConstraint(Int j, Real dist, const Matrix& gs)
00064       : BetaFormConstraint(matrixRow(gs,j)/dist), j(j), dist(dist) { setName(className()); }
00065 
00066     JointLimitBetaConstraint(const JointLimitBetaConstraint& jlc)
00067       : BetaFormConstraint(jlc), j(j), dist(dist) {}
00068 
00069     virtual String className() const { return String("JointLimitBetaConstraint"); }
00070 
00071     Int j;     ///< joint/variable index
00072     Real dist; ///< desired change in q[j]
00073 
00074     virtual String toString() const
00075     { return String("j:")+base::intToString(j)+" d:"+base::realToString(dist); }
00076 
00077   };
00078 
00079 
00080   class PushAwayBetaConstraint : public BetaFormConstraints::BetaFormConstraint
00081   {
00082   public:
00083     // push point on 'link' with parameter index v at Xvx along the link's x-axis, a distance L in direction n
00084     PushAwayBetaConstraint(Int v, Real Xvx,
00085                            const Vector& n, Real L,
00086                            const Matrix& gs,
00087                            const robot::KinematicChain& chain, const Vector& q);
00088 
00089     PushAwayBetaConstraint(const PushAwayBetaConstraint& pac)
00090       : BetaFormConstraint(pac), v(v), Xvx(Xvx), n(n), L(L) {}
00091 
00092     virtual String className() const { return String("PushAwayBetaConstraint"); }
00093 
00094     Int  v;   ///< variable index
00095     Real Xvx; ///< x component of proximity sensor location (in link frame)
00096     Vector n; ///< direction to push
00097     Real L;   ///< distance to push in direction n
00098 
00099     virtual String toString() const
00100     { std::ostringstream str;
00101       str << "v:" << v << " Xvx:" << Xvx << " n:" << n << " L:" << L;
00102       return str.str();
00103     }
00104   };
00105 
00106 
00107   class RankLossBetaConstraint : public BetaFormConstraints::BetaFormConstraint
00108   {
00109   public:
00110     RankLossBetaConstraint(Int row, const Matrix& A, const Vector& b, const Matrix& gs);
00111     RankLossBetaConstraint(const RankLossBetaConstraint& rlc)
00112       : BetaFormConstraint(rlc), row(row) {}
00113 
00114     virtual String className() const { return String("RankLossBetaConstraint"); }
00115 
00116     Int row;
00117 
00118     virtual String toString() const { return String("row:")+base::intToString(row); }
00119   };
00120 
00121 
00122 
00123 
00124   ///  Solve inverse kinematics.
00125   virtual Vector solve(const Vector& dx, const Vector& x, const Vector& q,
00126                        const base::Matrix& J,
00127                        OptimizationMethod      optMethod      = Lagrangian,
00128                        OptimizationCriterion   optCriterion   = LeastNorm,
00129                        OptimizationConstraints optConstraints = OptimizationConstraints(JointLimits),
00130                        base::Orient::Representation  orientationRepresentation = base::Orient::EulerRPY);
00131 
00132   virtual bool isConstraintTypeSupported(OptimizationConstraint  optConstraint,
00133                                          OptimizationMethod      optMethod      = DefaultMethod,
00134                                          OptimizationCriterion   optCriterion   = DefaultCriterion);
00135 
00136 
00137   virtual void setProximitySensorData(const array<LinkProximityData>& proximityData, Real d);
00138 
00139 
00140 
00141   /// Set implementation specific parameters.  Unknown names will throw a std::invald_argument exception
00142   /** Valid parameters:   name               value            description
00143    *  none currently
00144    */
00145   virtual void setParameter(const String& name, Real value);
00146 
00147 protected:
00148   ref<FullSpaceSolver> solver;
00149   robot::KinematicChain chain;
00150   Vector weights; ///< relative weights for each joint for LeastNorm (vector of all 1s for equal weighting)
00151   bool nonHolonomicPlatformActive;
00152   Real L;  ///< platform parameter L - distance from origin P to center of drive axle M (see paper 2)
00153 
00154   //!!! may cache the objective later, if it speeds things up
00155   //ref<Optimizer::Objective> objective; // objective function for Optimizer
00156 
00157   array<LinkProximityData> proximitySensorData; /// proximity data indexed by chain dof variable
00158   Real d; ///< link obstacle proximity 'danger distance'
00159 
00160 
00161   void weightedLeastNorm(Matrix& B, Vector& dZr, Vector weights);
00162 
00163   void addDependentRowConstraints(const array<Int>& rows, const Matrix& gs, const Matrix& A, const Vector& b, ref<BetaFormConstraints> constraints);
00164   void addJointLimitConstraints(const Matrix& gs, const Vector& q, const Vector& dq, ref<BetaFormConstraints> constraints);
00165 
00166   void addNonholonomicConstraint(const Matrix& gs, const Vector& q, ref<BetaFormConstraints> constraints);
00167 
00168   void addObstacleAvoidanceConstraints(const Matrix& gs, const Vector& q, const Vector& dq, ref<BetaFormConstraints> constraints);
00169 };
00170 
00171 
00172 } // namespace kinematics
00173 } // namespace control
00174 } // namespace robot
00175 
00176 #endif

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