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

robot/sim/TestBasicEnvironment

Go to the documentation of this file.
00001 /****************************************************************************
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: TestBasicEnvironment 1033 2004-02-11 20:47:52Z jungd $
00019   $Revision: 1.4 $
00020   $Date: 2004-02-11 15:47:52 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _ROBOT_SIM_TESTBASICENVIRONMENT_
00026 #define _ROBOT_SIM_TESTBASICENVIRONMENT_
00027 
00028 #include <robot/sim/sim>
00029 
00030 #include <robot/sim/BasicEnvironment>
00031 
00032 #include <robot/TestRobot>
00033 
00034 #include <list>
00035 
00036 
00037 namespace robot {
00038 namespace sim {
00039 
00040 /**
00041  * A basic environment for robots and simple obstacles without any simulation.
00042  *  Useful for testing.  Added Robot instances are typically of type TestRobot.
00043  */
00044 class TestBasicEnvironment : public robot::sim::BasicEnvironment
00045 {
00046 public:
00047   TestBasicEnvironment(ref<base::VFileSystem> fs, ref<base::Cache> cache, const String& name = "");
00048 
00049   virtual String className() const { return String("TestBasicEnvironment"); }
00050 
00051 
00052   // methods to add/remove robots
00053 /*
00054   virtual ref<Robot> addRobot(ref<base::VFile> robotSpecification,
00055                               const base::Point3& position, 
00056                               const base::Orient& orientation,
00057                               bool anchored = false);
00058 */
00059   virtual ref<RobotDescription> newRobotDescription() const 
00060     { return ref<RobotDescription>(NewObj RobotDescription()); }
00061 
00062   virtual ref<Robot> addRobot(ref<const robot::RobotDescription> robotDescription,
00063                               const base::Point3& position, 
00064                               const base::Orient& orientation,
00065                               bool anchored = false);
00066   
00067   virtual void removeRobot(ref<robot::Robot> robot);
00068 
00069   virtual Int numRobots() const { return robots.size(); }
00070   virtual ref<Robot> getRobot(Int i) { return base::elementAt(robots,i); }
00071 
00072 
00073   // methods to add/remove tools
00074   virtual ref<Tool> addTool(ref<const robot::ToolDescription> toolDescription,
00075                             const base::Point3& position, 
00076                             const base::Orient& orientation);
00077 
00078   virtual void removeTool(ref<Tool> tool);
00079 
00080   virtual Int numTools() const { return tools.size(); };
00081   virtual ref<Tool> getTool(Int i) { return base::elementAt(tools,i); }
00082   virtual ref<const Tool> getTool(Int i) const { return base::elementAt(tools,i); }
00083 
00084   /// place the specified tool within grasping range of the end-effector of the specified robot manipulator
00085   virtual void placeToolInProximity(ref<Tool> tool, ref<Robot> robot, Int manipulatorIndex=0);
00086 
00087 
00088   // methods to add/remove simple objects to the environment
00089   
00090   virtual ref<Obstacle> addBoxObstacle(base::Dimension3 dim, 
00091                                        const base::Point3& position, 
00092                                        const base::Orient& orientation,
00093                                        const String& name="");
00094   
00095   virtual ref<Obstacle> addSphereObstacle(Real radius,
00096                                           const base::Point3& position, 
00097                                           const base::Orient& orientation,
00098                                           const String& name="");
00099 
00100   virtual void removeObstacle(ref<Obstacle> obstacle);
00101   
00102   virtual Int numObstacles() const { return obstacles.size(); }
00103   virtual ref<Obstacle> getObstacle(Int i) { return base::elementAt(obstacles,i); }
00104   virtual ref<const Obstacle> getObstacle(Int i) const { return base::elementAt(obstacles,i); }
00105 
00106 
00107   // Simulatable
00108   virtual void preSimulate();
00109   virtual void simulateForSimTime(const base::Time& dt);
00110 
00111  // Externalizable
00112   virtual bool formatSupported(const String format, Real version = 1.0, ExternalizationType type = IO) const; ///< query if specific format is supported (for input, output or both)
00113   virtual void externalize(base::Externalizer& e, const String format = "", Real version = 1.0); ///< read or write object state to Externalizer
00114 
00115 protected:
00116   typedef reflist<robot::TestRobot> RobotList;
00117   typedef reflist<Tool> ToolList;
00118   typedef reflist<Obstacle> ObstacleList;
00119 
00120   RobotList    robots;    ///< list of robots in the environment
00121   ToolList     tools;     ///< list of tools in the environment
00122   ObstacleList obstacles; ///< list of obstacles in the environment
00123 
00124 };
00125 
00126 
00127 }
00128 } // robot::sim
00129 
00130 #endif

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