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.
9 * @addtogroup VehicleConfigurationHelper
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
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"
43 struct mixerChannelSettings
{
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
{
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;
81 void saveProgress(int total
, int current
, QString description
);
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
;
114 void resetVehicleConfig();
117 void setupTriCopter();
118 void setupQuadCopter();
119 void setupHexaCopter();
120 void setupOctoCopter();
122 void setupDualAileron();
128 void setupMotorcycle();
130 void setupBoatDiff();
133 void uAVOTransactionCompleted(UAVObject
*object
, bool success
);
134 void uAVOTransactionCompleted(int oid
, bool success
);
135 void saveChangesTimeout();
138 #endif // VEHICLECONFIGURATIONHELPER_H