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