iCub-main
OdeLogicalJoint.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: Vadim Tikhanoff, Paul Fitzpatrick
6 * email: vadim.tikhanoff@iit.it, 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_ODELOGICALJOINT_INC
22 #define ICUBSIMULATION_ODELOGICALJOINT_INC
23 
24 #include <ode/ode.h>
25 
26 #include <string>
27 
28 #include "pidfilter.h"
29 
30 #include "LogicalJoint.h"
31 
32 #include "RobotConfig.h"
33 
40 class OdeLogicalJoint : public LogicalJoint {
41 public:
46 
50  virtual ~OdeLogicalJoint();
51 
56  OdeLogicalJoint *nest(int len);
57 
61  OdeLogicalJoint *at(int index);
62 
66  void init(const char *unit, const char *type, int index, int sign, RobotConfig &conf);
67 
71  void init(OdeLogicalJoint& left, OdeLogicalJoint& right, OdeLogicalJoint& peer, int sgn);
72 
76  double getAngle() {
77  return getAngleRaw()*sign;
78  }
79 
83  double getVelocity() {
84  return getVelocityRaw()*sign;
85  }
86 
90  double getAngleRaw();
91 
95  double getVelocityRaw();
96 
100  double getSpeedSetpoint() {
101  return speedSetpoint;
102  }
103 
104  //test for torque
105  double getTorque();
106 
107  void setTorque(double target);
108 
112  void setControlParameters(double vel, double acc);
113 
117  void setPosition(double target);
118 
122  void setVelocity(double target);
123 
127  void setVelocityRaw(double target);
128 
129  virtual bool isValid() {
130  return (number != -1) || (verge != 0);
131  }
132 
133  void controlModeChanged(int cm);
134 
135 private:
136  int number;
137  std::string unit;
138  dJointID *joint;
139  dJointFeedback *feedback;
140  dVector3 axis;
141  dReal *speed;
142  dReal *torque;
143  double speedSetpoint;
144  bool hinged;
145  int universal;
146  int sign;
147  OdeLogicalJoint *sub;
148  int subLength;
149  bool active;
150  double vel;
151  double acc;
152  PidFilter filter;
153 
154  double dryFriction;
155  double maxTorque;
156 
157  OdeLogicalJoint *left, *right, *peer;
158  int verge;
159 };
160 
161 
162 #endif
Convenience class for mapping from physical ODE joints in the model to control joints in the ICUB spe...
OdeLogicalJoint * nest(int len)
Create an array of nested control units.
void setVelocity(double target)
Set velocity of joint (in ICUB units/sign).
double getSpeedSetpoint()
Get the current target velocity.
OdeLogicalJoint()
Constructor.
void setVelocityRaw(double target)
Set raw velocity of joint (in ODE units/sign).
void setPosition(double target)
Drive towards an angle setpoint (in ICUB units/sign).
void setTorque(double target)
Set the reference torque.
void init(const char *unit, const char *type, int index, int sign, RobotConfig &conf)
Initialize a regular control unit.
Header to implement the PID filter.
double getAngleRaw()
Get the angle of an associated joint in unconverted units and sign.
virtual ~OdeLogicalJoint()
Destructor.
double getVelocity()
Get the angular velocity of an associated joint, in ICUB units and sign.
Abstract class for mapping from "physical" (simulated) joints in the model to control joints in the I...
Definition: LogicalJoint.h:33
OdeLogicalJoint * at(int index)
Access a nested control unit.
double getTorque()
this is just a fake torque interface for now
double getVelocityRaw()
Get the velocity of an associated joint in unconverted units and sign.
double getAngle()
Get the angle of an associated joint, in ICUB units and sign.
void setControlParameters(double vel, double acc)
Set velocity and acceleration control parameters.
void controlModeChanged(int cm)
virtual bool isValid()