[3] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[3] | 4 | // %flair:license}
|
---|
| 5 | // created: 2013/04/29
|
---|
| 6 | // filename: BlCtrlV2_x4_speed.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: objet integrant les moteurs i2c, controle en vitesse
|
---|
| 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 |
|
---|
| 18 | #ifndef BLCTRLV2_X4_SPEED_H
|
---|
| 19 | #define BLCTRLV2_X4_SPEED_H
|
---|
| 20 |
|
---|
| 21 | #include <IODevice.h>
|
---|
| 22 | #include <Thread.h>
|
---|
| 23 |
|
---|
[15] | 24 | namespace flair {
|
---|
| 25 | namespace core {
|
---|
| 26 | class cvmatrix;
|
---|
| 27 | class FrameworkManager;
|
---|
| 28 | class I2cPort;
|
---|
[3] | 29 | }
|
---|
[15] | 30 | namespace gui {
|
---|
| 31 | class TabWidget;
|
---|
| 32 | class Tab;
|
---|
| 33 | class SpinBox;
|
---|
| 34 | class DoubleSpinBox;
|
---|
| 35 | class ComboBox;
|
---|
| 36 | class PushButton;
|
---|
| 37 | class GroupBox;
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
[3] | 40 |
|
---|
[15] | 41 | namespace flair {
|
---|
| 42 | namespace actuator {
|
---|
| 43 | class BlCtrlV2_x4_speed : public core::Thread, public core::IODevice {
|
---|
[3] | 44 |
|
---|
[15] | 45 | public:
|
---|
| 46 | BlCtrlV2_x4_speed(core::FrameworkManager *parent, std::string name,
|
---|
| 47 | core::I2cPort *i2cport, uint8_t base_address,
|
---|
| 48 | uint8_t priority);
|
---|
| 49 | ~BlCtrlV2_x4_speed();
|
---|
| 50 | void UseDefaultPlot(void);
|
---|
| 51 | void LockUserInterface(void);
|
---|
| 52 | void UnlockUserInterface(void);
|
---|
| 53 | void SetEnabled(bool status);
|
---|
| 54 | void SetUroll(float value);
|
---|
| 55 | void SetUpitch(float value);
|
---|
| 56 | void SetUyaw(float value);
|
---|
| 57 | void SetUgaz(float value);
|
---|
| 58 | void SetRollTrim(float value);
|
---|
| 59 | void SetPitchTrim(float value);
|
---|
| 60 | void SetYawTrim(float value);
|
---|
| 61 | void SetGazTrim(float value);
|
---|
| 62 | float TrimValue(void);
|
---|
| 63 | int StartValue(void);
|
---|
[3] | 64 |
|
---|
[15] | 65 | private:
|
---|
| 66 | /*!
|
---|
| 67 | * \brief Update using provided datas
|
---|
| 68 | *
|
---|
| 69 | * Reimplemented from IODevice.
|
---|
| 70 | *
|
---|
| 71 | * \param data data from the parent to process
|
---|
| 72 | */
|
---|
| 73 | void UpdateFrom(core::io_data *data){};
|
---|
| 74 | void WriteValue(uint16_t value);
|
---|
| 75 | float GetSpeed(void);
|
---|
| 76 | void StartTest(void);
|
---|
| 77 | void StopTest(void);
|
---|
| 78 | /*!
|
---|
| 79 | * \brief Run function
|
---|
| 80 | *
|
---|
| 81 | * Reimplemented from Thread.
|
---|
| 82 | *
|
---|
| 83 | */
|
---|
| 84 | void Run(void);
|
---|
| 85 | void Update(void);
|
---|
| 86 | gui::Tab *main_tab;
|
---|
| 87 | gui::TabWidget *tab;
|
---|
| 88 | gui::GroupBox *reglages_groupbox;
|
---|
| 89 | gui::SpinBox *min, *max, *test;
|
---|
| 90 | gui::PushButton *button_avg, *button_avd, *button_arg, *button_ard;
|
---|
| 91 | gui::ComboBox *av_g, *av_d, *ar_g, *ar_d, *pas;
|
---|
| 92 | gui::DoubleSpinBox *trim, *kp, *ki;
|
---|
| 93 | gui::SpinBox *start_value, *poles;
|
---|
| 94 | core::Time start_time, flight_start_time;
|
---|
| 95 | int time_sec;
|
---|
| 96 | float speed_av_g, speed_av_d, speed_ar_g, speed_ar_d;
|
---|
| 97 | float int_av_g, int_av_d, int_ar_g, int_ar_d;
|
---|
[3] | 98 |
|
---|
[15] | 99 | // matrix
|
---|
| 100 | core::cvmatrix *input;
|
---|
| 101 | core::cvmatrix *output;
|
---|
[3] | 102 |
|
---|
[15] | 103 | int tested_motor;
|
---|
| 104 | core::I2cPort *i2cport;
|
---|
| 105 | uint8_t slave_address;
|
---|
[3] | 106 |
|
---|
[15] | 107 | bool enabled;
|
---|
[3] | 108 |
|
---|
[15] | 109 | uint16_t SatPWM(float vel_cons, uint16_t min, uint16_t max);
|
---|
| 110 | };
|
---|
[3] | 111 | } // end namespace actuator
|
---|
| 112 | } // end namespace flair
|
---|
| 113 | #endif // BLCTRLV2_X4_SPEED_H
|
---|