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

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