hurlingsnake.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: hurlingsnake.h,v $ 00023 * Revision 1.10 2006/08/11 15:44:53 martius 00024 * *** empty log message *** 00025 * 00026 * Revision 1.9 2006/07/20 17:19:44 martius 00027 * removed using namespace std from matrix.h 00028 * 00029 * Revision 1.8 2006/07/14 15:13:46 fhesse 00030 * minor changes 00031 * 00032 * Revision 1.6.4.9 2006/06/25 16:57:13 martius 00033 * abstractrobot is configureable 00034 * name and revision 00035 * 00036 * Revision 1.6.4.8 2006/03/30 12:34:56 martius 00037 * documentation updated 00038 * 00039 * Revision 1.6.4.7 2006/03/30 08:43:05 fhesse 00040 * getTracePrimitive removed 00041 * 00042 * Revision 1.6.4.6 2006/03/28 14:20:28 fhesse 00043 * getTracePrimitive() added 00044 * 00045 * Revision 1.6.4.5 2005/12/30 22:54:38 martius 00046 * removed parentspace! 00047 * 00048 * Revision 1.6.4.4 2005/12/21 17:35:09 martius 00049 * moved to osg 00050 * 00051 * Revision 1.6.4.3 2005/11/16 11:26:52 martius 00052 * moved to selforg 00053 * 00054 * Revision 1.6.4.2 2005/11/15 12:29:26 martius 00055 * new selforg structure and OdeAgent, OdeRobot ... 00056 * 00057 * Revision 1.6.4.1 2005/11/14 17:37:17 martius 00058 * moved to selforg 00059 * 00060 * Revision 1.6 2005/11/09 13:26:21 martius 00061 * added factorSensor 00062 * 00063 * Revision 1.5 2005/10/06 17:14:24 martius 00064 * switched to stl lists 00065 * 00066 * Revision 1.4 2005/09/22 12:24:37 martius 00067 * removed global variables 00068 * OdeHandle and GlobalData are used instead 00069 * sensor prepared 00070 * 00071 * Revision 1.3 2005/08/31 17:18:15 fhesse 00072 * setTextures added, Mass is now sphere (not box anymore) 00073 * 00074 * Revision 1.2 2005/07/26 17:04:21 martius 00075 * lives in its own space now 00076 * 00077 * Revision 1.1 2005/07/21 12:17:04 fhesse 00078 * new hurling snake, to do add collision space, clean up, comment 00079 * 00080 * 00081 * * 00082 ***************************************************************************/ 00083 #ifndef __HURLINGSNAKE_H 00084 #define __HURLINGSNAKE_H 00085 00086 #include "oderobot.h" 00087 #include <selforg/configurable.h> 00088 #include "primitive.h" 00089 #include "joint.h" 00090 00091 namespace lpzrobots { 00092 00093 /** 00094 * Hurling snake is a string a beats. 00095 * 00096 */ 00097 class HurlingSnake : public OdeRobot{ 00098 public: 00099 /** 00100 * Constructor 00101 */ 00102 HurlingSnake(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const std::string& name); 00103 00104 /// update the subcomponents 00105 virtual void update(); 00106 00107 /** sets the pose of the vehicle 00108 @param pose desired 4x4 pose matrix 00109 */ 00110 virtual void place(const osg::Matrix& pose); 00111 00112 /** checks for internal collisions and treats them. 00113 * In case of a treatment return true (collision will be ignored by other objects and the default routine) 00114 * else false (collision is passed to other objects and (if not treated) to the default routine). 00115 */ 00116 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00117 /** this function is called in each timestep. It should perform robot-internal checks, 00118 like space-internal collision detection, sensor resets/update etc. 00119 @param globalData structure that contains global data from the simulation environment 00120 */ 00121 virtual void doInternalStuff(const GlobalData& globalData); 00122 00123 00124 /** returns actual sensorvalues 00125 @param sensors sensors scaled to [-1,1] 00126 @param sensornumber length of the sensor array 00127 @return number of actually written sensors 00128 */ 00129 virtual int getSensors(sensor* sensors, int sensornumber); 00130 00131 /** sets actual motorcommands 00132 @param motors motors scaled to [-1,1] 00133 @param motornumber length of the motor array 00134 */ 00135 virtual void setMotors(const motor* motors, int motornumber); 00136 00137 /** returns number of sensors 00138 */ 00139 virtual int getSensorNumber(); 00140 00141 /** returns number of motors 00142 */ 00143 virtual int getMotorNumber(); 00144 00145 /** returns a vector with the positions of all segments of the robot 00146 @param poslist vector of positions (of all robot segments) 00147 @return length of the list 00148 */ 00149 virtual int getSegmentsPosition(std::vector<Position> &poslist); 00150 00151 /** The list of all parameters with there value as allocated lists. 00152 */ 00153 virtual paramlist getParamList() const; 00154 00155 virtual paramval getParam(const paramkey& key) const; 00156 00157 virtual bool setParam(const paramkey& key, paramval val); 00158 00159 protected: 00160 /** the main object of the robot, which is used for position and speed tracking */ 00161 virtual Primitive* getMainPrimitive() const { return object[4] /*(center)*/; } 00162 //virtual Primitive* getMainPrimitive() const { return object[NUM-1] /*(head element)*/; } 00163 00164 00165 private: 00166 00167 /** creates vehicle at desired pose 00168 @param pose 4x4 pose matrix 00169 */ 00170 virtual void create(const osg::Matrix& pose); 00171 00172 /** destroys robot and space 00173 */ 00174 virtual void destroy(); 00175 00176 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00177 00178 bool created; // true if robot was created 00179 00180 00181 Position initial_pos; // initial position of robot 00182 00183 int NUM; /* number of beats */ 00184 double MASS; /* mass of a beats */ 00185 double RADIUS; /* sphere radius */ 00186 00187 Joint* joint[9]; 00188 Primitive* object[10]; 00189 00190 Pos oldp; 00191 00192 int sensorno; 00193 int motorno; 00194 00195 paramval factorForce; 00196 paramval frictionGround; 00197 paramval factorSensor; 00198 00199 }; 00200 00201 } 00202 00203 #endif 00204

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