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

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

- Search for |

- File List
- File Members

# passivesphere.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: passivesphere.h,v $
    00023  *   Revision 1.4  2008/09/16 14:49:46  martius
    00024  *   use cmath instead of math.h
    00025  *
    00026  *   Revision 1.3  2007/03/16 11:01:37  martius
    00027  *   abstractobstacle gets mor functionallity
    00028  *   setSubstance
    00029  *
    00030  *   Revision 1.2  2006/07/14 12:23:33  martius
    00031  *   selforg becomes HEAD
    00032  *
    00033  *   Revision 1.1.2.11  2006/06/16 22:27:26  martius
    00034  *   getMainPrimtive
    00035  *
    00036  *   Revision 1.1.2.10  2006/05/28 22:14:56  martius
    00037  *   heightfield included
    00038  *
    00039  *   Revision 1.1.2.9  2006/05/18 12:54:24  robot3
    00040  *   -fixed not being able to change the color after positioning
    00041  *    the obstacle
    00042  *   -cleared the files up
    00043  *
    00044  *   Revision 1.1.2.8  2006/05/11 08:59:15  robot3
    00045  *   -fixed a positioning bug (e.g. for passivesphere)
    00046  *   -some methods moved to abstractobstacle.h for avoiding inconsistencies
    00047  *
    00048  *   Revision 1.1.2.7  2006/03/31 09:59:23  fhesse
    00049  *   in create: z+=radius; added to place sphere on ground
    00050  *
    00051  *   Revision 1.1.2.6  2006/03/30 12:34:51  martius
    00052  *   documentation updated
    00053  *
    00054  *   Revision 1.1.2.5  2006/03/29 15:04:39  martius
    00055  *   have pose now
    00056  *
    00057  *   Revision 1.1.2.4  2006/01/18 16:46:39  martius
    00058  *   mass adjustable
    00059  *
    00060  *   Revision 1.1.2.3  2005/12/15 17:02:16  martius
    00061  *   *** empty log message ***
    00062  *
    00063  *   Revision 1.1.2.2  2005/12/11 23:35:07  martius
    00064  *   *** empty log message ***
    00065  *
    00066  *   Revision 1.1.2.1  2005/12/09 16:53:17  martius
    00067  *   camera is working now
    00068  *
    00069  *   Revision 1.5  2005/10/25 19:26:57  fhesse
    00070  *   comments adjusted and in doxygen style
    00071  *
    00072  *   Revision 1.4  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.3  2005/07/31 22:30:56  martius
    00078  *   textures
    00079  *
    00080  *   Revision 1.2  2005/07/18 14:52:33  martius
    00081  *   world and space are not pointers anymore.
    00082  *
    00083  *   Revision 1.1  2005/07/08 10:00:33  fhesse
    00084  *   initial version
    00085  *                                                    *
    00086  *                                                                         *
    00087  ***************************************************************************/
    00088 #ifndef __PASSIVESPHERE_H
    00089 #define __PASSIVESPHERE_H
    00090
    00091 #include <stdio.h>
    00092 #include <cmath>
    00093
    00094 #include "primitive.h"
    00095 #include "osgprimitive.h"
    00096 #include "abstractobstacle.h"
    00097
    00098 namespace lpzrobots {
    00099
    00100 /**
    00101  *  (Passive) sphere as obstacle
    00102  */
    00103 class PassiveSphere : public AbstractObstacle{
    00104   double radius;
    00105   double mass;
    00106   int texture;
    00107
    00108   Sphere* sphere;
    00109
    00110  public:
    00111
    00112   /**
    00113    * Constructor
    00114    */
    00115   PassiveSphere(const OdeHandle& odeHandle, const OsgHandle& osgHandle, double radius = 0.3, double mass = 1.0):
    00116     AbstractObstacle::AbstractObstacle(odeHandle, osgHandle), radius(radius), mass(mass) {
    00117     sphere=0;
    00118     obstacle_exists=false;
    00119   };
    00120
    00121   virtual void setTexture(const std::string& filename){
    00122     if(sphere) sphere->getOSGPrimitive()->setTexture(filename);
    00123   }
    00124
    00125   virtual void setPose(const osg::Matrix& pose){
    00126     this->pose = osg::Matrix::translate(0,0,radius) * pose;
    00127     if (obstacle_exists){
    00128       destroy();
    00129     }
    00130     create();
    00131   };
    00132
    00133   virtual Primitive* getMainPrimitive() const { return sphere; }
    00134
    00135
    00136  protected:
    00137   virtual void create(){
    00138     sphere = new Sphere(radius);
    00139     sphere->init(odeHandle, mass, osgHandle);
    00140     osg::Vec3 pos=pose.getTrans();
    00141     sphere->setPosition(pos);
    00142     obst.push_back(sphere);
    00143
    00144     obstacle_exists=true;
    00145   };
    00146
    00147 };
    00148
    00149 }
    00150
    00151 #endif