00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 * * 00022 * $Log: oderobot.h,v $ 00023 * Revision 1.11 2010/03/21 21:48:59 martius 00024 * camera sensor bugfixing (reference to osghandle) 00025 * twowheeled robot added (nimm2 with camera) 00026 * sense function added to robots (before control): sensors (type Sensor) are checked here 00027 * position and optical flow camera sensors added 00028 * 00029 * Revision 1.10 2008/05/14 14:36:28 martius 00030 * *** empty log message *** 00031 * 00032 * Revision 1.9 2008/05/07 16:45:52 martius 00033 * code cosmetics and documentation 00034 * 00035 * Revision 1.8 2008/05/06 17:14:17 martius 00036 * buildsystem further tuned, 00037 * help in Makefile 00038 * osg/data directory is also installed and registered at osg_robots 00039 * 00040 * Revision 1.7 2007/12/06 10:02:49 der 00041 * abstractground: returns now cornerpoints 00042 * abstractobstacle: is now trackable 00043 * hudstatistics: supports now AbstractmMeasure 00044 * 00045 * Revision 1.6 2007/11/07 13:21:16 martius 00046 * doInternal stuff changed signature 00047 * 00048 * Revision 1.5 2007/04/05 15:11:42 martius 00049 * angular speed tracking 00050 * 00051 * Revision 1.4 2006/08/08 17:04:46 martius 00052 * added new sensor model 00053 * 00054 * Revision 1.3 2006/07/20 17:19:44 martius 00055 * removed using namespace std from matrix.h 00056 * 00057 * Revision 1.2 2006/07/14 12:23:41 martius 00058 * selforg becomes HEAD 00059 * 00060 * Revision 1.1.2.17 2006/06/25 16:57:14 martius 00061 * abstractrobot is configureable 00062 * name and revision 00063 * 00064 * Revision 1.1.2.16 2006/06/12 12:59:07 robot8 00065 * -some corrections to component system (for example now connections are only pushed as pointers to the connection vector) 00066 * -created the evolution simulation for evolutionary evolution algorithms with atom like structures 00067 * 00068 * Revision 1.1.2.15 2006/03/30 12:34:56 martius 00069 * documentation updated 00070 * 00071 * Revision 1.1.2.14 2006/03/30 09:59:36 fhesse 00072 * getOsgHandle() removed 00073 * friend class OdeAgent added 00074 * 00075 * Revision 1.1.2.13 2006/03/30 09:37:05 fhesse 00076 * getOsgHandle added 00077 * 00078 * Revision 1.1.2.12 2006/03/29 15:08:42 martius 00079 * getMainPrimitive is public now 00080 * 00081 * Revision 1.1.2.11 2005/12/30 22:54:16 martius 00082 * collisioncallback must be implemented 00083 * 00084 * Revision 1.1.2.10 2005/12/14 15:37:09 martius 00085 * robots are working with osg 00086 * 00087 * Revision 1.1.2.9 2005/12/13 18:11:40 martius 00088 * still trying to port robots 00089 * 00090 * Revision 1.1.2.8 2005/12/13 12:31:46 martius 00091 * list version of isGeomInPrimitiveList 00092 * 00093 * Revision 1.1.2.7 2005/12/11 23:35:08 martius 00094 * *** empty log message *** 00095 * 00096 * Revision 1.1.2.6 2005/12/06 10:13:25 martius 00097 * openscenegraph integration started 00098 * 00099 * Revision 1.1.2.5 2005/11/24 16:20:54 fhesse 00100 * odeRto3x3RotationMatrix corrected 00101 * 00102 * Revision 1.1.2.4 2005/11/16 11:26:52 martius 00103 * moved to selforg 00104 * 00105 * Revision 1.1.2.3 2005/11/15 12:29:27 martius 00106 * new selforg structure and OdeAgent, OdeRobot ... 00107 * 00108 * Revision 1.1.2.2 2005/11/14 17:37:18 martius 00109 * moved to selforg 00110 * 00111 * Revision 1.1.2.1 2005/11/14 14:43:52 martius 00112 * moved from abstractrobot to oderobot 00113 * 00114 * Revision 1.11 2005/10/06 17:14:24 martius 00115 * switched to stl lists 00116 * 00117 * Revision 1.10 2005/09/22 12:24:36 martius 00118 * removed global variables 00119 * OdeHandle and GlobalData are used instead 00120 * sensor prepared 00121 * 00122 * Revision 1.9 2005/09/22 07:30:53 martius 00123 * moved color and position into extra modules 00124 * 00125 * Revision 1.8 2005/09/12 00:10:44 martius 00126 * position operators are const 00127 * 00128 * Revision 1.7 2005/08/30 16:53:53 martius 00129 * Position struct has toArray and operators 00130 * 00131 * Revision 1.6 2005/08/29 06:40:35 martius 00132 * added virtual destructor 00133 * 00134 * Revision 1.5 2005/08/22 20:32:45 martius 00135 * robot has a name 00136 * 00137 * Revision 1.4 2005/07/27 13:22:16 martius 00138 * position and color have constructors 00139 * ODEHandle 00140 * 00141 * Revision 1.3 2005/07/18 14:47:41 martius 00142 * world, space, contactgroup are not pointers anymore. 00143 * 00144 * Revision 1.2 2005/07/07 09:27:11 martius 00145 * isGeomInObjectList added 00146 * 00147 * Revision 1.1 2005/06/15 14:20:04 martius 00148 * moved into robots 00149 * * 00150 ***************************************************************************/ 00151 #ifndef __ODEROBOT_H 00152 #define __ODEROBOT_H 00153 00154 #include <vector> 00155 00156 #include <selforg/abstractrobot.h> 00157 #include "odehandle.h" 00158 #include "osghandle.h" 00159 #include "globaldata.h" 00160 #include "color.h" 00161 #include "pos.h" 00162 #include "osgforwarddecl.h" 00163 00164 namespace lpzrobots { 00165 00166 class Primitive; 00167 00168 /** 00169 * Abstract class for ODE robots 00170 * 00171 */ 00172 class OdeRobot : public AbstractRobot { 00173 public: 00174 00175 friend class OdeAgent; 00176 // friend class AtomOdeAgent; 00177 00178 /** 00179 * Constructor 00180 */ 00181 OdeRobot(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00182 const std::string& name, const std::string& revision); 00183 00184 virtual ~OdeRobot(); 00185 00186 00187 /// update the OSG notes here 00188 virtual void update() = 0; 00189 00190 /** sets the vehicle to position pos 00191 @param pos desired position of the robot 00192 */ 00193 virtual void place(const Pos& pos); 00194 00195 /** sets the pose of the vehicle 00196 @param pose desired 4x4 pose matrix 00197 */ 00198 virtual void place(const osg::Matrix& pose) = 0; 00199 00200 /** @deprecated 00201 * Do not use it anymore, collision control is done automatically. 00202 * In case of a treatment return true 00203 * (collision will be ignored by other objects and the default routine) 00204 * else false (collision is passed to other objects and (if not treated) to the default routine). 00205 */ 00206 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2){ return false; }; 00207 00208 /** this function is called each controlstep before control. 00209 This is the place the perform active sensing (e.g. Image processing) 00210 @param globalData structure that contains global data from the simulation environment 00211 */ 00212 virtual void sense(GlobalData& globalData) {}; 00213 00214 /** this function is called in each simulation timestep (always after control). It 00215 should perform robot-internal checks and actions 00216 like resetting certain sensors or implement velocity dependend friction and the like. 00217 The attached Motors should act here. 00218 @param globalData structure that contains global data from the simulation environment 00219 */ 00220 virtual void doInternalStuff(GlobalData& globalData) {}; 00221 00222 /** sets color of the robot 00223 @param col Color struct with desired Color 00224 */ 00225 virtual void setColor(const Color& col); 00226 00227 00228 /*********** BEGIN TRACKABLE INTERFACE ****************/ 00229 00230 /** returns position of the object 00231 @return vector of position (x,y,z) 00232 */ 00233 virtual Position getPosition() const; 00234 00235 /** returns linear speed vector of the object 00236 @return vector (vx,vy,vz) 00237 */ 00238 virtual Position getSpeed() const; 00239 00240 /** returns angular velocity vector of the object 00241 @return vector (wx,wy,wz) 00242 */ 00243 virtual Position getAngularSpeed() const; 00244 00245 /** returns the orientation of the object 00246 @return 3x3 rotation matrix 00247 */ 00248 virtual matrix::Matrix getOrientation() const; 00249 /*********** END TRACKABLE INTERFACE ****************/ 00250 00251 /// return the primitive of the robot that is used for tracking and camera following 00252 virtual Primitive* getMainPrimitive() const = 0; 00253 00254 protected: 00255 00256 static bool isGeomInPrimitiveList(Primitive** ps, int len, dGeomID geom); 00257 static bool isGeomInPrimitiveList(std::list<Primitive*> ps, dGeomID geom); 00258 00259 00260 protected: 00261 OdeHandle odeHandle; 00262 OsgHandle osgHandle; 00263 dSpaceID parentspace; 00264 }; 00265 00266 } 00267 00268 #endif 00269