sphererobotTest.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: sphererobotTest.h,v $ 00023 * Revision 1.6 2006/07/14 12:23:50 martius 00024 * selforg becomes HEAD 00025 * 00026 * Revision 1.5.4.2 2006/03/30 12:35:04 martius 00027 * documentation updated 00028 * 00029 * Revision 1.5.4.1 2005/11/15 12:29:51 martius 00030 * new selforg structure and OdeAgent, OdeRobot ... 00031 * 00032 * Revision 1.5 2005/11/09 13:43:17 fhesse 00033 * GPL added 00034 * * 00035 * * 00036 ***************************************************************************/ 00037 /************************************************************************/ 00038 /*shpererobot.h */ 00039 /*Schlangenkonstrukt fuer das ODE-Robotersystem des Authors */ 00040 /*@author Marcel Kretschmann */ 00041 /*@version alpha 0.1 */ 00042 /* */ 00043 /************************************************************************/ 00044 #ifndef __SPHEREROBOTTest_H 00045 #define __SPHEREROBOTTest_H 00046 00047 00048 #include "sphererobot.h" 00049 #include "sliderservo.h" 00050 #include "roboter.h" 00051 00052 /** 00053 *This is a class, which models a snake like robot. It consists of a number of equal elements, each linked 00054 *by a joint. This class is based upon the class roboter by the same author. 00055 *@author Marcel Kretschmann 00056 *@version beta 00057 **/ 00058 class SphererobotTest : public Roboter 00059 { 00060 public: 00061 typedef enum objects { Base, Pendular, Pole1Bot, Pole2Bot, Pole3Bot, 00062 Pole1Top , Pole2Top, Pole3Top}; 00063 00064 private: 00065 00066 //std::vector<dJointID> skyJoints; // for fixing segment 0 in the sky 00067 dSpaceID sphererobot_space; 00068 00069 vector<PID*> motorliste2; 00070 00071 public: 00072 SliderServo* servo; 00073 protected: 00074 SphererobotConf conf; 00075 double lastJointPos[3]; 00076 00077 public: 00078 00079 //SphererobotTest (); 00080 00081 /** 00082 *constructor 00083 *@param startRoboterID ID, which should be managed clearly 00084 *@author Marcel Kretschmann 00085 *@version beta 00086 **/ 00087 SphererobotTest ( int startRoboterID , const OdeHandle& odeHandle, 00088 const SphererobotConf& conf ); 00089 00090 /** 00091 *Destruktor 00092 *@author Marcel Kretschmann 00093 *@version beta 00094 **/ 00095 virtual ~SphererobotTest(); 00096 00097 static SphererobotConf getStandartConf(){ 00098 SphererobotConf c; 00099 c.diameter = 1; 00100 c.spheremass = 0.001; 00101 c.pendulardiameter = 0.2; 00102 c.pendularmass = 0.3; 00103 c.slidermass = 0.0001; 00104 c.sliderrange = 0.1; // range of the slider from center in multiple of diameter [-range,range] 00105 c.hingeRange = M_PI/180*45; 00106 return c; 00107 } 00108 00109 /** 00110 *Draws the geometrical objects of the robot. 00111 *@author Marcel Kretschmann 00112 *@version beta 00113 **/ 00114 virtual void draw(); 00115 00116 /**Sets the sphere to position pos, sets color to c, and creates sphere if necessary. 00117 *This overwrides the function place of the class robot. 00118 *@param pos desired position of the snake in struct Position 00119 *@param c desired color for the snake in struct Color 00120 *@author Marcel Kretschmann 00121 *@version beta 00122 **/ 00123 virtual void place (Position pos, Color *c = 0); 00124 00125 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00126 00127 /** 00128 *This is the collision handling function for snake robots. 00129 *This overwrides the function collisionCallback of the class robot. 00130 *@param data 00131 *@param o1 first geometrical object, which has taken part in the collision 00132 *@param o2 second geometrical object, which has taken part in the collision 00133 *@return true if the collision was threated by the robot, false if not 00134 *@author Marcel Kretschmann 00135 *@version beta 00136 **/ 00137 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00138 00139 /** 00140 *Writes the sensor values to an array in the memory. 00141 *@param sensors pointer to the array 00142 *@param sensornumber length of the sensor array 00143 *@return number of actually written sensors 00144 *@author Marcel Kretschmann 00145 *@version beta 00146 **/ 00147 virtual int getSensors ( sensor* sensors, int sensornumber ); 00148 00149 /** 00150 *Reads the actual motor commands from an array, an sets all motors of the snake to this values. 00151 *It is an linear allocation. 00152 *@param motors pointer to the array, motor values are scaled to [-1,1] 00153 *@param motornumber length of the motor array 00154 *@author Marcel Kretschmann 00155 *@version beta 00156 **/ 00157 virtual void setMotors ( const motor* motors, int motornumber ); 00158 00159 /** 00160 *Returns the number of motors used by the snake. 00161 *@return number of motors 00162 *@author Marcel Kretschmann 00163 *@version final 00164 **/ 00165 virtual int getMotorNumber(); 00166 00167 /** 00168 *Returns the number of sensors used by the robot. 00169 *@return number of sensors 00170 *@author Marcel Kretschmann 00171 *@version final 00172 **/ 00173 virtual int getSensorNumber(); 00174 00175 /** 00176 *Updates the sensorarray. 00177 *This overwrides the function sensoraktualisierung of the class robot 00178 *@author Marcel Kretschmann 00179 *@version beta 00180 **/ 00181 virtual void sensoraktualisierung ( ); 00182 00183 /** 00184 *Prints some internal robot parameters. Actualy it prints all sensor data of one callculation step. 00185 *@author Marcel Kretschmann 00186 *@version beta 00187 **/ 00188 virtual void getStatus (); 00189 00190 protected: 00191 virtual Object getMainObject(){ return Object();} 00192 00193 }; 00194 00195 #endif

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