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 *************************************************************************** 00023 * * 00024 * Spherical Robot magically driven * 00025 * * 00026 * $Log: forcedsphere.h,v $ 00027 * Revision 1.3 2006/07/14 12:23:40 martius 00028 * selforg becomes HEAD 00029 * 00030 * Revision 1.2.4.5 2006/03/30 12:34:56 martius 00031 * documentation updated 00032 * 00033 * Revision 1.2.4.4 2006/01/10 22:25:09 martius 00034 * moved to osg 00035 * 00036 * 00037 * * 00038 ***************************************************************************/ 00039 00040 #ifndef __FORCESSPHERE_H 00041 #define __FORCESSPHERE_H 00042 00043 #include "oderobot.h" 00044 00045 namespace lpzrobots { 00046 00047 class Primitive; 00048 00049 class ForcedSphere : public OdeRobot 00050 { 00051 protected: 00052 Primitive* object[1]; 00053 double radius; 00054 double max_force; 00055 bool created; 00056 00057 public: 00058 00059 /** 00060 *constructor 00061 **/ 00062 ForcedSphere ( const OdeHandle& odeHandle, const OsgHandle& osgHandle, 00063 const char* name, double radius=1, double max_force=1); 00064 00065 virtual ~ForcedSphere(); 00066 00067 /// update all primitives and joints 00068 virtual void update(); 00069 00070 /** sets the pose of the vehicle 00071 @param pose desired 4x4 pose matrix 00072 */ 00073 virtual void place(const osg::Matrix& pose); 00074 00075 /** 00076 *This is the collision handling function for snake robots. 00077 *This overwrides the function collisionCallback of the class robot. 00078 *@param data 00079 *@param o1 first geometrical object, which has taken part in the collision 00080 *@param o2 second geometrical object, which has taken part in the collision 00081 *@return true if the collision was threated by the robot, false if not 00082 **/ 00083 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00084 /** this function is called in each timestep. It should perform robot-internal checks, 00085 like space-internal collision detection, sensor resets/update etc. 00086 @param globalData structure that contains global data from the simulation environment 00087 */ 00088 virtual void doInternalStuff(const GlobalData& globalData); 00089 00090 /** 00091 *Writes the sensor values to an array in the memory. 00092 *@param sensors pointer to the array 00093 *@param sensornumber length of the sensor array 00094 *@return number of actually written sensors 00095 **/ 00096 virtual int getSensors ( sensor* sensors, int sensornumber ); 00097 00098 /** 00099 *Reads the actual motor commands from an array, an sets all motors of the snake to this values. 00100 *It is an linear allocation. 00101 *@param motors pointer to the array, motor values are scaled to [-1,1] 00102 *@param motornumber length of the motor array 00103 **/ 00104 virtual void setMotors ( const motor* motors, int motornumber ); 00105 00106 /** 00107 *Returns the number of motors used by the snake. 00108 *@return number of motors 00109 **/ 00110 virtual int getMotorNumber(); 00111 00112 /** 00113 *Returns the number of sensors used by the robot. 00114 *@return number of sensors 00115 **/ 00116 virtual int getSensorNumber(); 00117 00118 00119 protected: 00120 /** the main object of the robot, which is used for position and speed tracking */ 00121 virtual Primitive* getMainPrimitive() const { return object[0]; } 00122 00123 /** creates vehicle at desired pose 00124 @param pose 4x4 pose matrix 00125 */ 00126 virtual void create(const osg::Matrix& pose); 00127 virtual void destroy(); 00128 00129 00130 }; 00131 00132 } 00133 00134 #endif
1.4.7