formel1.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: formel1.h,v $ 00023 * Revision 1.5 2006/07/14 12:23:40 martius 00024 * selforg becomes HEAD 00025 * 00026 * Revision 1.2.4.5 2006/03/30 12:34:56 martius 00027 * documentation updated 00028 * 00029 * Revision 1.2.4.4 2006/01/12 14:47:47 martius 00030 * just taken from nimm4 00031 * 00032 * Revision 1.2.4.3 2005/11/16 11:26:52 martius 00033 * moved to selforg 00034 * 00035 * Revision 1.2.4.2 2005/11/15 12:29:26 martius 00036 * new selforg structure and OdeAgent, OdeRobot ... 00037 * 00038 * Revision 1.2.4.1 2005/11/14 17:37:17 martius 00039 * moved to selforg 00040 * 00041 * Revision 1.2 2005/09/22 12:24:37 martius 00042 * removed global variables 00043 * OdeHandle and GlobalData are used instead 00044 * sensor prepared 00045 * 00046 * Revision 1.1 2005/08/09 10:44:54 robot1 00047 * first vehicle for formel1 simulation 00048 * 00049 * 00050 * * 00051 ***************************************************************************/ 00052 #ifndef __FORMEL1_H 00053 #define __FORMEL1_H 00054 00055 #include "oderobot.h" 00056 00057 namespace lpzrobots { 00058 00059 class Primitive; 00060 class Joint; 00061 00062 /** Robot that looks like a Nimm 2 Bonbon :-) 00063 4 wheels and a capsule like body 00064 */ 00065 class Formel1 : public OdeRobot{ 00066 public: 00067 00068 Formel1(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00069 double size=1, double force=3, double speed=15, bool sphereWheels=true); 00070 00071 virtual ~Formel1(){}; 00072 00073 /** 00074 * updates the OSG nodes of the vehicle 00075 */ 00076 virtual void update(); 00077 00078 00079 /** sets the pose of the vehicle 00080 @param pose desired pose matrix 00081 */ 00082 virtual void place(const osg::Matrix& pose); 00083 00084 /** returns actual sensorvalues 00085 @param sensors sensors scaled to [-1,1] 00086 @param sensornumber length of the sensor array 00087 @return number of actually written sensors 00088 */ 00089 virtual int getSensors(sensor* sensors, int sensornumber); 00090 00091 /** sets actual motorcommands 00092 @param motors motors scaled to [-1,1] 00093 @param motornumber length of the motor array 00094 */ 00095 virtual void setMotors(const motor* motors, int motornumber); 00096 00097 /** returns number of sensors 00098 */ 00099 virtual int getSensorNumber(){ 00100 return sensorno; 00101 }; 00102 00103 /** returns number of motors 00104 */ 00105 virtual int getMotorNumber(){ 00106 return motorno; 00107 }; 00108 00109 /** checks for internal collisions and treats them. 00110 * In case of a treatment return true (collision will be ignored by other objects 00111 * and the default routine) else false (collision is passed to other objects and 00112 * (if not treated) to the default routine). 00113 */ 00114 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00115 00116 /** this function is called in each timestep. It should perform robot-internal checks, 00117 like space-internal collision detection, sensor resets/update etc. 00118 @param globalData structure that contains global data from the simulation environment 00119 */ 00120 virtual void doInternalStuff(const GlobalData& globalData); 00121 00122 00123 protected: 00124 /** the main object of the robot, which is used for position and speed tracking */ 00125 virtual Primitive* getMainPrimitive() const { return object[0]; } 00126 00127 /** creates vehicle at desired pose 00128 @param pose 4x4 pose matrix 00129 */ 00130 virtual void create(const osg::Matrix& pose); 00131 00132 /** destroys vehicle and space 00133 */ 00134 virtual void destroy(); 00135 00136 /** additional things for collision handling can be done here 00137 */ 00138 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00139 00140 double length; // chassis length 00141 double width; // chassis width 00142 double height; // chassis height 00143 double radius; // wheel radius 00144 double wheelthickness; // thickness of the wheels 00145 bool sphereWheels; // draw spherical wheels? 00146 double cmass; // chassis mass 00147 double wmass; // wheel mass 00148 int sensorno; //number of sensors 00149 int motorno; // number of motors 00150 int segmentsno; // number of motorsvehicle segments 00151 double speed; // 00152 00153 double max_force; // maximal force for motors 00154 00155 bool created; // true if robot was created 00156 00157 Primitive* object[5]; // 1 capsule, 4 wheels 00158 Hinge2Joint* joint[4]; // joints between cylinder and each wheel 00159 00160 }; 00161 00162 } 00163 00164 00165 #endif

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