LP-106 Setup Wizard refresh : Add dual servo setup (dual aileron or
[librepilot.git] / ground / gcs / src / plugins / setupwizard / vehicleconfigurationhelper.h
blob002518bf03dc28a44980efb4083b1847b56ff7c8
1 /**
2 ******************************************************************************
4 * @file vehicleconfigurationhelper.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
6 * @addtogroup
7 * @{
8 * @addtogroup VehicleConfigurationHelper
9 * @{
10 * @brief
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef VEHICLECONFIGURATIONHELPER_H
29 #define VEHICLECONFIGURATIONHELPER_H
31 #include <QList>
32 #include <QPair>
33 #include "vehicleconfigurationsource.h"
34 #include "uavobjectmanager.h"
35 #include "systemsettings.h"
36 #include "cfg_vehicletypes/vehicleconfig.h"
37 #include "actuatorsettings.h"
39 struct mixerChannelSettings {
40 int type;
41 int throttle1;
42 int throttle2;
43 int roll;
44 int pitch;
45 int yaw;
47 mixerChannelSettings() : type(), throttle1(), throttle2(), roll(), pitch(), yaw() {}
49 mixerChannelSettings(int t, int th1, int th2, int r, int p, int y)
50 : type(t), throttle1(th1), throttle2(th2), roll(r), pitch(p), yaw(y) {}
53 class VehicleConfigurationHelper : public QObject {
54 Q_OBJECT
56 public:
57 VehicleConfigurationHelper(VehicleConfigurationSource *configSource);
58 bool setupVehicle(bool save = true);
59 bool setupHardwareSettings(bool save = true);
60 static const qint16 LEGACY_ESC_FREQUENCY = 50;
61 static const qint16 RAPID_ESC_FREQUENCY = 490;
62 static const qint16 PWMSYNC_ESC_FREQUENCY = 0;
63 static const qint16 ONESHOT_ESC_FREQUENCY = 0;
64 static const qint16 ANALOG_SERVO_FREQUENCY = 50;
65 static const qint16 DIGITAL_SERVO_FREQUENCY = 333;
66 static const int MIXER_TYPE_NONE = 0;
67 static const int MIXER_TYPE_MOTOR = 1;
68 static const int MIXER_TYPE_REVERSABLEMOTOR = 2;
69 static const int MIXER_TYPE_SERVO = 3;
72 signals:
73 void saveProgress(int total, int current, QString description);
75 private:
76 static const float DEFAULT_ENABLED_ACCEL_TAU = 0.1;
78 VehicleConfigurationSource *m_configSource;
79 UAVObjectManager *m_uavoManager;
81 QList<QPair<UAVDataObject *, QString> * > m_modifiedObjects;
82 void addModifiedObject(UAVDataObject *object, QString description);
83 void clearModifiedObjects();
85 void applyHardwareConfiguration();
86 void applyVehicleConfiguration();
87 void applyActuatorConfiguration();
88 void applyFlightModeConfiguration();
89 void applySensorBiasConfiguration();
90 void applyStabilizationConfiguration();
91 void applyManualControlDefaults();
92 void applyTemplateSettings();
94 bool isApplicable(UAVObject *dataObj);
96 void applyMixerConfiguration(mixerChannelSettings channels[]);
98 GUIConfigDataUnion getGUIConfigData();
99 void applyMultiGUISettings(SystemSettings::AirframeTypeOptions airframe, GUIConfigDataUnion guiConfig);
101 bool saveChangesToController(bool save);
102 QEventLoop m_eventLoop;
103 bool m_transactionOK;
104 bool m_transactionTimeout;
105 int m_currentTransactionObjectID;
106 int m_progress;
108 void resetVehicleConfig();
109 void resetGUIData();
111 void setupTriCopter();
112 void setupQuadCopter();
113 void setupHexaCopter();
114 void setupOctoCopter();
115 void setupElevon();
116 void setupDualAileron();
117 void setupAileron();
118 void setupVtail();
120 void setupCar();
121 void setupTank();
122 void setupMotorcycle();
124 private slots:
125 void uAVOTransactionCompleted(UAVObject *object, bool success);
126 void uAVOTransactionCompleted(int oid, bool success);
127 void saveChangesTimeout();
130 #endif // VEHICLECONFIGURATIONHELPER_H