source: flair-src/trunk/lib/FlairSensorActuator/src/Bldc.h@ 340

Last change on this file since 340 was 340, checked in by Sanahuja Guillaume, 4 years ago

add servos

File size: 3.3 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5/*!
6 * \file Bldc.h
7 * \brief Base class for brushless motors drivers
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2013/11/14
10 * \version 4.0
11 */
12
13#ifndef BLDC_H
14#define BLDC_H
15
16#include <IODevice.h>
17#include <stdint.h>
18
19namespace flair {
20namespace core {
21class Matrix;
22}
23namespace gui {
24class Layout;
25class TabWidget;
26}
27}
28
29class Bldc_impl;
30
31namespace flair {
32namespace actuator {
33/*! \class Bldc
34*
35* \brief Base class for brushless motors drivers
36*/
37class Bldc : public core::IODevice {
38 friend class ::Bldc_impl;
39
40public:
41 /*!
42 * \brief Constructor
43 *
44 * Construct a Bldc.
45 *
46 * \param parent parent
47 * \param layout layout
48 * \param name name
49 * \param motors_count number of motors
50 */
51 Bldc(const core::IODevice *parent, gui::Layout *layout, std::string name,
52 uint8_t motors_count);
53
54 /*!
55 * \brief Destructor
56 *
57 */
58 ~Bldc();
59
60 /*!
61 * \brief Lock user interface
62 *
63 */
64 void LockUserInterface(void) const;
65
66 /*!
67 * \brief Unlock user interface
68 *
69 */
70 void UnlockUserInterface(void) const;
71
72 /*!
73 * \brief Use default plot
74 *
75 * \param tabwidget TabWidget to draw plots
76 */
77 void UseDefaultPlot(gui::TabWidget *tabwidget);
78
79 /*!
80 * \brief Output from motors
81 *
82 * First column is real speed if available, secund column is current if
83 *available
84 *
85 */
86 core::Matrix *Output(void) const;
87
88 /*!
89 * \brief Motors count
90 *
91 * \return number of motors
92 */
93 uint8_t MotorsCount(void) const;
94
95 /*!
96 * \brief Enable motors
97 *
98 * \param true to enable all motors
99 */
100 void SetEnabled(bool status);
101
102 /*!
103 * \brief Are motors enabled?
104 *
105 * \return true if motors are enabled
106 */
107 bool AreEnabled(void) const;
108
109 /*!
110 * \brief Set motor power
111 *
112 * Changes the power (from 0 to 1) of a specific motor. \n
113 * By default power is set to 1 for each motor which has no effect. \n
114 * A value <1 will decrease the power of a motor sent to the reimplemented Bldc
115 *class through SetMotors. \n
116 * The power value is applied after applying saturation between min value and
117 *max value.
118 * So the resulting value cannot be higher than max value
119 * but it can be lower than min value.
120 *
121 * \param motor_id id of the motor
122 * \param value power value (from 0 to 1)
123 *
124 */
125 void SetPower(int motor_id, float value);
126
127 /*!
128 * \brief Layout
129 *
130 * This the same Layout as passed to the constructor
131 *
132 * \return a Layout
133 */
134 gui::Layout *GetLayout(void) const;
135
136 /*!
137 * \brief Has speed measurement
138 *
139 * \return true if it has speed measurement
140 */
141 virtual bool HasSpeedMeasurement(void) const = 0;
142
143 /*!
144 * \brief Has current measurement
145 *
146 * \return true if it has current measurement
147 */
148 virtual bool HasCurrentMeasurement(void) const = 0;
149
150protected:
151 core::Matrix *output;
152
153private:
154 /*!
155 * \brief Update using provided datas
156 *
157 * Reimplemented from IODevice.
158 *
159 * \param data data from the parent to process
160 */
161 void UpdateFrom(const core::io_data *data);
162
163 /*!
164 * \brief Set motors values
165 *
166 * values size must be the same as MotorsCount()
167 *
168 * \param values set motors values
169 */
170 virtual void SetMotors(float *values) = 0;
171
172 class Bldc_impl *pimpl_;
173};
174} // end namespace actuator
175} // end namespace flair
176#endif // BLDC_H
Note: See TracBrowser for help on using the repository browser.