Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
relativepositionsensor.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __RELATIVEPOSITIONSENSOR_H
25 #define __RELATIVEPOSITIONSENSOR_H
26 
27 #include "sensor.h"
28 
29 namespace lpzrobots {
30 
31  /** Class for relative (or absolute) position sensing.
32  The sensor values are the normalised relative position to some given object ( setReference() ) or the origin.
33  */
34  class RelativePositionSensor : public Sensor {
35  public:
36  /**
37  @param maxDistance maximal distance that is expected used for normalisation of sensor value
38  @param exponent exponent of the sensor characteritic (default: 1 (linear))
39  @param dimensions bit mask for the dimensions to sense. Default: X | Y | Z (all dimensions)
40  @see Dimensions
41  If exact (relative) positions should be produced, use maxDistance=1 and exponent=1
42  */
43  RelativePositionSensor(double maxDistance, double exponent, short dimensions = X | Y | Z , bool local_coordinates = false);
45 
46  virtual void init(Primitive* own, Joint* joint = 0);
47  virtual int getSensorNumber() const;
48 
49  virtual bool sense(const GlobalData& globaldata);
50  virtual std::list<sensor> getList() const;
51 
52  /**
53  Sets the reference object we use for relative position measureing.
54  If not set or 0 then the origin is used.
55  This can be another robot an obstacle (light source) and such like
56  This must be called before first sense() or get() call.
57  */
58  virtual void setReference(Primitive* ref);
59 
60  private:
61  double maxDistance;
62  double exponent;
63  short dimensions;
64  Primitive* own;
65  Primitive* ref;
66  bool local_coords;
67  };
68 
69 
70 }
71 
72 #endif
Definition: sensor.h:46
Definition: sensor.h:46
RelativePositionSensor(double maxDistance, double exponent, short dimensions=X|Y|Z, bool local_coordinates=false)
Definition: relativepositionsensor.cpp:33
Definition: joint.h:41
virtual std::list< sensor > getList() const
returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded...
Definition: relativepositionsensor.cpp:56
Abstract class for sensors that can be plugged into a robot.
Definition: sensor.h:43
virtual bool sense(const GlobalData &globaldata)
performs sense action
Definition: relativepositionsensor.cpp:82
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
virtual int getSensorNumber() const
returns the number of sensors values produced by this sensor
Definition: relativepositionsensor.cpp:52
Data structure holding all essential global information.
Definition: globaldata.h:57
virtual void setReference(Primitive *ref)
Sets the reference object we use for relative position measureing.
Definition: relativepositionsensor.cpp:48
virtual void init(Primitive *own, Joint *joint=0)
initialises sensor with a body of robot and optionally with a joint.
Definition: relativepositionsensor.cpp:45
Class for relative (or absolute) position sensing.
Definition: relativepositionsensor.h:34
virtual ~RelativePositionSensor()
Definition: relativepositionsensor.h:44
Definition: sensor.h:46