octaplayground.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 * frankguettler@gmx.de * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 * * 00023 * $Log: octaplayground.h,v $ 00024 * Revision 1.7 2006/09/20 12:55:30 martius 00025 * correct size of ground 00026 * 00027 * Revision 1.6 2006/08/11 15:41:04 martius 00028 * playgrounds handle non-quadratic ground planes 00029 * 00030 * Revision 1.5 2006/07/14 12:23:33 martius 00031 * selforg becomes HEAD 00032 * 00033 * Revision 1.4.4.11 2006/06/29 16:39:55 robot3 00034 * -you can now see bounding shapes if you type ./start -drawboundings 00035 * -includes cleared up 00036 * -abstractobstacle and abstractground have now .cpp-files 00037 * 00038 * Revision 1.4.4.10 2006/05/23 13:37:22 robot3 00039 * -fixed some creating bugs 00040 * -setColor,setTexture and createGround must be 00041 * called before setPosition now 00042 * 00043 * Revision 1.4.4.9 2006/05/19 08:42:36 robot3 00044 * -some code moved to abstractground.h 00045 * -it's now possible creating a playground without a groundplane 00046 * 00047 * Revision 1.4.4.8 2006/05/18 14:38:28 robot3 00048 * wall uses wall texture now 00049 * 00050 * Revision 1.4.4.7 2006/05/18 12:54:24 robot3 00051 * -fixed not being able to change the color after positioning 00052 * the obstacle 00053 * -cleared the files up 00054 * 00055 * Revision 1.4.4.6 2006/05/18 12:00:57 robot3 00056 * removed unused variables 00057 * 00058 * Revision 1.4.4.5 2006/05/18 09:40:03 robot3 00059 * using existing texture image in cvs for the groundplane now 00060 * 00061 * Revision 1.4.4.4 2006/05/18 07:42:36 robot3 00062 * Grounds have now a groundPlane for shadowing issues 00063 * osgprimitive.cpp contains a bug that repeating textures (wrapping) 00064 * don't work, needs to be fixed 00065 * 00066 * Revision 1.4.4.3 2006/05/11 08:59:15 robot3 00067 * -fixed a positioning bug (e.g. for passivesphere) 00068 * -some methods moved to abstractobstacle.h for avoiding inconsistencies 00069 * 00070 * Revision 1.4.4.2 2006/03/29 15:04:39 martius 00071 * have pose now 00072 * 00073 * Revision 1.4.4.1 2006/01/10 20:11:12 martius 00074 * moved to osg 00075 * 00076 * Revision 1.4 2005/11/09 13:29:21 fhesse 00077 * GPL added 00078 * * 00079 * * 00080 ***************************************************************************/ 00081 #ifndef __OCTAPLAYGROUND_H 00082 #define __OCTAPLAYGROUND_H 00083 00084 #include "abstractground.h" 00085 00086 namespace lpzrobots { 00087 00088 class OctaPlayground : public AbstractGround { 00089 00090 00091 protected: 00092 double radius, width, height; 00093 00094 int number_elements; 00095 double angle; 00096 double box_length; 00097 00098 public: 00099 00100 00101 OctaPlayground(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00102 const Pos& geometry = Pos(7,0.2,0.5), int numberCorners=8, bool createGround=true): 00103 AbstractGround::AbstractGround(odeHandle, osgHandle,createGround,2*geometry.x(),2*geometry.x()) { 00104 radius = geometry.x(); 00105 width = geometry.y(); 00106 height = geometry.z(); 00107 00108 number_elements=numberCorners; 00109 angle= 2*M_PI/number_elements; 00110 obst.resize(number_elements); 00111 00112 calcBoxLength(); 00113 }; 00114 00115 protected: 00116 00117 virtual void create(){ 00118 // radius for positioning is smaller than radius since we use secants. 00119 // r is the smallest distance of the secant to the center of the circle. 00120 double r = sqrt(pow((1+cos(angle))/2, 2) + pow( sin(angle)/2 ,2)) * radius; 00121 for (int i=0; i<number_elements; i++){ 00122 Box* box = new Box(width , box_length , height); 00123 box->init(odeHandle, 0, osgHandle, Primitive::Geom | Primitive::Draw); 00124 osg::Matrix R = osg::Matrix::rotate(- i*angle, 0,0,1) * 00125 osg::Matrix::translate( cos(M_PI - i*angle) * r, 00126 sin(M_PI - i*angle) * r, 00127 height/2+0.01f /*reduces graphic errors and ode collisions*/ 00128 )* pose; 00129 box->setPose(R); 00130 box->getOSGPrimitive()->setTexture(wallTextureFileName); 00131 obst.push_back(box); 00132 } 00133 obstacle_exists=true; 00134 }; 00135 00136 virtual void calcBoxLength(){ 00137 double r = radius+width/2; 00138 // box_length =1.4 * sqrt( 2 * pow(radius,2) * (1 - cos(angle)) ); 00139 box_length = sqrt(pow( 1 - cos(angle), 2) + pow(sin(angle),2)) * r; 00140 } 00141 00142 }; 00143 00144 } 00145 00146 #endif

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