Robotsystem of the Robot Group Leipzig: raysensorbank.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

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