defaultWheelie.h

Go to the documentation of this file.
00001 /************************************************************************/ 00002 /* originally from: */ 00003 /* schlange.h */ 00004 /* Abstract class for Snakes */ 00005 /* @author Georg Martius */ 00006 /************************************************************************/ 00007 /* here: */ 00008 /* defaultWheelie.h */ 00009 /* Abstract class for Wheelies */ 00010 /* @author Frank Guettler */ 00011 /************************************************************************/ 00012 /*************************************************************************** 00013 * Copyright (C) 2005 by Robot Group Leipzig * 00014 * martius@informatik.uni-leipzig.de * 00015 * fhesse@informatik.uni-leipzig.de * 00016 * der@informatik.uni-leipzig.de * 00017 * frankguettler@gmx.de * 00018 * * 00019 * This program is free software; you can redistribute it and/or modify * 00020 * it under the terms of the GNU General Public License as published by * 00021 * the Free Software Foundation; either version 2 of the License, or * 00022 * (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the * 00031 * Free Software Foundation, Inc., * 00032 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00033 * * 00034 * $Log: defaultWheelie.h,v $ 00035 * Revision 1.4 2006/12/21 11:43:05 martius 00036 * commenting style for doxygen //< -> ///< 00037 * new sensors for spherical robots 00038 * 00039 * Revision 1.3 2006/07/20 17:19:44 martius 00040 * removed using namespace std from matrix.h 00041 * 00042 * Revision 1.2 2006/07/14 12:23:40 martius 00043 * selforg becomes HEAD 00044 * 00045 * Revision 1.1.2.3 2006/06/25 16:57:12 martius 00046 * abstractrobot is configureable 00047 * name and revision 00048 * 00049 * Revision 1.1.2.2 2006/06/20 07:18:29 robot3 00050 * -added cvs log 00051 * -changed some behaviour of wheelie 00052 * 00053 * * 00054 ***************************************************************************/ 00055 #ifndef __DEFAULTWHEELIE_H 00056 #define __DEFAULTWHEELIE_H 00057 00058 #include<vector> 00059 #include<assert.h> 00060 00061 #include"primitive.h" 00062 #include "joint.h" 00063 #include "angularmotor.h" 00064 00065 #include "oderobot.h" 00066 #include <selforg/configurable.h> 00067 00068 namespace lpzrobots { 00069 00070 typedef struct { 00071 public: 00072 int segmNumber; ///< number of snake elements 00073 double segmLength; ///< length of one snake element 00074 double segmDia; ///< diameter of a snake element 00075 double segmMass; ///< mass of one snake element 00076 double motorPower; ///< power of the motors / servos 00077 double sensorFactor; ///< scale for sensors 00078 double frictionGround; ///< friction with ground 00079 double frictionJoint; ///< friction within joint 00080 double jointLimit; ///< maximal angle for the joints (M_PI/2 = 90 degree) 00081 } WheelieConf; 00082 00083 00084 /** 00085 * This is a class, which models a snake like robot. 00086 * It consists of a number of equal elements, each linked 00087 * by a joint 00088 **/ 00089 class DefaultWheelie: public OdeRobot 00090 { 00091 protected: 00092 00093 bool created; 00094 00095 std::vector <Primitive*> objects; 00096 std::vector <Joint*> joints; 00097 std::vector <AngularMotor*> frictionmotors; 00098 WheelieConf conf; 00099 00100 public: 00101 DefaultWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00102 const WheelieConf& conf, const std::string& name, const std::string& revision); 00103 00104 static WheelieConf getDefaultConf(){ 00105 WheelieConf conf; 00106 conf.segmNumber = 8; // number of snake elements 00107 conf.segmLength = 0.4; // length of one snake element 00108 conf.segmDia = 0.2; // diameter of a snake element 00109 conf.segmMass = 0.4; // mass of one snake element 00110 conf.motorPower = 1; // power of the servos 00111 conf.sensorFactor = 1; // scale for sensors 00112 conf.frictionGround = 1.0; // friction with ground 00113 conf.frictionJoint = 0.1; // friction within joint 00114 conf.jointLimit = M_PI/8; 00115 return conf; 00116 } 00117 00118 virtual ~DefaultWheelie(); 00119 00120 00121 /** sets the pose of the vehicle 00122 @param pose desired 4x4 pose matrix 00123 */ 00124 virtual void place(const osg::Matrix& pose); 00125 00126 /// update all primitives and joints 00127 virtual void update(); 00128 00129 /** 00130 *This is the collision handling function for snake robots. 00131 *This overwrides the function collisionCallback of the class robot. 00132 *@param data 00133 *@param o1 first geometrical object, which has taken part in the collision 00134 *@param o2 second geometrical object, which has taken part in the collision 00135 *@return true if the collision was threated by the robot, false if not 00136 **/ 00137 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00138 00139 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00140 00141 virtual void doInternalStuff(const GlobalData& global); 00142 00143 /** 00144 *Reads the actual motor commands from an array, 00145 *an sets all motors of the snake to this values. 00146 *It is an linear allocation. 00147 *@param motors pointer to the array, motor values are scaled to [-1,1] 00148 *@param motornumber length of the motor array 00149 **/ 00150 virtual void setMotors ( const motor* motors, int motornumber ) = 0; 00151 00152 /** 00153 *Writes the sensor values to an array in the memory. 00154 *@param sensors pointer to the array 00155 *@param sensornumber length of the sensor array 00156 *@return number of actually written sensors 00157 **/ 00158 virtual int getSensors ( sensor* sensors, int sensornumber ) = 0; 00159 00160 /** returns number of sensors 00161 */ 00162 virtual int getSensorNumber() = 0; 00163 00164 /** returns number of motors 00165 */ 00166 virtual int getMotorNumber() = 0; 00167 00168 /** returns a vector with the positions of all segments of the robot 00169 @param poslist vector of positions (of all robot segments) 00170 @return length of the list 00171 */ 00172 virtual int getSegmentsPosition(std::vector<Position> &poslist); 00173 00174 00175 /** The list of all parameters with there value as allocated lists. 00176 */ 00177 virtual paramlist getParamList() const; 00178 00179 virtual paramval getParam(const paramkey& key) const;; 00180 00181 virtual bool setParam(const paramkey& key, paramval val); 00182 00183 /** the main object of the robot, which is used for position and speed tracking */ 00184 virtual Primitive* getMainPrimitive() const { 00185 if(!objects.empty()){ 00186 // int half = objects.size()/2; 00187 // return (objects[half]); 00188 return (objects[0]); 00189 }else return 0; 00190 } 00191 protected: 00192 00193 /** creates vehicle at desired pose 00194 @param pose 4x4 pose matrix 00195 */ 00196 virtual void create(const osg::Matrix& pose); 00197 virtual void destroy(); 00198 }; 00199 00200 } 00201 00202 #endif

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