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

Generated on Tue Jan 16 02:14:37 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8