Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / setupwizard / vehicleconfigurationhelper.h
blob7227ecd961ff45c67d852005439509297540d564
1 /**
2 ******************************************************************************
4 * @file vehicleconfigurationhelper.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015-2016.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
7 * @addtogroup
8 * @{
9 * @addtogroup VehicleConfigurationHelper
10 * @{
11 * @brief
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef VEHICLECONFIGURATIONHELPER_H
30 #define VEHICLECONFIGURATIONHELPER_H
32 #include "vehicleconfigurationsource.h"
33 #include "uavobjectmanager.h"
34 #include "cfg_vehicletypes/vehicleconfig.h"
36 #include "systemsettings.h"
37 #include "actuatorsettings.h"
39 #include <QList>
40 #include <QPair>
41 #include <QEventLoop>
43 struct mixerChannelSettings {
44 int type;
45 int throttle1;
46 int throttle2;
47 int roll;
48 int pitch;
49 int yaw;
51 mixerChannelSettings() : type(), throttle1(), throttle2(), roll(), pitch(), yaw() {}
53 mixerChannelSettings(int t, int th1, int th2, int r, int p, int y)
54 : type(t), throttle1(th1), throttle2(th2), roll(r), pitch(p), yaw(y) {}
57 class VehicleConfigurationHelper : public QObject {
58 Q_OBJECT
60 public:
61 VehicleConfigurationHelper(VehicleConfigurationSource *configSource);
62 bool setupVehicle(bool save = true);
63 bool setupHardwareSettings(bool save = true);
64 static const qint16 LEGACY_ESC_FREQUENCY = 50;
65 static const qint16 LEGACY_MULTI_ESC_FREQUENCY = 300;
66 static const qint16 RAPID_ESC_FREQUENCY = 490;
67 static const qint16 PWMSYNC_ESC_FREQUENCY = 0;
68 static const qint16 ESC_FREQUENCY_ZERO = 0;
69 static const qint16 DSHOT_MODE_150 = 150;
70 static const qint16 LEGACY_DSHOT_MODE = 600;
71 static const qint16 DSHOT_MODE_1200 = 1200;
72 static const qint16 ANALOG_SERVO_FREQUENCY = 50;
73 static const qint16 DIGITAL_SERVO_FREQUENCY = 333;
74 static const int MIXER_TYPE_NONE = 0;
75 static const int MIXER_TYPE_MOTOR = 1;
76 static const int MIXER_TYPE_REVERSABLEMOTOR = 2;
77 static const int MIXER_TYPE_SERVO = 3;
80 signals:
81 void saveProgress(int total, int current, QString description);
83 private:
84 VehicleConfigurationSource *m_configSource;
85 UAVObjectManager *m_uavoManager;
87 QList<QPair<UAVDataObject *, QString> * > m_modifiedObjects;
88 void addModifiedObject(UAVDataObject *object, QString description);
89 void clearModifiedObjects();
91 void applyHardwareConfiguration();
92 void applyVehicleConfiguration();
93 void applyActuatorConfiguration();
94 void applyFlightModeConfiguration();
95 void applySensorBiasConfiguration();
96 void applyStabilizationConfiguration();
97 void applyManualControlDefaults();
98 void applyTemplateSettings();
100 bool isApplicable(UAVObject *dataObj);
102 void applyMixerConfiguration(mixerChannelSettings channels[]);
104 GUIConfigDataUnion getGUIConfigData();
105 void applyMultiGUISettings(SystemSettings::AirframeTypeOptions airframe, GUIConfigDataUnion guiConfig);
107 bool saveChangesToController(bool save);
108 QEventLoop m_eventLoop;
109 bool m_transactionOK;
110 bool m_transactionTimeout;
111 int m_currentTransactionObjectID;
112 int m_progress;
114 void resetVehicleConfig();
115 void resetGUIData();
117 void setupTriCopter();
118 void setupQuadCopter();
119 void setupHexaCopter();
120 void setupOctoCopter();
121 void setupElevon();
122 void setupDualAileron();
123 void setupAileron();
124 void setupVtail();
126 void setupCar();
127 void setupTank();
128 void setupMotorcycle();
129 void setupBoat();
130 void setupBoatDiff();
132 private slots:
133 void uAVOTransactionCompleted(UAVObject *object, bool success);
134 void uAVOTransactionCompleted(int oid, bool success);
135 void saveChangesTimeout();
138 #endif // VEHICLECONFIGURATIONHELPER_H