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 * A robot with 4 wheels based on nimm4 with IR sensors * 00023 * * 00024 * $Log: fourwheeled.h,v $ 00025 * Revision 1.5 2010/03/26 14:18:07 martius 00026 * fourwheeled has a 2 wheeled mode 00027 * camera position/motion sensor meansure size change 00028 * 00029 * Revision 1.4 2009/05/11 17:03:07 martius 00030 * minor substance change 00031 * 00032 * Revision 1.3 2008/04/23 07:17:16 martius 00033 * makefiles cleaned 00034 * new also true realtime factor displayed, 00035 * warning if out of sync 00036 * drawinterval in full speed is 10 frames, independent of the speed 00037 * 00038 * Revision 1.2 2007/11/07 13:21:15 martius 00039 * doInternal stuff changed signature 00040 * 00041 * Revision 1.1 2007/08/24 11:49:35 martius 00042 * initial 00043 * 00044 * * 00045 ***************************************************************************/ 00046 #ifndef __FOUR_WHEELED__ 00047 #define __FOUR_WHEELED__ 00048 00049 #include "nimm4.h" 00050 #include "raysensorbank.h" 00051 00052 namespace lpzrobots { 00053 00054 class Primitive; 00055 class Hinge2Joint; 00056 00057 typedef struct { 00058 double size; 00059 double force; 00060 double speed; 00061 bool sphereWheels; 00062 bool useBumper; 00063 bool twoWheelMode; /// < if true then the robot emulates 2 wheels 00064 bool irFront; 00065 bool irBack; 00066 bool irSide; 00067 double irRangeFront; 00068 double irRangeBack; 00069 double irRangeSide; 00070 Substance wheelSubstance; 00071 } FourWheeledConf; 00072 00073 /** Robot is based on nimm4 with 00074 4 wheels and a capsule like body 00075 */ 00076 class FourWheeled : public Nimm4{ 00077 public: 00078 00079 /** 00080 * constructor of nimm4 robot 00081 * @param odeHandle data structure for accessing ODE 00082 * @param osgHandle ata structure for accessing OSG 00083 * @param conf configuration structure 00084 * @param name name of the robot 00085 */ 00086 FourWheeled(const OdeHandle& odeHandle, const OsgHandle& osgHandle, FourWheeledConf conf, const std::string& name); 00087 00088 static FourWheeledConf getDefaultConf(){ 00089 FourWheeledConf conf; 00090 conf.size = 1; 00091 conf.force = 3; 00092 conf.speed = 15; 00093 conf.sphereWheels = true; 00094 conf.twoWheelMode = false; 00095 conf.useBumper = true; 00096 conf.irFront = false; 00097 conf.irBack = false; 00098 conf.irSide = false; 00099 conf.irRangeFront = 3; 00100 conf.irRangeSide = 2; 00101 conf.irRangeBack = 2; 00102 conf.wheelSubstance.toRubber(40); 00103 return conf; 00104 } 00105 00106 virtual ~FourWheeled(); 00107 00108 /** 00109 * updates the OSG nodes of the vehicle 00110 */ 00111 virtual void update(); 00112 00113 virtual int getSensorNumber(); 00114 virtual int getMotorNumber(); 00115 00116 virtual int getSensors(sensor* sensors, int sensornumber); 00117 00118 virtual void setMotors(const motor* motors, int motornumber); 00119 00120 /** this function is called in each timestep. It should perform robot-internal checks, 00121 like space-internal collision detection, sensor resets/update etc. 00122 @param globalData structure that contains global data from the simulation environment 00123 */ 00124 virtual void doInternalStuff(GlobalData& globalData); 00125 00126 00127 protected: 00128 /** creates vehicle at desired pose 00129 @param pose 4x4 pose matrix 00130 */ 00131 virtual void create(const osg::Matrix& pose); 00132 00133 /** destroys vehicle and space 00134 */ 00135 virtual void destroy(); 00136 00137 FourWheeledConf conf; 00138 RaySensorBank irSensorBank; // a collection of ir sensors 00139 Primitive* bumpertrans; 00140 Primitive* bumper; 00141 }; 00142 00143 } 00144 00145 #endif