iCub-main
FakeLogicalJoint.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4 * Copyright (C) 2010 RobotCub Consortium, European Commission FP6 Project IST-004370
5 * Author: Paul Fitzpatrick
6 * email: paulfitz@alum.mit.edu
7 * website: www.robotcub.org
8 * Permission is granted to copy, distribute, and/or modify this program
9 * under the terms of the GNU General Public License, version 2 or any
10 * later version published by the Free Software Foundation.
11 *
12 * A copy of the license can be found at
13 * http://www.robotcub.org/icub/license/gpl.txt
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18 * Public License for more details
19 */
20 
21 #ifndef ICUBSIMULATION_FAKELOGICALJOINT_INC
22 #define ICUBSIMULATION_FAKELOGICALJOINT_INC
23 
24 #include "LogicalJoint.h"
25 
26 #include <yarp/os/Time.h>
27 
29 private:
30  double angle;
31  double vel;
32  double last;
33  double torque;
34 public:
36  last = yarp::os::Time::now();
37  angle = vel = torque = 0;
38  }
39 
40  virtual double getAngle() {
41  update();
42  return angle;
43  }
44 
45  virtual double getVelocity() {
46  update();
47  return vel;
48  }
49 
50  virtual void setControlParameters(double vel, double acc) {
51  this->vel = vel;
52  }
53 
54  virtual void setPosition(double target) {
55  update();
56  vel = (target-angle)*5;
57  }
58 
59  virtual void setVelocity(double target) {
60  update();
61  vel = target;
62  }
63 
64  virtual bool isValid() {
65  return true;
66  }
67 
68 
69  virtual double getTorque(){
70  return true;
71  }
72 
73  virtual void setTorque(double target){
74  torque = target;
75  }
76 
77  virtual void controlModeChanged(int cm){}
78 
79  void update() {
80  double now = yarp::os::Time::now();
81  angle += vel*(now-last);
82  last = now;
83  }
84 
85 };
86 
87 
88 #endif
virtual double getTorque()
this is just a fake torque interface for now
virtual void setPosition(double target)
Drive towards an angle setpoint (in ICUB units/sign).
virtual double getAngle()
Get the angle of an associated joint, in ICUB units and sign.
virtual void setVelocity(double target)
Set velocity of joint (in ICUB units/sign).
virtual double getVelocity()
Get the angular velocity of an associated joint, in ICUB units and sign.
virtual void setTorque(double target)
Set the reference torque.
virtual void controlModeChanged(int cm)
virtual bool isValid()
virtual void setControlParameters(double vel, double acc)
Set velocity and acceleration control parameters.
Abstract class for mapping from "physical" (simulated) joints in the model to control joints in the I...
Definition: LogicalJoint.h:33
_3f_vect_t acc
Definition: dataTypes.h:1