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: shortcircuit.h,v $ 00023 * Revision 1.7 2009/02/02 16:07:49 martius 00024 * added dummy object to avoid crash with tv/following camera 00025 * 00026 * Revision 1.6 2007/11/07 13:21:16 martius 00027 * doInternal stuff changed signature 00028 * 00029 * Revision 1.5 2006/12/11 18:24:37 martius 00030 * memory freed 00031 * 00032 * Revision 1.4 2006/07/14 12:23:42 martius 00033 * selforg becomes HEAD 00034 * 00035 * Revision 1.3.4.6 2006/03/30 12:34:57 martius 00036 * documentation updated 00037 * 00038 * Revision 1.3.4.5 2006/01/10 21:46:34 martius 00039 * collcallbak 00040 * 00041 * Revision 1.3.4.4 2006/01/10 20:32:58 martius 00042 * moved to osg 00043 * 00044 * Revision 1.3.4.3 2005/11/16 11:26:53 martius 00045 * moved to selforg 00046 * 00047 * Revision 1.3.4.2 2005/11/15 12:29:27 martius 00048 * new selforg structure and OdeAgent, OdeRobot ... 00049 * 00050 * Revision 1.3.4.1 2005/11/14 17:37:18 martius 00051 * moved to selforg 00052 * 00053 * Revision 1.3 2005/09/22 12:24:37 martius 00054 * removed global variables 00055 * OdeHandle and GlobalData are used instead 00056 * sensor prepared 00057 * 00058 * Revision 1.2 2005/07/18 14:47:41 martius 00059 * world, space, contactgroup are not pointers anymore. 00060 * 00061 * Revision 1.1 2005/07/06 16:03:37 martius 00062 * dummy robot that connects motors with sensors 00063 * 00064 ***************************************************************************/ 00065 #ifndef __SHORTCIRCUIT_H 00066 #define __SHORTCIRCUIT_H 00067 00068 00069 #include "oderobot.h" 00070 #include "primitive.h" 00071 00072 namespace lpzrobots { 00073 00074 /** 00075 * 00076 */ 00077 class ShortCircuit : public OdeRobot{ 00078 public: 00079 ShortCircuit(const OdeHandle& odeHandle, const OsgHandle& osgHandle, int sensornumber, int motornumber); 00080 00081 virtual ~ShortCircuit(); 00082 00083 virtual void update() {} 00084 00085 /** sets the pose of the vehicle 00086 @param pose desired 4x4 pose matrix 00087 */ 00088 virtual void place(const osg::Matrix& pose) {} 00089 00090 /** returns actual sensorvalues 00091 @param sensors sensors scaled to [-1,1] 00092 @param sensornumber length of the sensor array 00093 @return number of actually written sensors 00094 */ 00095 virtual int getSensors(sensor* sensors, int sensornumber); 00096 00097 /** sets actual motorcommands 00098 @param motors motors scaled to [-1,1] 00099 @param motornumber length of the motor array 00100 */ 00101 virtual void setMotors(const motor* motors, int motornumber); 00102 00103 /** returns number of sensors 00104 */ 00105 virtual int getSensorNumber() {return sensorno; } 00106 00107 /** returns number of motors 00108 */ 00109 virtual int getMotorNumber() {return motorno; } 00110 00111 /** this function is called in each timestep. It should perform robot-internal checks, 00112 like space-internal collision detection, sensor resets/update etc. 00113 @param globalData structure that contains global data from the simulation environment 00114 */ 00115 virtual void doInternalStuff(GlobalData& globalData) {} 00116 00117 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2) { return false;} 00118 00119 protected: 00120 /** the main object of the robot, which is used for position and speed tracking */ 00121 virtual Primitive* getMainPrimitive() const { return dummy; } 00122 00123 protected: 00124 DummyPrimitive *dummy; 00125 int sensorno; //number of sensors 00126 int motorno; // number of motors 00127 motor* motors; 00128 } ; 00129 00130 } 00131 00132 #endif 00133