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

Generated on Tue Apr 4 19:05:04 2006 for Robotsystem from Robot Group Leipzig by  doxygen 1.4.5