Robot Simulator of the Robotics Group for Self-Organization of Control: raysensor.h Source File

# raysensor.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024 #ifndef __RAYSENSOR_H
    00025 #define __RAYSENSOR_H
    00026
    00027 #include <ode-dbl/common.h>
    00028 #include "osgforwarddecl.h"
    00029 #include "odehandle.h"
    00030 #include "osghandle.h"
    00031
    00032
    00033 namespace lpzrobots {
    00034   class Primitive;
    00035
    00036 /** Abstract class for Ray-based sensors.
    00037     This are sensors which are based on distance measurements using the ODE geom class Ray.
    00038     The sensor value is obtained by collisions.
    00039     However of no collision is detected the sensor needs to ajust its output as well.
    00040     Therefore a reset function is provided.
    00041     See also RaySensorBank, which is an object for managing multiple ray sensors.
    00042  */
    00043 class RaySensor {
    00044 public:
    00045   enum rayDrawMode { drawNothing, drawRay, drawSensor, drawAll};
    00046
    00047   RaySensor() {}
    00048   virtual ~RaySensor(){}
    00049
    00050   // should create a copy if this, without initialisation
    00051   virtual RaySensor* clone() const = 0;
    00052
    00053   /** providing essential information
    00054       @param odeHandle OdeHandle
    00055       @param osgHandle OsgHandle
    00056       @param body primitive to which the sensor will be attached
    00057       @param pose relative pose in respect to body in which the sensor will be placed
    00058       @param range length of the sensor
    00059       @param drawMode whether to draw nothing, sensor body, ray, or both
    00060    */
    00061   virtual void init(const OdeHandle& odeHandle,
    00062                     const OsgHandle& osgHandle, Primitive* body,
    00063                     const osg::Matrix pose, float range,
    00064                     rayDrawMode drawMode = drawSensor) = 0;
    00065
    00066   /** used for reseting the sensor value to a value of maximal distance.
    00067    */
    00068   virtual void reset() = 0;
    00069
    00070   /** returns the sensor value (usually in the range [-1,1] )
    00071    */
    00072   virtual double get() = 0;
    00073
    00074   /** set the range of the sensor
    00075       @param range new length of the sensor
    00076   */
    00077   virtual void setRange(float range) = 0;
    00078
    00079   /** updates the position of the osg nodes
    00080    */
    00081   virtual void update() = 0;
    00082
    00083 };
    00084
    00085 }
    00086
    00087 #endif