YARP
Yet Another Robot Platform
ITorqueControl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_DEV_ITORQUECONTROL_H
10 #define YARP_DEV_ITORQUECONTROL_H
11 
12 #include <yarp/os/Vocab.h>
13 #include <yarp/dev/api.h>
14 
15 namespace yarp {
16  namespace dev {
17  class ITorqueControlRaw;
18  class ITorqueControl;
19  class MotorTorqueParameters;
20  }
21 }
22 
24 {
25  public:
26  double bemf;
27  double bemf_scale;
28  double ktau;
29  double ktau_scale;
30  MotorTorqueParameters() : bemf(0), bemf_scale(0), ktau(0), ktau_scale(0) {};
31 };
32 
39 {
40 public:
44  virtual ~ITorqueControl() {}
45 
51  virtual bool getAxes(int *ax) = 0;
52 
58  virtual bool getRefTorques(double *t)=0;
59 
66  virtual bool getRefTorque(int j, double *t)=0;
67 
72  virtual bool setRefTorques(const double *t)=0;
73 
79  virtual bool setRefTorque(int j, double t)=0;
80 
86  virtual bool setRefTorques(const int n_joint, const int *joints, const double *t) {return false;} // this function has a default implementation to keep backward compatibility with existing devices
87 
93  virtual bool getMotorTorqueParams(int j, yarp::dev::MotorTorqueParameters *params) {return false;}
94 
100  virtual bool setMotorTorqueParams(int j, const yarp::dev::MotorTorqueParameters params) {return false;}
101 
108  virtual bool getTorque(int j, double *t)=0;
109 
115  virtual bool getTorques(double *t)=0;
116 
123  virtual bool getTorqueRange(int j, double *min, double *max)=0;
124 
130  virtual bool getTorqueRanges(double *min, double *max)=0;
131 };
132 
139 {
140 public:
144  virtual ~ITorqueControlRaw() {}
145 
152  virtual bool getAxes(int *ax) = 0;
153 
160  virtual bool getTorqueRaw(int j, double *t)=0;
161 
167  virtual bool getTorquesRaw(double *t)=0;
168 
175  virtual bool getTorqueRangeRaw(int j, double *min, double *max)=0;
176 
182  virtual bool getTorqueRangesRaw(double *min, double *max)=0;
183 
188  virtual bool setRefTorquesRaw(const double *t)=0;
189 
195  virtual bool setRefTorqueRaw(int j, double t)=0;
196 
202  virtual bool setRefTorquesRaw(const int n_joint, const int *joints, const double *t) {return false;} // this function has a default implementation to keep backward compatibility with existing devices
203 
209  virtual bool getRefTorquesRaw(double *t)=0;
210 
217  virtual bool getRefTorqueRaw(int j, double *t)=0;
218 
224  virtual bool getMotorTorqueParamsRaw(int j, yarp::dev::MotorTorqueParameters *params) {return false;}
225 
231  virtual bool setMotorTorqueParamsRaw(int j, const yarp::dev::MotorTorqueParameters params) {return false;}
232 };
233 
244 constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECTS = yarp::os::createVocab('d', 't', 'q', 's'); //This implements the setRefTorques for the whole part
245 constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT = yarp::os::createVocab('d', 't', 'q'); //This implements the setRefTorque for a single joint
246 constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT_GROUP = yarp::os::createVocab('d', 't', 'q', 'g'); //This implements the setRefTorques with joint list
247 
248 #endif // YARP_DEV_ITORQUECONTROL_H
yarp::dev::ITorqueControl::setRefTorques
virtual bool setRefTorques(const int n_joint, const int *joints, const double *t)
Set new torque reference for a subset of joints.
Definition: ITorqueControl.h:86
yarp::dev::ITorqueControlRaw::setRefTorqueRaw
virtual bool setRefTorqueRaw(int j, double t)=0
Set the reference value of the torque for a given joint.
yarp::dev::MotorTorqueParameters::bemf
double bemf
Definition: ITorqueControl.h:26
yarp::os::createVocab
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
yarp::dev::ITorqueControlRaw::setMotorTorqueParamsRaw
virtual bool setMotorTorqueParamsRaw(int j, const yarp::dev::MotorTorqueParameters params)
Set the motor parameters.
Definition: ITorqueControl.h:231
yarp::dev::MotorTorqueParameters::ktau_scale
double ktau_scale
Definition: ITorqueControl.h:29
t
float t
Definition: FfmpegWriter.cpp:74
yarp::dev::ITorqueControlRaw::getTorqueRaw
virtual bool getTorqueRaw(int j, double *t)=0
Get the value of the torque on a given joint (this is the feedback if you have a torque sensor).
yarp::dev::MotorTorqueParameters
Definition: ITorqueControl.h:24
yarp::dev::ITorqueControlRaw::getMotorTorqueParamsRaw
virtual bool getMotorTorqueParamsRaw(int j, yarp::dev::MotorTorqueParameters *params)
Get the motor parameters.
Definition: ITorqueControl.h:224
VOCAB_TORQUES_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT
Definition: ITorqueControl.h:245
yarp::dev::ITorqueControlRaw
Interface for control boards implementing torque control.
Definition: ITorqueControl.h:139
VOCAB_TORQUES_DIRECTS
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECTS
Definition: ITorqueControl.h:244
yarp::dev::ITorqueControl::getTorque
virtual bool getTorque(int j, double *t)=0
Get the value of the torque on a given joint (this is the feedback if you have a torque sensor).
VOCAB_RANGES
constexpr yarp::conf::vocab32_t VOCAB_RANGES
Definition: ITorqueControl.h:240
yarp::dev::ITorqueControlRaw::getTorqueRangeRaw
virtual bool getTorqueRangeRaw(int j, double *min, double *max)=0
Get the full scale of the torque sensor of a given joint.
yarp::dev::ITorqueControl::getAxes
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
VOCAB_BEMF
constexpr yarp::conf::vocab32_t VOCAB_BEMF
Definition: ITorqueControl.h:238
VOCAB_TRQ
constexpr yarp::conf::vocab32_t VOCAB_TRQ
Definition: ITorqueControl.h:237
yarp::dev::ITorqueControlRaw::getAxes
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
yarp::dev::ITorqueControlRaw::getRefTorquesRaw
virtual bool getRefTorquesRaw(double *t)=0
Get the reference value of the torque for all joints.
yarp::dev::MotorTorqueParameters::ktau
double ktau
Definition: ITorqueControl.h:28
VOCAB_TORQUES_DIRECT_GROUP
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT_GROUP
Definition: ITorqueControl.h:246
VOCAB_TRQS
constexpr yarp::conf::vocab32_t VOCAB_TRQS
Definition: ITorqueControl.h:236
yarp::dev::ITorqueControlRaw::setRefTorquesRaw
virtual bool setRefTorquesRaw(const int n_joint, const int *joints, const double *t)
Set new torque reference for a subset of joints.
Definition: ITorqueControl.h:202
yarp::dev::ITorqueControl::getTorqueRanges
virtual bool getTorqueRanges(double *min, double *max)=0
Get the full scale of the torque sensors of all joints.
yarp::dev::MotorTorqueParameters::MotorTorqueParameters
MotorTorqueParameters()
Definition: ITorqueControl.h:30
yarp::dev::ITorqueControl::getRefTorques
virtual bool getRefTorques(double *t)=0
Get the reference value of the torque for all joints.
yarp::dev::ITorqueControl::setRefTorques
virtual bool setRefTorques(const double *t)=0
Set the reference value of the torque for all joints.
VOCAB_TORQUE_MODE
constexpr yarp::conf::vocab32_t VOCAB_TORQUE_MODE
Definition: ITorqueControl.h:235
VOCAB_RANGE
constexpr yarp::conf::vocab32_t VOCAB_RANGE
Definition: ITorqueControl.h:241
yarp::dev::ITorqueControlRaw::getTorquesRaw
virtual bool getTorquesRaw(double *t)=0
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
VOCAB_IMP_PARAM
constexpr yarp::conf::vocab32_t VOCAB_IMP_PARAM
Definition: ITorqueControl.h:242
yarp::dev::ITorqueControl::setMotorTorqueParams
virtual bool setMotorTorqueParams(int j, const yarp::dev::MotorTorqueParameters params)
Set a subset of motor parameters (bemf, ktau etc) useful for torque control.
Definition: ITorqueControl.h:100
yarp::dev::ITorqueControl::~ITorqueControl
virtual ~ITorqueControl()
Destructor.
Definition: ITorqueControl.h:44
yarp::dev::ITorqueControlRaw::~ITorqueControlRaw
virtual ~ITorqueControlRaw()
Destructor.
Definition: ITorqueControl.h:144
yarp::dev::ITorqueControl::getTorques
virtual bool getTorques(double *t)=0
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
VOCAB_MOTOR_PARAMS
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_PARAMS
Definition: ITorqueControl.h:239
YARP_dev_API
#define YARP_dev_API
Definition: api.h:19
yarp::dev::MotorTorqueParameters::bemf_scale
double bemf_scale
Definition: ITorqueControl.h:27
VOCAB_TORQUE
constexpr yarp::conf::vocab32_t VOCAB_TORQUE
Definition: ITorqueControl.h:234
VOCAB_IMP_OFFSET
constexpr yarp::conf::vocab32_t VOCAB_IMP_OFFSET
Definition: ITorqueControl.h:243
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::conf::vocab32_t
std::int32_t vocab32_t
Definition: numeric.h:52
Vocab.h
yarp::dev::ITorqueControlRaw::getTorqueRangesRaw
virtual bool getTorqueRangesRaw(double *min, double *max)=0
Get the full scale of the torque sensors of all joints.
yarp::dev::ITorqueControlRaw::setRefTorquesRaw
virtual bool setRefTorquesRaw(const double *t)=0
Set the reference value of the torque for all joints.
yarp::dev::ITorqueControl
Interface for control boards implementing torque control.
Definition: ITorqueControl.h:39
yarp::dev::ITorqueControl::setRefTorque
virtual bool setRefTorque(int j, double t)=0
Set the reference value of the torque for a given joint.
yarp::dev::ITorqueControlRaw::getRefTorqueRaw
virtual bool getRefTorqueRaw(int j, double *t)=0
Set the reference value of the torque for a given joint.
api.h
yarp::dev::ITorqueControl::getRefTorque
virtual bool getRefTorque(int j, double *t)=0
Get the reference value of the torque for a given joint.
yarp::dev::ITorqueControl::getMotorTorqueParams
virtual bool getMotorTorqueParams(int j, yarp::dev::MotorTorqueParameters *params)
Get a subset of motor parameters (bemf, ktau etc) useful for torque control.
Definition: ITorqueControl.h:93
yarp::dev::ITorqueControl::getTorqueRange
virtual bool getTorqueRange(int j, double *min, double *max)=0
Get the full scale of the torque sensor of a given joint.