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

robot/ManipulatorDescription

Go to the documentation of this file.
00001 /* **-*-c++-*-**************************************************************
00002   Copyright (C)2003 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: ManipulatorDescription 1038 2004-02-11 20:50:44Z jungd $
00019   $Revision: 1.7 $
00020   $Date: 2004-02-11 15:50:44 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_MANIPULATORDESCRIPTION_
00026 #define _ROBOT_MANIPULATORDESCRIPTION_
00027 
00028 #include <robot/robot>
00029 
00030 #include <base/Named>
00031 #include <base/Externalizable>
00032 #include <base/ReferencedObject>
00033 #include <base/DOM>
00034 #include <robot/KinematicChain>
00035 
00036 
00037 namespace robot {
00038 
00039 /**
00040  * An abstract description of a manipulator
00041  */
00042 class ManipulatorDescription : public base::Named, public base::Externalizable, public base::ReferencedObject
00043 {
00044 public:
00045   enum Type { Serial, Parallel };
00046 
00047   ManipulatorDescription() : mtype(Serial) {}
00048   ManipulatorDescription(String name, Matrix4 baseTransform, KinematicChain kinematicChain)
00049     : Named(name), mtype(Serial), baseTransform(baseTransform), kinematicChain(kinematicChain) {}
00050   ManipulatorDescription(const ManipulatorDescription& md) 
00051     : Named(md), mtype(md.mtype), baseTransform(md.baseTransform), kinematicChain(md.kinematicChain) {}
00052 
00053   ManipulatorDescription& operator=(const ManipulatorDescription& md)
00054     {
00055       setName(md.getName());
00056       mtype = md.mtype;
00057       baseTransform = md.baseTransform;
00058       kinematicChain = md.kinematicChain;
00059       return *this;
00060     }
00061 
00062   virtual String className() const { return String("ManipulatorDescription"); }
00063 
00064   void set(String name, Matrix4 baseTransform, KinematicChain kinematicChain)
00065     {
00066       setType(Serial);
00067       setName(name);
00068       setBaseTransform(baseTransform);
00069       setKinematicChain(kinematicChain);
00070     }
00071   
00072   
00073   virtual Type type() const { return mtype; }
00074 
00075   /**
00076    * get a kinematic chain that describes this manipulator.
00077    *  For serial manipulators this is a unique chain of joints.  For Parallel
00078    *  manipulators the chain obtained depends on the parameter.
00079    * The chain doesn't include the base link.
00080    *  (NB: when/if parallel manipulator support is added, this argument may change
00081    *   or be overloaded, but there will always be a default that will provide
00082    *   the unique chain in the case of a serial manipulator)
00083    */
00084   virtual const KinematicChain& getKinematicChain(Int p=0) const
00085     { return kinematicChain; }
00086 
00087   /// the transformation from the mount origin to the base origin (the first joint)
00088   virtual Matrix4 getBaseTransform() const { return baseTransform; }
00089 
00090 
00091   bool operator==(const ManipulatorDescription& md)
00092     {
00093       if (&md == this) return true;
00094       return (getName()==md.getName()) && (mtype==md.mtype)
00095         && (baseTransform==md.baseTransform) && (kinematicChain==md.kinematicChain);
00096     }
00097 
00098   bool operator!=(const ManipulatorDescription& md) { return !(*this == md); }
00099 
00100   
00101 
00102   // Externalizable
00103   virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const
00104     { return ( (format=="xml") && (version==1.0) ); }
00105   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00106   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0) const
00107     { Externalizable::externalize(e,format,version); }
00108 
00109 protected:
00110   ManipulatorDescription(String name) : Named(name) {}
00111   
00112   virtual void setType(Type type) { mtype=type; }
00113   virtual void setBaseTransform(const Matrix4& m) { baseTransform=m; }
00114   virtual void setKinematicChain(const KinematicChain& kc) { kinematicChain=kc; }
00115 
00116   // externalization helpers
00117   virtual void outputElementXML(base::Externalizer& e, base::dom::DOMElement* manipElem, String format, Real version) const;
00118   virtual void inputElementXML(base::Externalizer& e, base::dom::DOMElement* manipElem, String format, Real version);
00119 
00120   Type mtype;
00121   Matrix4 baseTransform; ///< depricated
00122   KinematicChain kinematicChain;
00123 
00124   friend class Robot;
00125 };
00126 
00127 
00128 } // robot
00129 
00130 #endif

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