Robotsystem of the Robot Group Leipzig: oderobot.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Examples

- Search for |

- File List
- File Members

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