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

Last change on this file since 9 was 3, checked in by Sanahuja Guillaume, 9 years ago

sensoractuator

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