| 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 | // 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 |
|
---|
| 19 | #ifndef BLCTRLV2_X4_SPEED_H
|
---|
| 20 | #define BLCTRLV2_X4_SPEED_H
|
---|
| 21 |
|
---|
| 22 | #include <IODevice.h>
|
---|
| 23 | #include <Thread.h>
|
---|
| 24 |
|
---|
| 25 | namespace flair
|
---|
| 26 | {
|
---|
| 27 | namespace core
|
---|
| 28 | {
|
---|
| 29 | class cvmatrix;
|
---|
| 30 | class FrameworkManager;
|
---|
| 31 | class I2cPort;
|
---|
| 32 |
|
---|
| 33 | }
|
---|
| 34 | namespace gui
|
---|
| 35 | {
|
---|
| 36 | class TabWidget;
|
---|
| 37 | class Tab;
|
---|
| 38 | class SpinBox;
|
---|
| 39 | class DoubleSpinBox;
|
---|
| 40 | class ComboBox;
|
---|
| 41 | class PushButton;
|
---|
| 42 | class GroupBox;
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | namespace flair
|
---|
| 47 | {
|
---|
| 48 | namespace actuator
|
---|
| 49 | {
|
---|
| 50 | class BlCtrlV2_x4_speed : public core::Thread,public core::IODevice
|
---|
| 51 | {
|
---|
| 52 |
|
---|
| 53 | public:
|
---|
| 54 | BlCtrlV2_x4_speed(core::FrameworkManager* parent,std::string name,core::I2cPort* i2cport,uint8_t base_address,uint8_t priority);
|
---|
| 55 | ~BlCtrlV2_x4_speed();
|
---|
| 56 | void UseDefaultPlot(void);
|
---|
| 57 | void LockUserInterface(void);
|
---|
| 58 | void UnlockUserInterface(void);
|
---|
| 59 | void SetEnabled(bool status);
|
---|
| 60 | void SetUroll(float value);
|
---|
| 61 | void SetUpitch(float value);
|
---|
| 62 | void SetUyaw(float value);
|
---|
| 63 | void SetUgaz(float value);
|
---|
| 64 | void SetRollTrim(float value);
|
---|
| 65 | void SetPitchTrim(float value);
|
---|
| 66 | void SetYawTrim(float value);
|
---|
| 67 | void SetGazTrim(float value);
|
---|
| 68 | float TrimValue(void);
|
---|
| 69 | int StartValue(void);
|
---|
| 70 |
|
---|
| 71 | private:
|
---|
| 72 | /*!
|
---|
| 73 | * \brief Update using provided datas
|
---|
| 74 | *
|
---|
| 75 | * Reimplemented from IODevice.
|
---|
| 76 | *
|
---|
| 77 | * \param data data from the parent to process
|
---|
| 78 | */
|
---|
| 79 | void UpdateFrom(core::io_data *data){};
|
---|
| 80 | void WriteValue(uint16_t value);
|
---|
| 81 | float GetSpeed(void);
|
---|
| 82 | void StartTest(void);
|
---|
| 83 | void StopTest(void);
|
---|
| 84 | /*!
|
---|
| 85 | * \brief Run function
|
---|
| 86 | *
|
---|
| 87 | * Reimplemented from Thread.
|
---|
| 88 | *
|
---|
| 89 | */
|
---|
| 90 | void Run(void);
|
---|
| 91 | void Update(void);
|
---|
| 92 | gui::Tab* main_tab;
|
---|
| 93 | gui::TabWidget* tab;
|
---|
| 94 | gui::GroupBox* reglages_groupbox;
|
---|
| 95 | gui::SpinBox *min,*max,*test;
|
---|
| 96 | gui::PushButton *button_avg,*button_avd,*button_arg,*button_ard;
|
---|
| 97 | gui::ComboBox *av_g,*av_d,*ar_g,*ar_d,*pas;
|
---|
| 98 | gui::DoubleSpinBox *trim,*kp,*ki;
|
---|
| 99 | gui::SpinBox *start_value,*poles;
|
---|
| 100 | core::Time start_time,flight_start_time;
|
---|
| 101 | int time_sec;
|
---|
| 102 | float speed_av_g,speed_av_d,speed_ar_g,speed_ar_d;
|
---|
| 103 | float int_av_g,int_av_d,int_ar_g,int_ar_d;
|
---|
| 104 |
|
---|
| 105 | //matrix
|
---|
| 106 | core::cvmatrix *input;
|
---|
| 107 | core::cvmatrix *output;
|
---|
| 108 |
|
---|
| 109 | int tested_motor;
|
---|
| 110 | core::I2cPort* i2cport;
|
---|
| 111 | uint8_t slave_address;
|
---|
| 112 |
|
---|
| 113 | bool enabled;
|
---|
| 114 |
|
---|
| 115 | uint16_t SatPWM(float vel_cons,uint16_t min,uint16_t max);
|
---|
| 116 | };
|
---|
| 117 | } // end namespace actuator
|
---|
| 118 | } // end namespace flair
|
---|
| 119 | #endif // BLCTRLV2_X4_SPEED_H
|
---|