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

robot/JFKengine

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: JFKengine 1039 2004-02-11 20:50:52Z jungd $
00019   $Revision: 1.5 $
00020   $Date: 2004-02-11 15:50:52 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_JFKENGINE_
00026 #define _ROBOT_JFKENGINE_
00027 
00028 #include <robot/robot>
00029 
00030 #include <base/Expression>
00031 #include <robot/KinematicEvaluator>
00032 #include <robot/KinematicChain>
00033 
00034 
00035 namespace robot {
00036 
00037 
00038 /**
00039  * A KinematicEvaluator that uses symbolic differentiation to compute 
00040  * Jacobian and forward kinematics matrix expressions.
00041  */
00042 class JFKengine : public KinematicEvaluator
00043 {
00044 public:
00045   JFKengine();   
00046 
00047   virtual String className() const { return String("JFKengine"); } ///< identifies this class type as a JFKengine
00048   virtual Object& clone() const { return *NewObj JFKengine(*this); } ///< makes a copy of this JFKengine
00049 
00050   
00051   // KinematicEvaluator interface
00052   virtual Matrix getForwardKinematics(const KinematicChain& chain, const Vector& q) const;
00053   virtual Matrix getJacobian(const KinematicChain& chain, const Vector& q, bool includeOrientation = true) const;
00054   virtual array<base::Vector> getJointOrigins(const KinematicChain& chain, const base::Vector& q ) const;
00055   virtual array<base::Vector> getLinkOrigins(const KinematicChain& chain, const base::Vector& q ) const;
00056 
00057   
00058   ///  forms symbolic forward kinematics expression matrix
00059   /**
00060    *   @param      chain  a description of a chain of links from which expression matrices are to be formed.
00061    *   @return     A 4 x 4 ExpressionMatrix containing transformation matrix T for the given SerialManipulator;
00062    *               T represents the position and orientation of the nth link with reference
00063    *               to the base coordinate frame of the manipulator.
00064    *   @exception  std::out_of_range exception, if no joints are specified or n is greater than the number
00065    *               of joints in manipulator 
00066    */
00067   base::ExpressionMatrix getForwardKinematics(const KinematicChain& chain) const;
00068 
00069 
00070   /// forms a symbolic Jacobian expression matrix
00071   /** 
00072    *   @param      chain  a description of a chain of joints each specified via D-H parameters for which
00073    *                      the Jacobian is to be formed.
00074    *   @param      includeOrientation if true, J will be a 6 x n ExpressionMatrix with orientation components
00075    *               otherwise it will be a 3 x n ExpressionMatrix including only position components
00076    *   @return     A [6|3] x n ExpressionMatrix containing the Jacobian for the given SerialManipulator.
00077    *               n is the number of joints in the given chain.
00078    *   @exception  std::out_of_range exception, if no joints are specified
00079    * \todo check & document if this is the Geometric Jacobian or Analytical Jacobian
00080    *       (in Jg the orientation components represent ang. vel (omega), in Ja the orientation components
00081    *        represent the time derivative of Euler angles - theta_dot) - I think this implementation is Jg.
00082    *        (omega is better for representing ang. velocity than theta_dot.
00083    *         On the other hand, the intergral of theta_dot, Euler angles themselves (theta) can easily represent
00084    *         orientation, but the intergral of omega has no physical meaning (called quasi-coordinates))
00085    */
00086   base::ExpressionMatrix getJacobian(const KinematicChain& chain, bool includeOrientation = true) const;
00087 
00088 
00089   
00090 protected:
00091   JFKengine(const JFKengine& jfke) {} ///< copy constructor
00092  
00093   mutable bool forwardKinematicsCached;     ///< ==true signals that A and T have already been calculated and are cached
00094   mutable array<base::ExpressionMatrix> A;  ///< array of matrices that give position and orientation with respect to previous frame
00095   mutable array<base::ExpressionMatrix> T;  ///< array of matrices that give position and orientation with respect to base
00096   mutable KinematicChain chain_AT;          ///< cached chain used to form A and T
00097   mutable bool JCached;                     ///< ==true signals that J has already been calculated and is cached
00098   mutable KinematicChain chain_J;           ///< cached chain used to form J
00099   mutable base::ExpressionMatrix J;         ///< contains the cached 6 x n Jacobian
00100 };
00101 
00102 } // namespace robot
00103 
00104 #endif

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