nimm2.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: nimm2.h,v $ 00023 * Revision 1.22 2006/12/21 11:43:05 martius 00024 * commenting style for doxygen //< -> ///< 00025 * new sensors for spherical robots 00026 * 00027 * Revision 1.21 2006/12/11 18:24:36 martius 00028 * memory freed 00029 * 00030 * Revision 1.20 2006/09/21 22:09:58 martius 00031 * collision for mesh 00032 * 00033 * Revision 1.19 2006/07/20 17:19:44 martius 00034 * removed using namespace std from matrix.h 00035 * 00036 * Revision 1.18 2006/07/14 12:23:40 martius 00037 * selforg becomes HEAD 00038 * 00039 * Revision 1.17.4.10 2006/06/25 16:57:14 martius 00040 * abstractrobot is configureable 00041 * name and revision 00042 * 00043 * Revision 1.17.4.9 2006/03/30 12:34:56 martius 00044 * documentation updated 00045 * 00046 * Revision 1.17.4.8 2006/01/31 15:36:14 martius 00047 * irRange in config 00048 * 00049 * Revision 1.17.4.7 2006/01/17 17:02:19 martius 00050 * faster, stronger, more friction 00051 * 00052 * Revision 1.17.4.6 2005/12/15 17:04:08 martius 00053 * Primitives are not longer inherited from OSGPrimitive, moreover 00054 * they aggregate them. 00055 * Joint have better getter and setter 00056 * 00057 * Revision 1.17.4.5 2005/12/14 15:37:09 martius 00058 * robots are working with osg 00059 * 00060 * Revision 1.17.4.4 2005/12/13 18:11:39 martius 00061 * still trying to port robots 00062 * 00063 * Revision 1.17.4.3 2005/11/16 11:26:52 martius 00064 * moved to selforg 00065 * 00066 * Revision 1.17.4.2 2005/11/15 12:29:26 martius 00067 * new selforg structure and OdeAgent, OdeRobot ... 00068 * 00069 * Revision 1.17.4.1 2005/11/14 17:37:17 martius 00070 * moved to selforg 00071 * 00072 * Revision 1.17 2005/09/27 14:11:37 martius 00073 * changed to use of Nimm2Conf 00074 * IR sensors at front 00075 * 00076 * Revision 1.16 2005/09/22 12:24:37 martius 00077 * removed global variables 00078 * OdeHandle and GlobalData are used instead 00079 * sensor prepared 00080 * 00081 * Revision 1.15 2005/09/22 11:22:15 martius 00082 * removed global variables 00083 * OdeHandle and GlobalData are used instead 00084 * sensor prepared 00085 * 00086 * Revision 1.14 2005/08/31 11:12:46 martius 00087 * removed unused vars 00088 * 00089 * Revision 1.13 2005/08/03 11:43:03 fhesse 00090 * wheels moved out of center in cigarMode 00091 * 00092 * Revision 1.12 2005/08/02 13:35:53 fhesse 00093 * cigarMode added 00094 * 00095 * Revision 1.11 2005/08/02 13:17:10 fhesse 00096 * bumper added 00097 * 00098 * Revision 1.10 2005/07/31 22:31:15 martius 00099 * textures 00100 * 00101 * Revision 1.9 2005/07/29 15:12:51 martius 00102 * color modified 00103 * spherical wheels are standart but adjustable 00104 * 00105 * Revision 1.8 2005/07/26 17:03:25 martius 00106 * resizeable 00107 * forces and collisions fixed 00108 * 00109 * Revision 1.7 2005/07/18 14:47:41 martius 00110 * world, space, contactgroup are not pointers anymore. 00111 * 00112 * Revision 1.6 2005/07/08 09:33:28 martius 00113 * speed and force as optional constuctor parameter 00114 * 00115 * Revision 1.5 2005/07/07 09:27:40 martius 00116 * proper collision detection in car_space 00117 * 00118 * Revision 1.4 2005/07/06 16:04:39 martius 00119 * added collisioncallback to robot to perform smoother collisions of wheels with ground 00120 * 00121 * Revision 1.3 2005/06/23 13:31:15 fhesse 00122 * Vehicle changed to Nimm2 00123 * 00124 * * 00125 ***************************************************************************/ 00126 #ifndef __NIMM2_H 00127 #define __NIMM2_H 00128 00129 #include "oderobot.h" 00130 #include "raysensorbank.h" 00131 00132 #include "primitive.h" 00133 #include "joint.h" 00134 00135 namespace lpzrobots { 00136 00137 typedef struct Bumper{ 00138 Bumper() { trans = 0; bump = 0;} 00139 Primitive* trans; 00140 Primitive* bump; 00141 } Bumper; 00142 00143 typedef struct { 00144 double size; 00145 double force; 00146 double speed; 00147 bool sphereWheels; 00148 double wheelSize; ///< size of the wheels in body diameters 00149 bool bumper; 00150 bool cigarMode; 00151 bool irFront; 00152 bool irBack; 00153 bool irSide; 00154 double irRange; 00155 bool singleMotor; 00156 } Nimm2Conf; 00157 00158 /** Robot that looks like a Nimm 2 Bonbon :-) 00159 2 wheels and a cylinder like body 00160 */ 00161 class Nimm2 : public OdeRobot{ 00162 public: 00163 00164 Nimm2(const OdeHandle& odehandle, const OsgHandle& osgHandle, 00165 const Nimm2Conf& conf, const std::string& name); 00166 00167 static Nimm2Conf getDefaultConf(){ 00168 Nimm2Conf conf; 00169 conf.size=1; 00170 conf.force=8; 00171 conf.speed=12; 00172 conf.sphereWheels=true; 00173 conf.wheelSize=1; 00174 conf.bumper=false; 00175 conf.cigarMode=false; 00176 conf.irFront=false; 00177 conf.irBack=false; 00178 conf.irSide=false; 00179 conf.irRange=3; 00180 conf.singleMotor=false; 00181 return conf; 00182 } 00183 00184 virtual ~Nimm2(); 00185 00186 /** 00187 * updates the OSG nodes of the vehicle 00188 */ 00189 virtual void update(); 00190 00191 /** sets the pose of the vehicle 00192 @param pose desired 4x4 pose matrix 00193 */ 00194 virtual void place(const osg::Matrix& pose); 00195 00196 /** returns actual sensorvalues 00197 @param sensors sensors scaled to [-1,1] 00198 @param sensornumber length of the sensor array 00199 @return number of actually written sensors 00200 */ 00201 virtual int getSensors(sensor* sensors, int sensornumber); 00202 00203 /** sets actual motorcommands 00204 @param motors motors scaled to [-1,1] 00205 @param motornumber length of the motor array 00206 */ 00207 virtual void setMotors(const motor* motors, int motornumber); 00208 00209 /** returns number of sensors 00210 */ 00211 virtual int getSensorNumber(){ 00212 return sensorno; 00213 }; 00214 00215 /** returns number of motors 00216 */ 00217 virtual int getMotorNumber(){ 00218 return motorno; 00219 }; 00220 00221 /** returns a vector with the positions of all segments of the robot 00222 @param poslist vector of positions (of all robot segments) 00223 @return length of the list 00224 */ 00225 virtual int getSegmentsPosition(std::vector<Position> &poslist); 00226 00227 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00228 00229 /** this function is called in each timestep. It should perform robot-internal checks, 00230 like space-internal collision detection, sensor resets/update etc. 00231 @param globalData structure that contains global data from the simulation environment 00232 */ 00233 virtual void doInternalStuff(const GlobalData& globalData); 00234 00235 protected: 00236 /** the main object of the robot, which is used for position and speed tracking */ 00237 virtual Primitive* getMainPrimitive() const { return object[0]; } 00238 00239 /** creates vehicle at desired pose 00240 @param pose 4x4 pose matrix 00241 */ 00242 virtual void create(const osg::Matrix& pose); 00243 00244 /** destroys vehicle and space 00245 */ 00246 virtual void destroy(); 00247 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00248 00249 Nimm2Conf conf; 00250 00251 double length; // chassis length 00252 double width; // chassis width 00253 double height; // chassis height 00254 double radius; // wheel radius 00255 double wheelthickness; // thickness of the wheels 00256 double cmass; // chassis mass 00257 double wmass; // wheel mass 00258 int sensorno; //number of sensors 00259 int motorno; // number of motors 00260 00261 bool created; // true if robot was created 00262 double max_force; 00263 00264 Primitive* object[3]; // 1 cylinder, 2 wheels 00265 double wheeloffset; // offset from center when in cigarMode 00266 int number_bumpers; // number of bumpers (1 -> bumpers at one side, 2 -> bumpers at 2 sides) 00267 Bumper bumper[2]; 00268 Hinge2Joint* joint[2]; // joints between cylinder and each wheel 00269 00270 RaySensorBank irSensorBank; // a collection of ir sensors 00271 }; 00272 00273 } 00274 00275 #endif

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