Robotsystem from Robot Group Leipzig: oderobot.h Source File

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

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