YARP
Yet Another Robot Platform
ITorqueControl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 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
virtual bool getMotorTorqueParams(int j, yarp::dev::MotorTorqueParameters *params)
Get a subset of motor parameters (bemf, ktau etc) useful for torque control.
#define YARP_dev_API
Definition: api.h:19
constexpr yarp::conf::vocab32_t VOCAB_RANGE
virtual bool setMotorTorqueParamsRaw(int j, const yarp::dev::MotorTorqueParameters params)
Set the motor parameters.
Interface for control boards implementing torque control.
virtual bool setRefTorques(const int n_joint, const int *joints, const double *t)
Set new torque reference for a subset of joints.
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECTS
constexpr yarp::conf::vocab32_t VOCAB_IMP_PARAM
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT_GROUP
virtual bool getMotorTorqueParamsRaw(int j, yarp::dev::MotorTorqueParameters *params)
Get the motor parameters.
std::int32_t vocab32_t
Definition: numeric.h:52
constexpr yarp::conf::vocab32_t VOCAB_MOTOR_PARAMS
The main, catch-all namespace for YARP.
Definition: numeric.h:47
constexpr yarp::conf::vocab32_t VOCAB_RANGES
constexpr yarp::conf::vocab32_t VOCAB_BEMF
constexpr yarp::conf::vocab32_t VOCAB_TRQ
constexpr yarp::conf::vocab32_t VOCAB_TORQUES_DIRECT
float t
virtual ~ITorqueControlRaw()
Destructor.
constexpr yarp::conf::vocab32_t VOCAB_TORQUE_MODE
virtual bool setMotorTorqueParams(int j, const yarp::dev::MotorTorqueParameters params)
Set a subset of motor parameters (bemf, ktau etc) useful for torque control.
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
virtual ~ITorqueControl()
Destructor.
constexpr yarp::conf::vocab32_t VOCAB_TORQUE
Interface for control boards implementing torque control.
constexpr yarp::conf::vocab32_t VOCAB_IMP_OFFSET
constexpr yarp::conf::vocab32_t VOCAB_TRQS
virtual bool setRefTorquesRaw(const int n_joint, const int *joints, const double *t)
Set new torque reference for a subset of joints.