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

robot/PlatformDescription

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: PlatformDescription 1039 2004-02-11 20:50:52Z jungd $
00019   $Revision: 1.6 $
00020   $Date: 2004-02-11 15:50:52 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_PLATFORMDESCRIPTION_
00026 #define _ROBOT_PLATFORMDESCRIPTION_
00027 
00028 #include <robot/robot>
00029 
00030 #include <base/Named>
00031 #include <base/Externalizable>
00032 #include <base/ReferencedObject>
00033 #include <base/Dimension3>
00034 #include <base/Expression>
00035 #include <robot/KinematicChain>
00036 
00037 
00038 namespace robot {
00039 
00040 /**
00041  * An abstract description of a Robot's platform 
00042  *  (typically the mobile base)
00043  */
00044 class PlatformDescription : public base::Named, public base::Externalizable, public base::ReferencedObject
00045 {
00046 public:
00047   PlatformDescription() 
00048     : Named("platform"), mobile(false), 
00049       holonomic(true), dims(base::Dimension3(1,1,0.1)) , offset(0,0,-0.05)
00050     {}
00051 
00052   PlatformDescription(String name, const base::Dimension3& dimensions, 
00053                       const base::Vector3& originOffset,
00054                       bool mobile, bool holonomic=true, Real L=1, Real W=2)
00055     : Named(name), mobile(mobile), holonomic(holonomic), 
00056       dims(dimensions),offset(originOffset), nhL(L), nhW(W) {}
00057 
00058   PlatformDescription(const PlatformDescription& p)
00059     : Named(p),
00060       mobile(p.mobile), holonomic(p.holonomic),
00061       dims(p.dims), offset(p.offset), nhL(p.nhL), nhW(p.nhW) {}
00062 
00063   PlatformDescription& operator=(const PlatformDescription& p)
00064     {
00065       setName(p.getName());
00066       mobile = p.mobile;
00067       holonomic = p.holonomic;
00068       dims = p.dims; 
00069       offset = p.offset;
00070       nhL = p.nhL;
00071       nhW = p.nhW;
00072       return *this;
00073     }
00074 
00075   void set(String name, const base::Dimension3& dimensions, 
00076            const base::Vector3& originOffset,
00077            bool mobile, bool holonomic=true, Real L=1, Real W=2)
00078     {
00079       setName(name);
00080       setMobile(mobile);
00081       setHolonomic(holonomic);
00082       setDimensions(dimensions);
00083       setOriginOffset(originOffset);
00084       setL(L);
00085       setW(W);
00086     }
00087     
00088     
00089   virtual String className() const { return String("PlatformDescription"); }
00090 
00091   virtual bool   isMobile() const    ///< is the robot mobile, or fixed (e.g. to the floor)?
00092     { return mobile; }
00093   virtual bool   isHolonomic() const ///< if mobile, is the platform capable of holonomic movement
00094     { return holonomic; }
00095 
00096   virtual base::Dimension3 dimensions() const ///< physical platform bounding dimensions (Length, Width, Thickness)
00097     { return dims; }
00098 
00099   virtual base::Vector3 originOffset() const ///< offset of platfom/robot origin from platform shape's origin
00100     { return offset; }
00101 
00102   virtual Real L() const  ///< distance of nonholonomic platform drive axle back from platform origin
00103     { return nhL; }
00104     
00105   virtual Real W() const  ///< distance between nonholonomic platform steering axle and drive axle
00106     { return nhW; }
00107     
00108 
00109   /**
00110    * get an equivelent kinematic chain for this platform.
00111    * The platform dof can either be 0, 3 or 6:
00112    * - 0-dof: the chain consists of a single link; a FixedTransform set to platformTransform (transform from world frame to platform origin)
00113    * - 3-dof: platform position in the 2D (x,y) plane with orientation theta about the Z-axis.
00114    *          The static components of the platform position are taken from platformTransform.
00115    * - 6-dof: platform position in 3D (x,y,z) and EulerRPY (roll, pitch, yaw) orientation.
00116    * If the platform is not mobile, platformDOF is considered 0
00117    */
00118   virtual KinematicChain getKinematicChain(Int platformDOF=0, const base::Matrix4& platformTransform = base::Matrix4()) const;
00119 
00120   
00121   /** 
00122    * utility method to compute the steering angle needed to move the non-holonomic platform from state q to qp.
00123    * The dimension of q determines the platform DOF assumed (see getKinematicChain) - must be 0, 3 or 6.
00124    *  (since a 0-dof platform can't be controlled, 0 is returned)
00125    */
00126   virtual Real requiredSteeringAngle(const Vector& q, const Vector& qp) const;
00127   
00128   
00129   // Externalizable
00130   virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const
00131     { return ( (format=="xml") && (version==1.0) ); }
00132   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00133   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0) const
00134     { Externalizable::externalize(e,format,version); }
00135 
00136 protected:
00137   PlatformDescription(String name) : Named(name), mobile(false) {}
00138 
00139   void setMobile(bool mobile) { this->mobile = mobile; }
00140   void setHolonomic(bool holonomic) { this->holonomic = holonomic; }
00141   void setDimensions(base::Dimension3 dimensions) { dims = dimensions; }
00142   void setOriginOffset(base::Vector3 originOffset) { offset = originOffset; }
00143   void setL(Real L) { nhL = L; }
00144   void setW(Real W) { nhW = W; }
00145 
00146 private:
00147   bool   mobile;    
00148   bool   holonomic; 
00149   
00150   base::Dimension3 dims; 
00151   base::Vector3 offset; ///< offset of platfom/robot origin from platform shape's origin
00152   
00153   // for non-holonomic platform only
00154   Real nhL; ///< distance of nonholonomic platform drive axle back from platform origin
00155   Real nhW; ///< distance between nonholonomic platform steering axle and drive axle
00156   
00157   friend class Robot;
00158 };
00159 
00160 
00161 } // robot
00162 
00163 #endif

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