YARP
Yet Another Robot Platform
IAmplifierControl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_DEV_IAMPLIFIERCONTROL_H
11 #define YARP_DEV_IAMPLIFIERCONTROL_H
12 
13 #include <yarp/os/Vocab.h>
14 #include <yarp/dev/api.h>
15 
18 namespace yarp
19 {
20  namespace dev
21  {
22  class IAmplifierControlRaw;
23  class IAmplifierControl;
24  }
25 }
26 
33 {
34 public:
38  virtual ~IAmplifierControl() {}
39 
45  virtual bool enableAmp(int j)=0;
46 
51  virtual bool disableAmp(int j)=0;
52 
53  /* Get the status of the amplifiers, coded in a 32 bits integer for
54  * each amplifier (at the moment contains only the fault, it will be
55  * expanded in the future).
56  * @param st pointer to storage
57  * @return true in good luck, false otherwise.
58  */
59  virtual bool getAmpStatus(int *st)=0;
60 
61  /* Get the status of a single amplifier, coded in a 32 bits integer
62  * @param j joint number
63  * @param st storage for return value
64  * @return true/false success failure.
65  */
66  virtual bool getAmpStatus(int j, int *v)=0;
67 
68  /* Read the electric current going to all motors.
69  * @param vals pointer to storage for the output values
70  * @return hopefully true, false in bad luck.
71  */
72  virtual bool getCurrents(double *vals)=0;
73 
74  /* Read the electric current going to a given motor.
75  * @param j motor number
76  * @param val pointer to storage for the output value
77  * @return probably true, might return false in bad times
78  */
79  virtual bool getCurrent(int j, double *val)=0;
80 
88  virtual bool getMaxCurrent(int j, double *v)=0;
89 
90  /* Set the maximum electric current going to a given motor.
91  * Exceeding this value will trigger instantaneous hardware fault.
92  * @param j motor number
93  * @param v the new value
94  * @return probably true, might return false in bad times
95  */
96  virtual bool setMaxCurrent(int j, double v)=0;
97 
98  /* Get the nominal current which can be kept for an indefinite amount of time
99  * without harming the motor. This value is specific for each motor and it is typically
100  * found in its data-sheet. The units are Ampere.
101  * This value and the peak current may be used by the firmware to configure
102  * an I2T filter.
103  * @param j joint number
104  * @param val storage for return value. [Ampere]
105  * @return true/false success failure.
106  */
107  virtual bool getNominalCurrent(int m, double *val) {return false;};
108 
109  /* Set the nominal current which can be kept for an indefinite amount of time
110  * without harming the motor. This value is specific for each motor and it is typically
111  * found in its data-sheet. The units are Ampere.
112  * This value and the peak current may be used by the firmware to configure
113  * an I2T filter.
114  * @param j joint number
115  * @param val storage for return value. [Ampere]
116  * @return true/false success failure.
117  */
118  virtual bool setNominalCurrent(int m, const double val) { return false; };
119 
120  /* Get the peak current which causes damage to the motor if maintained
121  * for a long amount of time.
122  * The value is often found in the motor data-sheet, units are Ampere.
123  * This value and the nominal current may be used by the firmware to configure
124  * an I2T filter.
125  * @param j joint number
126  * @param val storage for return value. [Ampere]
127  * @return true/false success failure.
128  */
129  virtual bool getPeakCurrent(int m, double *val) {return false;};
130 
131  /* Set the peak current. This value which causes damage to the motor if maintained
132  * for a long amount of time.
133  * The value is often found in the motor data-sheet, units are Ampere.
134  * This value and the nominal current may be used by the firmware to configure
135  * an I2T filter.
136  * @param j joint number
137  * @param val storage for return value. [Ampere]
138  * @return true/false success failure.
139  */
140  virtual bool setPeakCurrent(int m, const double val) {return false;};
141 
142  /* Get the the current PWM value used to control the motor.
143  * The units are firmware dependent, either machine units or percentage.
144  * @param j joint number
145  * @param val filled with PWM value.
146  * @return true/false success failure.
147  */
148  virtual bool getPWM(int j, double* val) {return false;};
149 
150  /* Get the PWM limit for the given motor.
151  * The units are firmware dependent, either machine units or percentage.
152  * @param j joint number
153  * @param val filled with PWM limit value.
154  * @return true/false success failure.
155  */
156  virtual bool getPWMLimit(int j, double* val) {return false;};
157 
158  /* Set the PWM limit for the given motor.
159  * The units are firmware dependent, either machine units or percentage.
160  * @param j joint number
161  * @param val new value for the PWM limit.
162  * @return true/false success failure.
163  */
164  virtual bool setPWMLimit(int j, const double val) {return false;};
165 
166  /* Get the power source voltage for the given motor in Volt.
167  * @param j joint number
168  * @param val filled with return value.
169  * @return true/false success failure.
170  */
171  virtual bool getPowerSupplyVoltage(int j, double* val) {return false;};
172 };
173 
179 {
180 public:
185 
191  virtual bool enableAmpRaw(int j)=0;
192 
197  virtual bool disableAmpRaw(int j)=0;
198 
199  /* Get the status of the amplifiers, coded in a 32 bits integer for
200  * each amplifier (at the moment contains only the fault, it will be
201  * expanded in the future).
202  * @param st pointer to storage
203  * @return true/false success failure.
204  */
205  virtual bool getAmpStatusRaw(int *st)=0;
206 
207  /* Get the status of a single amplifier, coded in a 32 bits integer
208  * @param j joint number
209  * @param st storage for return value
210  * @return true/false success failure.
211  */
212  virtual bool getAmpStatusRaw(int j, int *st)=0;
213 
214  /* Read the electric current going to all motors.
215  * @param vals pointer to storage for the output values
216  * @return hopefully true, false in bad luck.
217  */
218  virtual bool getCurrentsRaw(double *vals)=0;
219 
220  /* Read the electric current going to a given motor.
221  * @param j motor number
222  * @param val pointer to storage for the output value
223  * @return probably true, might return false in bad times
224  */
225  virtual bool getCurrentRaw(int j, double *val)=0;
226 
227  /* Set the maximum electric current going to a given motor.
228  * Exceeding this value will trigger instantaneous hardware fault.
229  * @param j motor number
230  * @param v the new value
231  * @return probably true, might return false in bad times
232  */
233  virtual bool setMaxCurrentRaw(int j, double v)=0;
234 
242  virtual bool getMaxCurrentRaw(int j, double *v)=0;
243 
244  /* Get the nominal current which can be kept for an indefinite amount of time
245  * without harming the motor. This value is specific for each motor and it is typically
246  * found in its data-sheet. The units are Ampere.
247  * This value and the peak current may be used by the firmware to configure
248  * an I2T filter.
249  * @param j joint number
250  * @param val storage for return value. [Ampere]
251  * @return true/false success failure.
252  */
253  virtual bool getNominalCurrentRaw(int m, double *val) {return false;};
254 
255  /* Set the nominal current which can be kept for an indefinite amount of time
256  * without harming the motor. This value is specific for each motor and it is typically
257  * found in its data-sheet. The units are Ampere.
258  * This value and the peak current may be used by the firmware to configure
259  * an I2T filter.
260  * @param j joint number
261  * @param val storage for return value. [Ampere]
262  * @return true/false success failure.
263  */
264  virtual bool setNominalCurrentRaw(int m, const double val) { return false; };
265 
266  /* Get the peak current which causes damage to the motor if maintained
267  * for a long amount of time.
268  * The value is often found in the motor data-sheet, units are Ampere.
269  * This value and the nominal current may be used by the firmware to configure
270  * an I2T filter.
271  * @param j joint number
272  * @param val storage for return value. [Ampere]
273  * @return true/false success failure.
274  */
275  virtual bool getPeakCurrentRaw(int m, double *val) {return false;};
276 
277  /* Set the peak current. This value which causes damage to the motor if maintained
278  * for a long amount of time.
279  * The value is often found in the motor data-sheet, units are Ampere.
280  * This value and the nominal current may be used by the firmware to configure
281  * an I2T filter.
282  * @param j joint number
283  * @param val storage for return value. [Ampere]
284  * @return true/false success failure.
285  */
286  virtual bool setPeakCurrentRaw(int m, const double val) {return false;};
287 
288  /* Get the current PWM value used to control the motor.
289  * The units are firmware dependent, either machine units or percentage.
290  * @param j joint number
291  * @param val filled with PWM value.
292  * @return true/false success failure.
293  */
294  virtual bool getPWMRaw(int j, double* val) {return false;};
295 
296  /* Get the PWM limit for the given motor.
297  * The units are firmware dependent, either machine units or percentage.
298  * @param j joint number
299  * @param val filled with PWM limit value.
300  * @return true/false success failure.
301  */
302  virtual bool getPWMLimitRaw(int j, double* val) {return false;};
303 
304  /* Set the PWM limit for the given motor.
305  * The units are firmware dependent, either machine units or percentage.
306  * @param j joint number
307  * @param val new value for the PWM limit.
308  * @return true/false success failure.
309  */
310  virtual bool setPWMLimitRaw(int j, const double val) {return false;};
311 
312  /* Get the power source voltage for the given motor in Volt.
313  * @param j joint number
314  * @param val filled with return value. [Volt]
315  * @return true/false success failure.
316  */
317  virtual bool getPowerSupplyVoltageRaw(int j, double* val) {return false;};
318 };
319 
320 // interface IAmplifierControl sets/gets
333 
334 #endif // YARP_DEV_IAMPLIFIERCONTROL_H
VOCAB_AMP_PEAK_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_PEAK_CURRENT
Definition: IAmplifierControl.h:329
yarp::dev::IAmplifierControlRaw::enableAmpRaw
virtual bool enableAmpRaw(int j)=0
Enable the amplifier on a specific joint.
yarp::dev::IAmplifierControl::setMaxCurrent
virtual bool setMaxCurrent(int j, double v)=0
yarp::os::createVocab
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
VOCAB_AMP_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_CURRENT
Definition: IAmplifierControl.h:325
VOCAB_AMP_VOLTAGE_SUPPLY
constexpr yarp::conf::vocab32_t VOCAB_AMP_VOLTAGE_SUPPLY
Definition: IAmplifierControl.h:332
yarp::dev::IAmplifierControl::enableAmp
virtual bool enableAmp(int j)=0
Enable the amplifier on a specific joint.
VOCAB_AMP_PWM_LIMIT
constexpr yarp::conf::vocab32_t VOCAB_AMP_PWM_LIMIT
Definition: IAmplifierControl.h:331
VOCAB_AMP_STATUS
constexpr yarp::conf::vocab32_t VOCAB_AMP_STATUS
Definition: IAmplifierControl.h:323
yarp::dev::IAmplifierControlRaw::setNominalCurrentRaw
virtual bool setNominalCurrentRaw(int m, const double val)
Definition: IAmplifierControl.h:264
yarp::dev::IAmplifierControlRaw::setPWMLimitRaw
virtual bool setPWMLimitRaw(int j, const double val)
Definition: IAmplifierControl.h:310
VOCAB_AMP_NOMINAL_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_NOMINAL_CURRENT
Definition: IAmplifierControl.h:328
yarp::dev::IAmplifierControl::getAmpStatus
virtual bool getAmpStatus(int j, int *v)=0
VOCAB_AMP_MAXCURRENT
constexpr yarp::conf::vocab32_t VOCAB_AMP_MAXCURRENT
Definition: IAmplifierControl.h:327
yarp::dev::IAmplifierControlRaw::getAmpStatusRaw
virtual bool getAmpStatusRaw(int *st)=0
VOCAB_AMP_DISABLE
constexpr yarp::conf::vocab32_t VOCAB_AMP_DISABLE
Definition: IAmplifierControl.h:322
VOCAB_AMP_CURRENTS
constexpr yarp::conf::vocab32_t VOCAB_AMP_CURRENTS
Definition: IAmplifierControl.h:326
yarp::dev::IAmplifierControl::getAmpStatus
virtual bool getAmpStatus(int *st)=0
yarp::dev::IAmplifierControlRaw::getCurrentsRaw
virtual bool getCurrentsRaw(double *vals)=0
yarp::dev::IAmplifierControl::getPeakCurrent
virtual bool getPeakCurrent(int m, double *val)
Definition: IAmplifierControl.h:129
yarp::dev::IAmplifierControl::getCurrent
virtual bool getCurrent(int j, double *val)=0
yarp::dev::IAmplifierControl::setPWMLimit
virtual bool setPWMLimit(int j, const double val)
Definition: IAmplifierControl.h:164
yarp::dev::IAmplifierControl::~IAmplifierControl
virtual ~IAmplifierControl()
Destructor.
Definition: IAmplifierControl.h:38
yarp::dev::IAmplifierControl::getPWMLimit
virtual bool getPWMLimit(int j, double *val)
Definition: IAmplifierControl.h:156
yarp::dev::IAmplifierControl::getPWM
virtual bool getPWM(int j, double *val)
Definition: IAmplifierControl.h:148
VOCAB_AMP_ENABLE
constexpr yarp::conf::vocab32_t VOCAB_AMP_ENABLE
Definition: IAmplifierControl.h:321
yarp::dev::IAmplifierControl::setPeakCurrent
virtual bool setPeakCurrent(int m, const double val)
Definition: IAmplifierControl.h:140
yarp::dev::IAmplifierControl::getPowerSupplyVoltage
virtual bool getPowerSupplyVoltage(int j, double *val)
Definition: IAmplifierControl.h:171
yarp::dev::IAmplifierControlRaw::getMaxCurrentRaw
virtual bool getMaxCurrentRaw(int j, double *v)=0
Returns the maximum electric current allowed for a given motor.
VOCAB_AMP_PWM
constexpr yarp::conf::vocab32_t VOCAB_AMP_PWM
Definition: IAmplifierControl.h:330
yarp::dev::IAmplifierControl::getNominalCurrent
virtual bool getNominalCurrent(int m, double *val)
Definition: IAmplifierControl.h:107
yarp::dev::IAmplifierControlRaw::getPowerSupplyVoltageRaw
virtual bool getPowerSupplyVoltageRaw(int j, double *val)
Definition: IAmplifierControl.h:317
yarp::dev::IAmplifierControlRaw::getAmpStatusRaw
virtual bool getAmpStatusRaw(int j, int *st)=0
yarp::dev::IAmplifierControl::disableAmp
virtual bool disableAmp(int j)=0
Disable the amplifier on a specific joint.
YARP_dev_API
#define YARP_dev_API
Definition: api.h:19
yarp::dev::IAmplifierControl::getMaxCurrent
virtual bool getMaxCurrent(int j, double *v)=0
Returns the maximum electric current allowed for a given motor.
yarp::dev::IAmplifierControl
Interface for control devices, amplifier commands.
Definition: IAmplifierControl.h:33
yarp::dev::IAmplifierControl::setNominalCurrent
virtual bool setNominalCurrent(int m, const double val)
Definition: IAmplifierControl.h:118
yarp::dev::IAmplifierControlRaw::getPWMRaw
virtual bool getPWMRaw(int j, double *val)
Definition: IAmplifierControl.h:294
VOCAB_AMP_STATUS_SINGLE
constexpr yarp::conf::vocab32_t VOCAB_AMP_STATUS_SINGLE
Definition: IAmplifierControl.h:324
yarp::dev::IAmplifierControlRaw::getCurrentRaw
virtual bool getCurrentRaw(int j, double *val)=0
yarp::dev::IAmplifierControlRaw::setPeakCurrentRaw
virtual bool setPeakCurrentRaw(int m, const double val)
Definition: IAmplifierControl.h:286
yarp::dev::IAmplifierControl::getCurrents
virtual bool getCurrents(double *vals)=0
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::dev::IAmplifierControlRaw::getPWMLimitRaw
virtual bool getPWMLimitRaw(int j, double *val)
Definition: IAmplifierControl.h:302
yarp::conf::vocab32_t
std::int32_t vocab32_t
Definition: numeric.h:52
Vocab.h
yarp::dev::IAmplifierControlRaw::disableAmpRaw
virtual bool disableAmpRaw(int j)=0
Disable the amplifier on a specific joint.
yarp::dev::IAmplifierControlRaw::getPeakCurrentRaw
virtual bool getPeakCurrentRaw(int m, double *val)
Definition: IAmplifierControl.h:275
yarp::dev::IAmplifierControlRaw
Interface for control devices, amplifier commands.
Definition: IAmplifierControl.h:179
yarp::dev::IAmplifierControlRaw::getNominalCurrentRaw
virtual bool getNominalCurrentRaw(int m, double *val)
Definition: IAmplifierControl.h:253
yarp::dev::IAmplifierControlRaw::~IAmplifierControlRaw
virtual ~IAmplifierControlRaw()
Destructor.
Definition: IAmplifierControl.h:184
api.h
yarp::dev::IAmplifierControlRaw::setMaxCurrentRaw
virtual bool setMaxCurrentRaw(int j, double v)=0