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
OdeLogicalJoint::OdeLogicalJoint
OdeLogicalJoint()
Constructor.
Definition: OdeLogicalJoint.cpp:30
RobotConfig
Definition: RobotConfig.h:55
LogicalJoint
Abstract class for mapping from "physical" (simulated) joints in the model to control joints in the I...
Definition: LogicalJoint.h:33
PidFilter
Definition: pidfilter.h:33
OdeLogicalJoint::getVelocityRaw
double getVelocityRaw()
Get the velocity of an associated joint in unconverted units and sign.
Definition: OdeLogicalJoint.cpp:202
OdeLogicalJoint::controlModeChanged
void controlModeChanged(int cm)
Definition: OdeLogicalJoint.cpp:276
OdeLogicalJoint::setVelocityRaw
void setVelocityRaw(double target)
Set raw velocity of joint (in ODE units/sign).
Definition: OdeLogicalJoint.cpp:257
OdeLogicalJoint::at
OdeLogicalJoint * at(int index)
Access a nested control unit.
Definition: OdeLogicalJoint.cpp:64
OdeLogicalJoint::setTorque
void setTorque(double target)
Set the reference torque.
Definition: OdeLogicalJoint.cpp:182
OdeLogicalJoint::init
void init(const char *unit, const char *type, int index, int sign, RobotConfig &conf)
Initialize a regular control unit.
Definition: OdeLogicalJoint.cpp:85
LogicalJoint.h
OdeLogicalJoint::getSpeedSetpoint
double getSpeedSetpoint()
Get the current target velocity.
Definition: OdeLogicalJoint.h:100
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
OdeLogicalJoint::getAngle
double getAngle()
Get the angle of an associated joint, in ICUB units and sign.
Definition: OdeLogicalJoint.h:76
OdeLogicalJoint::setPosition
void setPosition(double target)
Drive towards an angle setpoint (in ICUB units/sign).
Definition: OdeLogicalJoint.cpp:236
RobotConfig.h
pidfilter.h
Header to implement the PID filter.
OdeLogicalJoint::nest
OdeLogicalJoint * nest(int len)
Create an array of nested control units.
Definition: OdeLogicalJoint.cpp:54
OdeLogicalJoint::getTorque
double getTorque()
this is just a fake torque interface for now
Definition: OdeLogicalJoint.cpp:175
OdeLogicalJoint::setVelocity
void setVelocity(double target)
Set velocity of joint (in ICUB units/sign).
Definition: OdeLogicalJoint.cpp:247
OdeLogicalJoint
Convenience class for mapping from physical ODE joints in the model to control joints in the ICUB spe...
Definition: OdeLogicalJoint.h:40
OdeLogicalJoint::setControlParameters
void setControlParameters(double vel, double acc)
Set velocity and acceleration control parameters.
Definition: OdeLogicalJoint.cpp:221
OdeLogicalJoint::isValid
virtual bool isValid()
Definition: OdeLogicalJoint.h:129
OdeLogicalJoint::getVelocity
double getVelocity()
Get the angular velocity of an associated joint, in ICUB units and sign.
Definition: OdeLogicalJoint.h:83
OdeLogicalJoint::getAngleRaw
double getAngleRaw()
Get the angle of an associated joint in unconverted units and sign.
Definition: OdeLogicalJoint.cpp:186
OdeLogicalJoint::~OdeLogicalJoint
virtual ~OdeLogicalJoint()
Destructor.
Definition: OdeLogicalJoint.cpp:47