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
torquesensor.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 __TORQUESENSOR_H
25 #define __TORQUESENSOR_H
26 
27 #include "sensor.h"
28 #include <ode-dbl/ode.h>
29 
30 namespace lpzrobots {
31 
32  class Joint;
33 
34  /** Class for sensing the torque that are applied to the joint by a motor.
35  The sensor value can be interpreted as a motor current.
36  */
37  class TorqueSensor : public Sensor {
38  public:
39 
40  /**
41  @param maxtorque at this torque the sensor value is 1.
42  @param avg number of averaging steps (def 1) (very noisy for universal joint)
43  */
44  TorqueSensor(double maxtorque = 1.0, int avg = 1);
45  virtual ~TorqueSensor();
46 
47  /** the primitive is not required here, set it to NULL
48  @param joint the joint on which to measure the torques.
49  */
50  virtual void init(Primitive* own, Joint* joint = 0);
51  virtual int getSensorNumber() const;
52 
53  virtual bool sense(const GlobalData& globaldata);
54  virtual std::list<sensor> getList() const;
55  virtual int get(sensor* sensors, int length) const; // we implement this one because easier with averaging
56 
57  private:
58  Joint* joint;
59  double maxtorque;
60  std::vector<sensor> values;
61  double tau; // for averaging
62  };
63 
64 
65 }
66 
67 #endif
Class for sensing the torque that are applied to the joint by a motor.
Definition: torquesensor.h:37
virtual ~TorqueSensor()
Definition: torquesensor.cpp:39
Definition: joint.h:41
double sensor
Definition: types.h:29
virtual void init(Primitive *own, Joint *joint=0)
the primitive is not required here, set it to NULL
Definition: torquesensor.cpp:42
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: torquesensor.cpp:55
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
Data structure holding all essential global information.
Definition: globaldata.h:57
TorqueSensor(double maxtorque=1.0, int avg=1)
Definition: torquesensor.cpp:33
virtual int getSensorNumber() const
returns the number of sensors values produced by this sensor
Definition: torquesensor.cpp:51
virtual std::list< sensor > getList() const
returns a list of sensor values (usually in the range [-1,1] ) This function should be overloaded...
Definition: torquesensor.cpp:98