raysensorbank.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: raysensorbank.h,v $ 00023 * Revision 1.5 2006/09/20 12:56:28 martius 00024 * setRange 00025 * 00026 * Revision 1.4 2006/08/28 12:18:31 martius 00027 * documentation 00028 * 00029 * Revision 1.3 2006/07/14 12:23:43 martius 00030 * selforg becomes HEAD 00031 * 00032 * Revision 1.2.4.4 2006/03/30 12:34:59 martius 00033 * documentation updated 00034 * 00035 * Revision 1.2.4.3 2006/01/12 15:14:57 martius 00036 * indentation and clear routine 00037 * 00038 * Revision 1.2.4.2 2005/12/14 12:43:07 martius 00039 * moved to osg 00040 * 00041 * Revision 1.2.4.1 2005/12/13 18:11:54 martius 00042 * sensors ported, but not yet finished 00043 * 00044 * Revision 1.2 2005/09/27 13:59:26 martius 00045 * ir sensors are working now 00046 * 00047 * Revision 1.1 2005/09/27 11:03:34 fhesse 00048 * sensorbank added 00049 * 00050 * * 00051 ***************************************************************************/ 00052 #ifndef __RAYSENSORBANK_H 00053 #define __RAYSENSORBANK_H 00054 00055 #include <vector> 00056 #include "raysensor.h" 00057 00058 namespace lpzrobots { 00059 00060 /** Class for a bank (collection) of ray sensors. 00061 Ray sensors can be registered at the bank. Methods for resetting, 00062 sensing and reading the sensor values of all sensors are provided. 00063 */ 00064 class RaySensorBank { 00065 public: 00066 RaySensorBank(); 00067 00068 virtual ~RaySensorBank(); 00069 00070 /** initialises sensor bank with handles for ode and osg 00071 */ 00072 virtual void init( const OdeHandle& odeHandle, const OsgHandle& osgHandle ); 00073 00074 /** registers a new sensor at the sensor bank. The body and the pose have to be provided. 00075 @param raysensor RaySensor to add 00076 @param body body to which the sensor should be connected 00077 @param pose relative position/orientation 00078 @param range maximum sense range of the sensor 00079 @return index of the sensor 00080 */ 00081 virtual unsigned int registerSensor(RaySensor* raysensor, Primitive* body, 00082 const osg::Matrix& pose, double range, 00083 RaySensor::rayDrawMode drawMode); 00084 00085 /** resets all sensors (used for reseting the sensor value to a value of maximal distance) 00086 */ 00087 virtual void reset(); 00088 00089 /** performs sense action of all sensors by checking collision with the given object 00090 @return true for any collision handled (sensed) and false for no interaction 00091 */ 00092 virtual bool sense(dGeomID object); 00093 00094 /** returns the sensor value of the given sensor (usually in the range [-1,1] ) 00095 */ 00096 virtual double get(unsigned int index); 00097 00098 /** writes sensorvalues in given sensorarray 00099 @param sensorarray pointer to the sensorarray in which the values should be stored 00100 @param array_size maximal number of all elements in the sensorarray 00101 @return number of written sensorvalues 00102 */ 00103 virtual int get(double* sensorarray, unsigned int array_size); 00104 00105 /** set the range of the specified sensor (index) 00106 @param index index of sensor to modify 00107 @param range new length of the sensor 00108 */ 00109 virtual void setRange(unsigned int index, double range); 00110 00111 /** set the range of all sensors 00112 @param range new length of the sensors 00113 */ 00114 virtual void setRange(double range); 00115 00116 /** returns the spaceID of the sensor space 00117 */ 00118 virtual dSpaceID getSpaceID(); 00119 00120 /** updates the sensor's graphical representation 00121 */ 00122 virtual void update(); 00123 00124 // delete all registered sensors. 00125 virtual void clear(); 00126 00127 protected: 00128 std::vector<RaySensor*> bank; 00129 bool initialized; 00130 00131 OdeHandle odeHandle; 00132 OsgHandle osgHandle; 00133 }; 00134 00135 } 00136 00137 #endif

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