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

robot/RobotDescription

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: RobotDescription 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_ROBOTDESCRIPTION_
00026 #define _ROBOT_ROBOTDESCRIPTION_
00027 
00028 #include <robot/robot>
00029 
00030 #include <base/array>
00031 #include <base/Named>
00032 #include <base/Externalizable>
00033 #include <base/ReferencedObject>
00034 
00035 #include <robot/PlatformDescription>
00036 #include <robot/ManipulatorDescription>
00037 #include <robot/KinematicChain>
00038 
00039 
00040 namespace robot {
00041 
00042 /**
00043  * An abstract description of a Robot
00044  */
00045 class RobotDescription : public base::Named, public base::Externalizable, public base::ReferencedObject
00046 {
00047 public:
00048   RobotDescription() {}
00049   RobotDescription(String name, ref<const PlatformDescription> platformDescription, 
00050                    array<ref<const ManipulatorDescription> > manipulatorDescriptions, 
00051                    array<Vector3> manipulatorOffsets)
00052     : Named(name), platformDescr(platformDescription), 
00053       manipulatorDescrs(manipulatorDescriptions), manipOffsets(manipulatorOffsets) 
00054     {}
00055 
00056   RobotDescription(const RobotDescription& r) 
00057     : Named(r), platformDescr(r.platformDescr),
00058       manipulatorDescrs(r.manipulatorDescrs),
00059       manipOffsets(r.manipOffsets)
00060     {}
00061 
00062   virtual String className() const { return String("RobotDescription"); }
00063   
00064   
00065   void set(String name, ref<const PlatformDescription> platformDescription, 
00066            array<ref<const ManipulatorDescription> > manipulatorDescriptions, 
00067            array<Vector3> manipulatorOffsets)
00068     {
00069       setName(name);
00070       setPlatformDescription(platformDescription);
00071       setManipulatorDescriptions(manipulatorDescriptions);
00072       setManipulatorOffsets(manipulatorOffsets);
00073     }
00074   
00075   
00076   // factory
00077   virtual ref<PlatformDescription>    newPlatformDescription() const { return ref<PlatformDescription>(NewObj PlatformDescription()); }
00078   virtual ref<ManipulatorDescription> newManipulatorDescription() const { return ref<ManipulatorDescription>(NewObj ManipulatorDescription()); }
00079 
00080   
00081   RobotDescription& operator=(const RobotDescription& r)
00082     {
00083       setName(r.getName());
00084       platformDescr = r.platformDescr;
00085       manipulatorDescrs = r.manipulatorDescrs;
00086       manipOffsets = r.manipOffsets;
00087       return *this;
00088     }
00089 
00090   /// get description of this robot's platform
00091   virtual ref<const PlatformDescription>       platform() const     { return platformDescr; }
00092 
00093   /// get descriptions of this robot's manipulators (if any)
00094   virtual const array<ref<const ManipulatorDescription> >& manipulators() const { return manipulatorDescrs; }
00095 
00096   /// get the offset of each manipulator from the platform origin
00097   virtual const array<Vector3>&                manipulatorOffsets() const { return manipOffsets; }
00098 
00099   
00100   /**
00101    * get an equivelent kinematic chain for the robot (from world frame to indicated manipulator end-effector).
00102    * The platform dof can either be 0, 3 or 6:
00103    * - 0-dof: the first link in the chain is a FixedTransform set to platformTransform (transform from world frame to platform origin)
00104    * - 3-dof: platform position in the 2D (x,y) plane with orientation theta about the Z-axis.
00105    *          The static components of the platform position are taken from platformTransform.
00106    * - 6-dof: platform position in 3D (x,y,z) and EulerRPY (roll, pitch, yaw) orientation.
00107    * If the platform is not mobile, the platformDOF is considered 0
00108    * If the robot has no manipulator, the chain ends at the platform origin.
00109    */
00110   virtual KinematicChain getKinematicChain(Int platformDOF=0, const base::Matrix4& platformTransform = base::Matrix4(),
00111                                            Int manipIndex=0, Int manipChainIndex=0) const;
00112 
00113   
00114   // Externalizable
00115   virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const
00116     { return ( (format=="xml") && (version==1.0) ); }
00117   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0);
00118   virtual void externalize(base::Externalizer& e, String format = "", Real version = 1.0) const
00119     { Externalizable::externalize(e,format,version); }
00120 
00121 
00122 protected:
00123   RobotDescription(const String& name) : Named(name) {}
00124   
00125   void setPlatformDescription(ref<const PlatformDescription> pd) { platformDescr = pd; }
00126   void setManipulatorDescriptions(const array<ref<const ManipulatorDescription> >& mds) { manipulatorDescrs = mds; }
00127   void setManipulatorOffsets(const array<Vector3> offsets) { manipOffsets=offsets; }
00128 
00129 private:
00130   ref<const PlatformDescription>            platformDescr;     ///< description of mobile platform
00131   array<ref<const ManipulatorDescription> > manipulatorDescrs; ///< list of manipulators attached to platform
00132   array<Vector3>                            manipOffsets;      ///< Vectors representing the offset of each manipulator relative to the platform coord. frame 
00133 
00134   friend class Robot;
00135 };
00136 
00137 
00138 } // robot
00139 
00140 #endif

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