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