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 __RELATIVEPOSITIONSENSOR_H 00025 #define __RELATIVEPOSITIONSENSOR_H 00026 00027 #include "sensor.h" 00028 00029 namespace lpzrobots { 00030 00031 /** Class for relative position sensing. 00032 The sensor values are the normalised relative position to some given object ( setReference() ) 00033 */ 00034 class RelativePositionSensor : public Sensor { 00035 public: 00036 /** 00037 @param maxDistance maximal distance that is expected used for normalisation of sensor value 00038 @param exponent exponent of the sensor characteritic (default: 1 (linear)) 00039 @param dimensions bit mask for the dimensions to sense. Default: X | Y | Z (all dimensions) 00040 @see Dimensions 00041 */ 00042 RelativePositionSensor(double maxDistance, double exponent, short dimensions = X | Y | Z , bool local_coordinates = false); 00043 virtual ~RelativePositionSensor() {} 00044 00045 virtual void init(Primitive* own); 00046 virtual int getSensorNumber() const; 00047 00048 virtual bool sense(const GlobalData& globaldata); 00049 virtual std::list<sensor> get() const; 00050 virtual int get(sensor* sensors, int length) const; 00051 00052 /** 00053 Sets the reference object we use for relative position measureing. 00054 This can be another robot an obstacle (light source) and such like 00055 This must be called before first sense() or get() call. 00056 */ 00057 virtual void setReference(Primitive* ref); 00058 00059 private: 00060 double maxDistance; 00061 double exponent; 00062 short dimensions; 00063 Primitive* own; 00064 Primitive* ref; 00065 bool local_coords; 00066 }; 00067 00068 00069 } 00070 00071 #endif