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

robot/sim/BasicEnvironment

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: BasicEnvironment 1033 2004-02-11 20:47:52Z jungd $
00019   $Revision: 1.6 $
00020   $Date: 2004-02-11 15:47:52 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_SIM_BASICENVIRONMENT_
00026 #define _ROBOT_SIM_BASICENVIRONMENT_
00027 
00028 #include <robot/sim/sim>
00029 
00030 #include <robot/sim/Environment>
00031 
00032 
00033 namespace robot {
00034 namespace sim {
00035 
00036 /**
00037  * An abstract basic 'no-frills' environment for Robots
00038  *  Assumes a flat ground and can contain simple obstacles
00039  */
00040 class BasicEnvironment : public Environment
00041 {
00042 public:
00043   BasicEnvironment(ref<base::VFileSystem> fs, ref<base::Cache> cache, const String& name = "") 
00044     : Environment(fs, cache, name) {}
00045     
00046   BasicEnvironment(const BasicEnvironment& e) 
00047     : Environment(e) {}
00048     
00049   virtual String className() const { return String("BasicEnvironment"); }
00050 
00051   // factory
00052   virtual ref<ToolDescription> newToolDescription() const = 0;
00053 
00054   // methods to add/remove tools
00055 
00056   class Tool : public base::Named, public base::ReferencedObject
00057   {
00058   public:
00059     Tool(String name, ref<const robot::ToolDescription> toolDescription,
00060          const base::Point3& position, 
00061          const base::Orient& orientation)
00062       : Named(name), toolDescription(toolDescription),
00063         position(position), orientation(orientation) {}
00064     
00065     virtual String className() const { return String("Tool"); }
00066 
00067     virtual ref<const robot::ToolDescription> getToolDescription() const { return toolDescription; }
00068     virtual const base::Point3& getPosition() const { return position; }
00069     virtual       base::Point3& getPosition() { return position; }
00070     virtual const base::Orient& getOrientation() const { return orientation; }
00071     virtual       base::Orient& getOrientation() { return orientation; }
00072     
00073   protected:
00074     ref<const robot::ToolDescription> toolDescription;
00075     base::Point3 position;
00076     base::Orient orientation;
00077   };
00078 
00079   
00080   virtual ref<Tool> addTool(ref<const robot::ToolDescription> toolDescription,
00081                             const base::Point3& position, 
00082                             const base::Orient& orientation) = 0;
00083 
00084   virtual void removeTool(ref<Tool> tool) = 0;
00085 
00086   virtual Int numTools() const = 0;
00087   virtual ref<Tool> getTool(Int i) = 0;
00088   virtual ref<const Tool> getTool(Int i) const = 0;
00089 
00090 
00091   /// place the specified tool within grasping range of the end-effector of the specified robot manipulator
00092   virtual void placeToolInProximity(ref<Tool> tool, ref<Robot> robot, Int manipulatorIndex=0) = 0;
00093 
00094 
00095   // methods to add/remove simple objects to/from the environment
00096   class Obstacle : public base::ReferencedObject, public base::Named
00097   {
00098   public:
00099     enum ObstacleType { BoxObstacle, SphereObstacle };
00100 
00101     Obstacle(base::Dimension3 dims,
00102              const base::Point3& position, 
00103              const base::Orient& orientation)
00104       : type(BoxObstacle), dims(dims), 
00105          position(position), orientation(orientation) {}
00106     
00107     Obstacle(Real radius,
00108              const base::Point3& position, 
00109              const base::Orient& orientation)
00110       : type(SphereObstacle), radius(radius),
00111         position(position), orientation(orientation) {}
00112 
00113     virtual String className() const { return String("Obstacle"); }
00114 
00115     void setName(const String& name) { Named::setName(name); }
00116     
00117     ObstacleType type;
00118     base::Dimension3 dims; // for Box
00119     Real radius;           // for Sphere
00120     base::Point3 position;
00121     base::Orient orientation;
00122   };
00123 
00124   
00125   virtual ref<Obstacle> addBoxObstacle(base::Dimension3 dim, 
00126                                        const base::Point3& position, 
00127                                        const base::Orient& orientation,
00128                                        const String& name="") = 0;
00129   
00130   virtual ref<Obstacle> addSphereObstacle(Real radius,
00131                                           const base::Point3& position, 
00132                                           const base::Orient& orientation,
00133                                           const String& name="") = 0;
00134 
00135   virtual void removeObstacle(ref<Obstacle> obstacle) = 0;
00136   
00137   virtual Int numObstacles() const = 0;
00138   virtual ref<Obstacle> getObstacle(Int i) = 0;
00139   virtual ref<const Obstacle> getObstacle(Int i) const = 0;
00140 
00141 };
00142 
00143 
00144 }
00145 } // robot::sim
00146 
00147 #endif

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