2012-08-17 00:47:31 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file vehicleconfigurationhelper.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
|
|
|
* @addtogroup
|
|
|
|
* @{
|
|
|
|
* @addtogroup VehicleConfigurationHelper
|
|
|
|
* @{
|
|
|
|
* @brief
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VEHICLECONFIGURATIONHELPER_H
|
|
|
|
#define VEHICLECONFIGURATIONHELPER_H
|
|
|
|
|
2012-08-19 23:25:50 +02:00
|
|
|
#include <QList>
|
|
|
|
#include <QPair>
|
2012-08-17 00:47:31 +02:00
|
|
|
#include "vehicleconfigurationsource.h"
|
|
|
|
#include "uavobjectmanager.h"
|
2012-08-19 23:25:50 +02:00
|
|
|
#include "systemsettings.h"
|
|
|
|
#include "cfg_vehicletypes/vehicleconfig.h"
|
2012-09-04 01:28:28 +02:00
|
|
|
#include "actuatorsettings.h"
|
2012-08-17 00:47:31 +02:00
|
|
|
|
2012-09-04 01:28:28 +02:00
|
|
|
struct mixerChannelSettings {
|
2012-08-17 00:47:31 +02:00
|
|
|
int type;
|
|
|
|
int throttle1;
|
|
|
|
int throttle2;
|
|
|
|
int roll;
|
|
|
|
int pitch;
|
|
|
|
int yaw;
|
|
|
|
|
2012-09-04 01:28:28 +02:00
|
|
|
mixerChannelSettings() : type(), throttle1(), throttle2(), roll(), pitch(), yaw() {}
|
2012-08-17 00:47:31 +02:00
|
|
|
|
2012-09-04 01:28:28 +02:00
|
|
|
mixerChannelSettings(int t, int th1, int th2, int r, int p, int y)
|
2012-08-17 00:47:31 +02:00
|
|
|
: type(t), throttle1(th1), throttle2(th2), roll(r), pitch(p), yaw(y) {}
|
|
|
|
};
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
class VehicleConfigurationHelper : public QObject {
|
2012-08-19 23:25:50 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-08-17 00:47:31 +02:00
|
|
|
public:
|
2013-05-19 16:37:30 +02:00
|
|
|
VehicleConfigurationHelper(VehicleConfigurationSource *configSource);
|
2012-09-07 07:35:43 +02:00
|
|
|
bool setupVehicle(bool save = true);
|
2012-09-23 21:58:37 +02:00
|
|
|
bool setupHardwareSettings(bool save = true);
|
2012-09-04 01:28:28 +02:00
|
|
|
static const qint16 LEGACY_ESC_FREQUENCE;
|
|
|
|
static const qint16 RAPID_ESC_FREQUENCE;
|
2012-08-19 23:25:50 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void saveProgress(int total, int current, QString description);
|
|
|
|
|
2012-08-17 00:47:31 +02:00
|
|
|
private:
|
2012-08-19 23:25:50 +02:00
|
|
|
static const int MIXER_TYPE_DISABLED = 0;
|
2013-05-19 16:37:30 +02:00
|
|
|
static const int MIXER_TYPE_MOTOR = 1;
|
|
|
|
static const int MIXER_TYPE_SERVO = 2;
|
2012-11-17 17:45:10 +01:00
|
|
|
static const float DEFAULT_ENABLED_ACCEL_TAU = 0.1;
|
2012-08-19 23:25:50 +02:00
|
|
|
|
2012-08-17 00:47:31 +02:00
|
|
|
VehicleConfigurationSource *m_configSource;
|
|
|
|
UAVObjectManager *m_uavoManager;
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
QList<QPair<UAVDataObject *, QString> * > m_modifiedObjects;
|
|
|
|
void addModifiedObject(UAVDataObject *object, QString description);
|
2012-08-19 23:25:50 +02:00
|
|
|
void clearModifiedObjects();
|
|
|
|
|
2012-08-17 00:47:31 +02:00
|
|
|
void applyHardwareConfiguration();
|
|
|
|
void applyVehicleConfiguration();
|
2012-08-27 07:19:46 +02:00
|
|
|
void applyActuatorConfiguration();
|
2012-08-17 00:47:31 +02:00
|
|
|
void applyFlighModeConfiguration();
|
2013-04-29 15:11:24 +02:00
|
|
|
void applySensorBiasConfiguration();
|
2012-08-21 23:10:38 +02:00
|
|
|
void applyStabilizationConfiguration();
|
2012-09-09 23:44:42 +02:00
|
|
|
void applyManualControlDefaults();
|
2012-08-17 00:47:31 +02:00
|
|
|
|
2012-10-01 21:50:00 +02:00
|
|
|
void applyMixerConfiguration(mixerChannelSettings channels[]);
|
2012-08-19 23:25:50 +02:00
|
|
|
|
|
|
|
GUIConfigDataUnion getGUIConfigData();
|
|
|
|
void applyMultiGUISettings(SystemSettings::AirframeTypeOptions airframe, GUIConfigDataUnion guiConfig);
|
|
|
|
|
2012-09-09 23:44:42 +02:00
|
|
|
bool saveChangesToController(bool save);
|
2012-08-19 23:25:50 +02:00
|
|
|
QEventLoop m_eventLoop;
|
|
|
|
bool m_transactionOK;
|
|
|
|
bool m_transactionTimeout;
|
|
|
|
int m_currentTransactionObjectID;
|
|
|
|
int m_progress;
|
|
|
|
|
2012-08-17 00:47:31 +02:00
|
|
|
void resetVehicleConfig();
|
|
|
|
void resetGUIData();
|
|
|
|
|
|
|
|
void setupTriCopter();
|
|
|
|
void setupQuadCopter();
|
|
|
|
void setupHexaCopter();
|
|
|
|
void setupOctoCopter();
|
2014-06-08 05:04:12 +02:00
|
|
|
void setupElevon();
|
2013-11-24 23:29:38 +01:00
|
|
|
void setupAileron();
|
2012-08-17 00:47:31 +02:00
|
|
|
|
2012-08-19 23:25:50 +02:00
|
|
|
private slots:
|
2013-05-19 16:37:30 +02:00
|
|
|
void uAVOTransactionCompleted(UAVObject *object, bool success);
|
2012-08-19 23:25:50 +02:00
|
|
|
void uAVOTransactionCompleted(int oid, bool success);
|
|
|
|
void saveChangesTimeout();
|
2012-08-17 00:47:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VEHICLECONFIGURATIONHELPER_H
|