YARP
Yet Another Robot Platform
ImplementAmplifierControl.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_IMPLEMENTAMPLIFIERCONTROL_H
10 #define YARP_DEV_IMPLEMENTAMPLIFIERCONTROL_H
11 
13 #include <yarp/dev/api.h>
14 
15 namespace yarp
16 {
17  namespace dev
18  {
19  class ImplementAmplifierControl;
20  }
21 }
22 
24 {
25 protected:
27  void *helper;
28  double *dTemp;
29  int *iTemp;
30 
39  bool initialize (int size, const int *amap, const double *enc, const double *zos, const double *ampereFactor=NULL, const double *voltFactor=NULL);
40 
45  bool uninitialize ();
46 
47 public:
48  /* Constructor.
49  * @param y is the pointer to the class instance inheriting from this
50  * implementation.
51  */
53 
58 
64  bool enableAmp(int j) override;
65 
70  bool disableAmp(int j) override;
71 
72  /* Get the status of the amplifiers, coded in a 32 bits integer for
73  * each amplifier (at the moment contains only the fault, it will be
74  * expanded in the future).
75  * @param st pointer to storage
76  * @return true in good luck, false otherwise.
77  */
78  bool getAmpStatus(int *st) override;
79 
80  bool getAmpStatus(int j, int *st) override;
81 
82  /* Read the electric current going to all motors.
83  * @param vals pointer to storage for the output values
84  * @return hopefully true, false in bad luck.
85  */
86  bool getCurrents(double *vals) override;
87 
88  /* Read the electric current going to a given motor.
89  * @param j motor number
90  * @param val pointer to storage for the output value
91  * @return probably true, might return false in bad times
92  */
93  bool getCurrent(int j, double *val) override;
94 
95  /* Set the maximum electric current going to a given motor. The behavior
96  * of the board/amplifier when this limit is reached depends on the
97  * implementation.
98  * @param j motor number
99  * @param v the new value
100  * @return probably true, might return false in bad times
101  */
102  bool setMaxCurrent(int j, double v) override;
103 
112  bool getMaxCurrent(int j, double *v) override;
113 
114  /* Get the the nominal current which can be kept for an indefinite amount of time
115  * without harming the motor. This value is specific for each motor and it is typically
116  * found in its datasheet. The units are Ampere.
117  * This value and the peak current may be used by the firmware to configure
118  * an I2T filter.
119  * @param j joint number
120  * @param val storage for return value. [Ampere]
121  * @return true/false success failure.
122  */
123  bool getNominalCurrent(int m, double *val) override;
124 
125  /* Set the the nominal current which can be kept for an indefinite amount of time
126  * without harming the motor. This value is specific for each motor and it is typically
127  * found in its datasheet. The units are Ampere.
128  * This value and the peak current may be used by the firmware to configure
129  * an I2T filter.
130  * @param j joint number
131  * @param val storage for return value. [Ampere]
132  * @return true/false success failure.
133  */
134  bool setNominalCurrent(int m, const double val) override;
135 
136  /* Get the the peak current which causes damage to the motor if maintained
137  * for a long amount of time.
138  * The value is often found in the motor datasheet, units are Ampere.
139  * This value and the nominal current may be used by the firmware to configure
140  * an I2T filter.
141  * @param j joint number
142  * @param val storage for return value. [Ampere]
143  * @return true/false success failure.
144  */
145  bool getPeakCurrent(int m, double *val) override;
146 
147  /* Set the the peak current. This value which causes damage to the motor if maintained
148  * for a long amount of time.
149  * The value is often found in the motor datasheet, units are Ampere.
150  * This value and the nominal current may be used by the firmware to configure
151  * an I2T filter.
152  * @param j joint number
153  * @param val storage for return value. [Ampere]
154  * @return true/false success failure.
155  */
156  bool setPeakCurrent(int m, const double val) override;
157 
158  /* Get the the current PWM value used to control the motor.
159  * The units are firmware dependent, either machine units or percentage.
160  * @param j joint number
161  * @param val filled with PWM value.
162  * @return true/false success failure.
163  */
164  bool getPWM(int j, double* val) override;
165 
166  /* Get the PWM limit for the given motor.
167  * The units are firmware dependent, either machine units or percentage.
168  * @param j joint number
169  * @param val filled with PWM limit value.
170  * @return true/false success failure.
171  */
172  bool getPWMLimit(int j, double* val) override;
173 
174  /* Set the PWM limit for the given motor.
175  * The units are firmware dependent, either machine units or percentage.
176  * @param j joint number
177  * @param val new value for the PWM limit.
178  * @return true/false success failure.
179  */
180  bool setPWMLimit(int j, const double val) override;
181 
182  /* Get the power source voltage for the given motor in Volt.
183  * @param j joint number
184  * @param val filled with return value.
185  * @return true/false success failure.
186  */
187  bool getPowerSupplyVoltage(int j, double* val) override;
188 };
189 
190 
191 #endif // YARP_DEV_IMPLEMENTAMPLIFIERCONTROL_H
yarp::dev::IAmplifierControl::setMaxCurrent
virtual bool setMaxCurrent(int j, double v)=0
yarp::dev::ImplementAmplifierControl
Definition: ImplementAmplifierControl.h:24
yarp::dev::IAmplifierControl::enableAmp
virtual bool enableAmp(int j)=0
Enable the amplifier on a specific joint.
yarp::dev::ImplementAmplifierControl::ImplementAmplifierControl
ImplementAmplifierControl(yarp::dev::IAmplifierControlRaw *y)
Definition: ImplementAmplifierControl.cpp:21
yarp::dev::IAmplifierControl::getAmpStatus
virtual bool getAmpStatus(int *st)=0
yarp::dev::ImplementAmplifierControl::dTemp
double * dTemp
Definition: ImplementAmplifierControl.h:28
yarp::dev::ImplementAmplifierControl::uninitialize
bool uninitialize()
Clean up internal data and memory.
Definition: ImplementAmplifierControl.cpp:53
yarp::dev::IAmplifierControl::getPeakCurrent
virtual bool getPeakCurrent(int m, double *val)
Definition: IAmplifierControl.h:129
ControlBoardInterfaces.h
define control board standard interfaces
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::ImplementAmplifierControl::iTemp
int * iTemp
Definition: ImplementAmplifierControl.h:29
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
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::IAmplifierControl::getNominalCurrent
virtual bool getNominalCurrent(int m, double *val)
Definition: IAmplifierControl.h:107
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::ImplementAmplifierControl::iAmplifier
IAmplifierControlRaw * iAmplifier
Definition: ImplementAmplifierControl.h:26
yarp::dev::IAmplifierControl::getCurrents
virtual bool getCurrents(double *vals)=0
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::dev::ImplementAmplifierControl::helper
void * helper
Definition: ImplementAmplifierControl.h:27
yarp::dev::IAmplifierControlRaw
Interface for control devices, amplifier commands.
Definition: IAmplifierControl.h:179
api.h
yarp::dev::ImplementAmplifierControl::~ImplementAmplifierControl
virtual ~ImplementAmplifierControl()
Destructor.
Definition: ImplementAmplifierControl.cpp:29
yarp::dev::ImplementAmplifierControl::initialize
bool initialize(int size, const int *amap, const double *enc, const double *zos, const double *ampereFactor=NULL, const double *voltFactor=NULL)
Initialize the internal data and alloc memory.
Definition: ImplementAmplifierControl.cpp:34