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: nimm4.h,v $ 00023 * Revision 1.10 2009/05/11 17:03:07 martius 00024 * minor substance change 00025 * 00026 * Revision 1.9 2008/05/07 16:45:52 martius 00027 * code cosmetics and documentation 00028 * 00029 * Revision 1.8 2007/11/07 13:21:16 martius 00030 * doInternal stuff changed signature 00031 * 00032 * Revision 1.7 2007/09/06 18:48:00 martius 00033 * createNewSimpleSpace used 00034 * 00035 * Revision 1.6 2006/07/14 12:23:41 martius 00036 * selforg becomes HEAD 00037 * 00038 * Revision 1.5.4.13 2006/06/25 16:57:14 martius 00039 * abstractrobot is configureable 00040 * name and revision 00041 * 00042 * Revision 1.5.4.12 2006/04/04 14:13:24 fhesse 00043 * documentation improved 00044 * 00045 * Revision 1.5.4.11 2006/03/31 16:20:28 fhesse 00046 * class Joint; changed to: class Hinge2Joint; 00047 * 00048 * Revision 1.5.4.10 2006/03/30 12:34:56 martius 00049 * documentation updated 00050 * 00051 * Revision 1.5.4.9 2005/12/15 17:04:08 martius 00052 * Primitives are not longer inherited from OSGPrimitive, moreover 00053 * they aggregate them. 00054 * Joint have better getter and setter 00055 * 00056 * Revision 1.5.4.8 2005/12/14 15:37:09 martius 00057 * robots are working with osg 00058 * 00059 * Revision 1.5.4.7 2005/12/13 18:11:40 martius 00060 * still trying to port robots 00061 * 00062 * Revision 1.5.4.6 2005/12/12 23:41:19 martius 00063 * added Joint wrapper 00064 * 00065 * Revision 1.5.4.5 2005/12/11 23:35:08 martius 00066 * *** empty log message *** 00067 * 00068 * Revision 1.5.4.4 2005/12/06 10:13:25 martius 00069 * openscenegraph integration started 00070 * 00071 * Revision 1.5.4.3 2005/11/16 11:26:52 martius 00072 * moved to selforg 00073 * 00074 * Revision 1.5.4.2 2005/11/15 12:29:26 martius 00075 * new selforg structure and OdeAgent, OdeRobot ... 00076 * 00077 * Revision 1.5.4.1 2005/11/14 17:37:18 martius 00078 * moved to selforg 00079 * 00080 * Revision 1.5 2005/10/27 16:10:41 fhesse 00081 * nimm4 as example 00082 * 00083 * Revision 1.4 2005/09/22 12:24:37 martius 00084 * removed global variables 00085 * OdeHandle and GlobalData are used instead 00086 * sensor prepared 00087 * 00088 * Revision 1.3 2005/08/31 11:14:06 martius 00089 * removed unused vars 00090 * 00091 * Revision 1.2 2005/08/03 20:38:56 martius 00092 * added textures and correct placement 00093 * 00094 * Revision 1.1 2005/07/29 15:13:11 martius 00095 * a robot with 4 independent wheels 00096 * 00097 * * 00098 ***************************************************************************/ 00099 #ifndef __NIMM4_H 00100 #define __NIMM4_H 00101 00102 #include "oderobot.h" 00103 00104 namespace lpzrobots { 00105 00106 class Primitive; 00107 class Hinge2Joint; 00108 00109 /** Robot that looks like a Nimm 2 Bonbon :-) 00110 4 wheels and a capsule like body 00111 */ 00112 class Nimm4 : public OdeRobot{ 00113 public: 00114 00115 /** 00116 * constructor of nimm4 robot 00117 * @param odeHandle data structure for accessing ODE 00118 * @param osgHandle ata structure for accessing OSG 00119 * @param size scaling of robot 00120 * @param force maximal used force to realize motorcommand 00121 * @param speed factor for changing speed of robot 00122 * @param sphereWheels switches between spheres and 'normal' wheels 00123 */ 00124 Nimm4(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const std::string& name, 00125 double size=1, double force=3, double speed=15, bool sphereWheels=true); 00126 00127 virtual ~Nimm4(){ 00128 destroy(); 00129 }; 00130 00131 /** 00132 * updates the OSG nodes of the vehicle 00133 */ 00134 virtual void update(); 00135 00136 00137 /** sets the pose of the vehicle 00138 @param pose desired pose matrix 00139 */ 00140 virtual void place(const osg::Matrix& pose); 00141 00142 /** returns actual sensorvalues 00143 @param sensors sensors scaled to [-1,1] 00144 @param sensornumber length of the sensor array 00145 @return number of actually written sensors 00146 */ 00147 virtual int getSensors(sensor* sensors, int sensornumber); 00148 00149 /** sets actual motorcommands 00150 @param motors motors scaled to [-1,1] 00151 @param motornumber length of the motor array 00152 */ 00153 virtual void setMotors(const motor* motors, int motornumber); 00154 00155 /** returns number of sensors 00156 */ 00157 virtual int getSensorNumber(){ 00158 return sensorno; 00159 }; 00160 00161 /** returns number of motors 00162 */ 00163 virtual int getMotorNumber(){ 00164 return motorno; 00165 }; 00166 00167 /** this function is called in each timestep. It should perform robot-internal checks, 00168 like space-internal collision detection, sensor resets/update etc. 00169 @param globalData structure that contains global data from the simulation environment 00170 */ 00171 virtual void doInternalStuff(GlobalData& globalData); 00172 00173 00174 protected: 00175 /** the main object of the robot, which is used for position and speed tracking */ 00176 virtual Primitive* getMainPrimitive() const { return object[0]; } 00177 00178 /** creates vehicle at desired pose 00179 @param pose 4x4 pose matrix 00180 */ 00181 virtual void create(const osg::Matrix& pose); 00182 00183 /** destroys vehicle and space 00184 */ 00185 virtual void destroy(); 00186 00187 /** additional things for collision handling can be done here 00188 */ 00189 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00190 00191 double length; // chassis length 00192 double width; // chassis width 00193 double height; // chassis height 00194 double radius; // wheel radius 00195 double wheelthickness; // thickness of the wheels 00196 bool sphereWheels; // draw spherical wheels? 00197 double cmass; // chassis mass 00198 double wmass; // wheel mass 00199 int sensorno; // number of sensors 00200 int motorno; // number of motors 00201 int segmentsno; // number of motorsvehicle segments 00202 double speed; // factor for adjusting speed of robot 00203 00204 double max_force; // maximal force for motors 00205 00206 bool created; // true if robot was created 00207 00208 Substance wheelsubstance; // material of wheel 00209 00210 Primitive* object[5]; // 1 capsule, 4 wheels 00211 Hinge2Joint* joint[4]; // joints between cylinder and each wheel 00212 00213 }; 00214 00215 } 00216 00217 #endif