oderobot.h

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

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7