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