2012-08-17 00:47:31 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file vehicleconfigurationhelper.cpp
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "vehicleconfigurationhelper.h"
|
|
|
|
#include "extensionsystem/pluginmanager.h"
|
|
|
|
#include "hwsettings.h"
|
|
|
|
#include "actuatorsettings.h"
|
|
|
|
#include "attitudesettings.h"
|
|
|
|
#include "mixersettings.h"
|
|
|
|
#include "systemsettings.h"
|
2012-08-23 16:28:57 +02:00
|
|
|
#include "manualcontrolsettings.h"
|
2014-02-09 19:33:29 +01:00
|
|
|
#include "flightmodesettings.h"
|
2012-08-23 16:28:57 +02:00
|
|
|
#include "stabilizationsettings.h"
|
2014-06-12 18:07:03 +02:00
|
|
|
#include "stabilizationbank.h"
|
2014-06-12 08:43:38 +02:00
|
|
|
#include "stabilizationsettingsbank1.h"
|
2013-04-29 15:11:24 +02:00
|
|
|
#include "revocalibration.h"
|
2013-12-26 16:56:54 +01:00
|
|
|
#include "accelgyrosettings.h"
|
2012-08-17 00:47:31 +02:00
|
|
|
|
2012-09-04 01:28:28 +02:00
|
|
|
const qint16 VehicleConfigurationHelper::LEGACY_ESC_FREQUENCE = 50;
|
2013-05-19 16:37:30 +02:00
|
|
|
const qint16 VehicleConfigurationHelper::RAPID_ESC_FREQUENCE = 400;
|
2014-08-17 19:47:16 +02:00
|
|
|
const qint16 VehicleConfigurationHelper::ANALOG_SERVO_FREQUENCE = 50;
|
2014-08-17 14:55:11 +02:00
|
|
|
const qint16 VehicleConfigurationHelper::DIGITAL_SERVO_FREQUENCE = 333;
|
2012-09-04 01:28:28 +02:00
|
|
|
|
2012-08-17 00:47:31 +02:00
|
|
|
VehicleConfigurationHelper::VehicleConfigurationHelper(VehicleConfigurationSource *configSource)
|
2012-08-19 23:25:50 +02:00
|
|
|
: m_configSource(configSource), m_uavoManager(0),
|
2013-05-19 16:37:30 +02:00
|
|
|
m_transactionOK(false), m_transactionTimeout(false), m_currentTransactionObjectID(-1),
|
|
|
|
m_progress(0)
|
2012-08-17 00:47:31 +02:00
|
|
|
{
|
|
|
|
Q_ASSERT(m_configSource);
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
m_uavoManager = pm->getObject<UAVObjectManager>();
|
|
|
|
Q_ASSERT(m_uavoManager);
|
|
|
|
}
|
|
|
|
|
2012-09-07 07:35:43 +02:00
|
|
|
bool VehicleConfigurationHelper::setupVehicle(bool save)
|
2012-08-17 00:47:31 +02:00
|
|
|
{
|
2012-08-19 23:25:50 +02:00
|
|
|
m_progress = 0;
|
2012-09-09 23:44:42 +02:00
|
|
|
clearModifiedObjects();
|
|
|
|
resetVehicleConfig();
|
|
|
|
resetGUIData();
|
2013-05-19 16:37:30 +02:00
|
|
|
if (!saveChangesToController(save)) {
|
2012-09-09 23:44:42 +02:00
|
|
|
return false;
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
|
|
|
|
2012-09-23 21:58:37 +02:00
|
|
|
m_progress = 0;
|
2012-08-17 00:47:31 +02:00
|
|
|
applyHardwareConfiguration();
|
|
|
|
applyVehicleConfiguration();
|
2012-08-27 07:19:46 +02:00
|
|
|
applyActuatorConfiguration();
|
2014-08-17 14:55:11 +02:00
|
|
|
applyFlightModeConfiguration();
|
2013-04-29 15:11:24 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
if (save) {
|
2013-04-29 15:11:24 +02:00
|
|
|
applySensorBiasConfiguration();
|
|
|
|
}
|
|
|
|
|
2012-08-21 23:10:38 +02:00
|
|
|
applyStabilizationConfiguration();
|
2012-09-09 23:44:42 +02:00
|
|
|
applyManualControlDefaults();
|
2012-08-19 23:25:50 +02:00
|
|
|
|
2012-09-09 23:44:42 +02:00
|
|
|
bool result = saveChangesToController(save);
|
2012-09-23 21:58:37 +02:00
|
|
|
emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, result ? tr("Done!") : tr("Failed!"));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VehicleConfigurationHelper::setupHardwareSettings(bool save)
|
|
|
|
{
|
|
|
|
m_progress = 0;
|
|
|
|
clearModifiedObjects();
|
|
|
|
applyHardwareConfiguration();
|
|
|
|
applyManualControlDefaults();
|
|
|
|
|
|
|
|
bool result = saveChangesToController(save);
|
|
|
|
emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, result ? tr("Done!") : tr("Failed!"));
|
2012-09-09 23:44:42 +02:00
|
|
|
return result;
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::addModifiedObject(UAVDataObject *object, QString description)
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
m_modifiedObjects << new QPair<UAVDataObject *, QString>(object, description);
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::clearModifiedObjects()
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
for (int i = 0; i < m_modifiedObjects.count(); i++) {
|
|
|
|
QPair<UAVDataObject *, QString> *pair = m_modifiedObjects.at(i);
|
2012-08-19 23:25:50 +02:00
|
|
|
delete pair;
|
|
|
|
}
|
|
|
|
m_modifiedObjects.clear();
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::applyHardwareConfiguration()
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
HwSettings *hwSettings = HwSettings::GetInstance(m_uavoManager);
|
2012-08-17 00:47:31 +02:00
|
|
|
HwSettings::DataFields data = hwSettings->getData();
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
switch (m_configSource->getControllerType()) {
|
|
|
|
case VehicleConfigurationSource::CONTROLLER_CC:
|
|
|
|
case VehicleConfigurationSource::CONTROLLER_CC3D:
|
|
|
|
// Reset all ports
|
|
|
|
data.CC_RcvrPort = HwSettings::CC_RCVRPORT_DISABLED;
|
|
|
|
|
|
|
|
// Default mainport to be active telemetry link
|
|
|
|
data.CC_MainPort = HwSettings::CC_MAINPORT_TELEMETRY;
|
|
|
|
|
|
|
|
data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DISABLED;
|
|
|
|
switch (m_configSource->getInputType()) {
|
|
|
|
case VehicleConfigurationSource::INPUT_PWM:
|
|
|
|
data.CC_RcvrPort = HwSettings::CC_RCVRPORT_PWM;
|
2012-08-17 00:47:31 +02:00
|
|
|
break;
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::INPUT_PPM:
|
|
|
|
data.CC_RcvrPort = HwSettings::CC_RCVRPORT_PPM;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_SBUS:
|
|
|
|
// We have to set teletry on flexport since s.bus needs the mainport.
|
|
|
|
data.CC_MainPort = HwSettings::CC_MAINPORT_SBUS;
|
|
|
|
data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_TELEMETRY;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_DSMX10:
|
|
|
|
data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DSMX10BIT;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_DSMX11:
|
|
|
|
data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DSMX11BIT;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_DSM2:
|
|
|
|
data.CC_FlexiPort = HwSettings::CC_FLEXIPORT_DSM2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::CONTROLLER_REVO:
|
|
|
|
// Reset all ports
|
|
|
|
data.RM_RcvrPort = HwSettings::RM_RCVRPORT_DISABLED;
|
|
|
|
|
|
|
|
// Default mainport to be active telemetry link
|
|
|
|
data.RM_MainPort = HwSettings::RM_MAINPORT_TELEMETRY;
|
|
|
|
|
|
|
|
data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DISABLED;
|
|
|
|
switch (m_configSource->getInputType()) {
|
|
|
|
case VehicleConfigurationSource::INPUT_PWM:
|
|
|
|
data.RM_RcvrPort = HwSettings::RM_RCVRPORT_PWM;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_PPM:
|
|
|
|
data.RM_RcvrPort = HwSettings::RM_RCVRPORT_PPM;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_SBUS:
|
|
|
|
// We have to set teletry on flexport since s.bus needs the mainport.
|
|
|
|
data.RM_MainPort = HwSettings::RM_MAINPORT_SBUS;
|
|
|
|
data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_TELEMETRY;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_DSMX10:
|
|
|
|
data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DSMX10BIT;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_DSMX11:
|
|
|
|
data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DSMX11BIT;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_DSM2:
|
|
|
|
data.RM_FlexiPort = HwSettings::RM_FLEXIPORT_DSM2;
|
2012-08-17 00:47:31 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-19 16:37:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
2012-08-20 00:14:17 +02:00
|
|
|
hwSettings->setData(data);
|
2012-08-19 23:25:50 +02:00
|
|
|
addModifiedObject(hwSettings, tr("Writing hardware settings"));
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::applyVehicleConfiguration()
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getVehicleType()) {
|
|
|
|
case VehicleConfigurationSource::VEHICLE_MULTI:
|
2012-08-17 00:47:31 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getVehicleSubType()) {
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_TRI_Y:
|
|
|
|
setupTriCopter();
|
2012-08-17 00:47:31 +02:00
|
|
|
break;
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS:
|
|
|
|
setupQuadCopter();
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_COAX_Y:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_H:
|
2014-07-10 06:01:28 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_X:
|
2013-05-19 16:37:30 +02:00
|
|
|
setupHexaCopter();
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO:
|
2014-07-13 13:58:18 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_X:
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_X:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_PLUS:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_V:
|
|
|
|
setupOctoCopter();
|
2012-08-17 00:47:31 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-19 16:37:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::VEHICLE_FIXEDWING:
|
2013-11-24 23:29:38 +01:00
|
|
|
{
|
|
|
|
switch (m_configSource->getVehicleSubType()) {
|
|
|
|
case VehicleConfigurationSource::FIXED_WING_AILERON:
|
|
|
|
setupAileron();
|
|
|
|
break;
|
2014-06-08 05:04:12 +02:00
|
|
|
case VehicleConfigurationSource::FIXED_WING_ELEVON:
|
|
|
|
setupElevon();
|
2013-11-24 23:29:38 +01:00
|
|
|
break;
|
2014-06-11 20:41:42 +02:00
|
|
|
case VehicleConfigurationSource::FIXED_WING_VTAIL:
|
2014-08-18 01:20:31 +02:00
|
|
|
// TODO: Implement settings for VTail fixed wings
|
2014-06-11 20:41:42 +02:00
|
|
|
break;
|
2013-11-24 23:29:38 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::VEHICLE_HELI:
|
2014-08-17 14:55:11 +02:00
|
|
|
// TODO: Implement settings for Helis
|
|
|
|
break;
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::VEHICLE_SURFACE:
|
2014-08-17 14:55:11 +02:00
|
|
|
// TODO: Implement settings for Surface
|
2013-05-19 16:37:30 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-27 07:19:46 +02:00
|
|
|
void VehicleConfigurationHelper::applyActuatorConfiguration()
|
2012-08-17 00:47:31 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
ActuatorSettings *actSettings = ActuatorSettings::GetInstance(m_uavoManager);
|
2012-08-27 07:19:46 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getVehicleType()) {
|
|
|
|
case VehicleConfigurationSource::VEHICLE_MULTI:
|
|
|
|
{
|
|
|
|
ActuatorSettings::DataFields data = actSettings->getData();
|
|
|
|
|
|
|
|
QList<actuatorChannelSettings> actuatorSettings = m_configSource->getActuatorSettings();
|
|
|
|
for (quint16 i = 0; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) {
|
|
|
|
data.ChannelType[i] = ActuatorSettings::CHANNELTYPE_PWM;
|
|
|
|
data.ChannelAddr[i] = i;
|
|
|
|
data.ChannelMin[i] = actuatorSettings[i].channelMin;
|
|
|
|
data.ChannelNeutral[i] = actuatorSettings[i].channelNeutral;
|
|
|
|
data.ChannelMax[i] = actuatorSettings[i].channelMax;
|
|
|
|
}
|
2012-08-17 00:47:31 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
data.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_FALSE;
|
2012-09-04 01:28:28 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
for (quint16 i = 0; i < ActuatorSettings::CHANNELUPDATEFREQ_NUMELEM; i++) {
|
|
|
|
data.ChannelUpdateFreq[i] = LEGACY_ESC_FREQUENCE;
|
|
|
|
}
|
2012-08-17 00:47:31 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
qint16 updateFrequence = LEGACY_ESC_FREQUENCE;
|
2014-08-17 14:55:11 +02:00
|
|
|
switch (m_configSource->getActuatorType()) {
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::ESC_LEGACY:
|
|
|
|
updateFrequence = LEGACY_ESC_FREQUENCE;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::ESC_RAPID:
|
|
|
|
updateFrequence = RAPID_ESC_FREQUENCE;
|
|
|
|
break;
|
|
|
|
default:
|
2012-08-17 00:47:31 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
switch (m_configSource->getVehicleSubType()) {
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_TRI_Y:
|
|
|
|
data.ChannelUpdateFreq[0] = updateFrequence;
|
|
|
|
if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) {
|
|
|
|
data.ChannelUpdateFreq[1] = updateFrequence;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS:
|
|
|
|
data.ChannelUpdateFreq[0] = updateFrequence;
|
|
|
|
data.ChannelUpdateFreq[1] = updateFrequence;
|
|
|
|
if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) {
|
|
|
|
data.ChannelUpdateFreq[2] = updateFrequence;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_COAX_Y:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_H:
|
2014-07-10 06:01:28 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_X:
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO:
|
2014-07-13 13:58:18 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_X:
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_X:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_PLUS:
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_V:
|
|
|
|
data.ChannelUpdateFreq[0] = updateFrequence;
|
|
|
|
data.ChannelUpdateFreq[1] = updateFrequence;
|
|
|
|
data.ChannelUpdateFreq[2] = updateFrequence;
|
|
|
|
data.ChannelUpdateFreq[3] = updateFrequence;
|
2012-08-17 00:47:31 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-19 16:37:30 +02:00
|
|
|
}
|
|
|
|
actSettings->setData(data);
|
|
|
|
addModifiedObject(actSettings, tr("Writing actuator settings"));
|
|
|
|
break;
|
|
|
|
}
|
2014-05-25 21:20:04 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::VEHICLE_FIXEDWING:
|
2013-12-18 21:14:56 +01:00
|
|
|
{
|
|
|
|
ActuatorSettings::DataFields data = actSettings->getData();
|
|
|
|
|
|
|
|
QList<actuatorChannelSettings> actuatorSettings = m_configSource->getActuatorSettings();
|
2014-08-18 01:20:31 +02:00
|
|
|
for (quint16 i = 0; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) {
|
2013-12-18 21:14:56 +01:00
|
|
|
data.ChannelType[i] = ActuatorSettings::CHANNELTYPE_PWM;
|
|
|
|
data.ChannelAddr[i] = i;
|
2014-08-17 14:55:11 +02:00
|
|
|
data.ChannelMin[i] = actuatorSettings[i].channelMin;
|
|
|
|
data.ChannelNeutral[i] = actuatorSettings[i].channelNeutral;
|
|
|
|
data.ChannelMax[i] = actuatorSettings[i].channelMax;
|
2013-12-18 21:14:56 +01:00
|
|
|
}
|
2014-08-17 14:55:11 +02:00
|
|
|
|
2014-08-17 19:47:16 +02:00
|
|
|
qint16 updateFrequence = ANALOG_SERVO_FREQUENCE;
|
2014-08-17 14:55:11 +02:00
|
|
|
switch (m_configSource->getActuatorType()) {
|
2014-08-17 19:47:16 +02:00
|
|
|
case VehicleConfigurationSource::SERVO_ANALOG:
|
|
|
|
updateFrequence = ANALOG_SERVO_FREQUENCE;
|
2014-08-17 14:55:11 +02:00
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::SERVO_DIGITAL:
|
|
|
|
updateFrequence = DIGITAL_SERVO_FREQUENCE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-18 01:20:31 +02:00
|
|
|
for (quint16 i = 0; i < ActuatorSettings::CHANNELUPDATEFREQ_NUMELEM; i++) {
|
2014-08-18 13:14:07 +02:00
|
|
|
data.ChannelUpdateFreq[i] = updateFrequence;
|
2014-08-18 01:20:31 +02:00
|
|
|
if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) {
|
|
|
|
if (i == 1) {
|
|
|
|
data.ChannelUpdateFreq[i] = ANALOG_SERVO_FREQUENCE;
|
|
|
|
}
|
|
|
|
} else if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_NANO) {
|
|
|
|
if (i == 2) {
|
|
|
|
data.ChannelUpdateFreq[i] = ANALOG_SERVO_FREQUENCE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-25 21:20:04 +02:00
|
|
|
actSettings->setData(data);
|
|
|
|
addModifiedObject(actSettings, tr("Writing actuator settings"));
|
2014-06-12 08:43:38 +02:00
|
|
|
|
2014-08-21 23:47:18 +02:00
|
|
|
break;
|
2013-12-18 21:14:56 +01:00
|
|
|
}
|
2014-05-25 21:20:04 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::VEHICLE_HELI:
|
2014-08-17 14:55:11 +02:00
|
|
|
// TODO: Implement settings for Heli vehicle types
|
|
|
|
break;
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::VEHICLE_SURFACE:
|
2014-08-17 14:55:11 +02:00
|
|
|
// TODO: Implement settings for ground vehicle types
|
2013-05-19 16:37:30 +02:00
|
|
|
break;
|
2014-08-17 14:55:11 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
default:
|
|
|
|
break;
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-17 14:55:11 +02:00
|
|
|
void VehicleConfigurationHelper::applyFlightModeConfiguration()
|
2012-08-17 00:47:31 +02:00
|
|
|
{
|
2014-02-09 19:33:29 +01:00
|
|
|
FlightModeSettings *modeSettings = FlightModeSettings::GetInstance(m_uavoManager);
|
2013-05-19 16:37:30 +02:00
|
|
|
ManualControlSettings *controlSettings = ManualControlSettings::GetInstance(m_uavoManager);
|
|
|
|
|
2014-02-09 19:33:29 +01:00
|
|
|
Q_ASSERT(modeSettings);
|
2012-08-20 00:14:17 +02:00
|
|
|
Q_ASSERT(controlSettings);
|
|
|
|
|
2014-02-09 19:33:29 +01:00
|
|
|
FlightModeSettings::DataFields data = modeSettings->getData();
|
|
|
|
ManualControlSettings::DataFields data2 = controlSettings->getData();
|
|
|
|
data.Stabilization1Settings[0] = FlightModeSettings::STABILIZATION1SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization1Settings[1] = FlightModeSettings::STABILIZATION1SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization1Settings[2] = FlightModeSettings::STABILIZATION1SETTINGS_AXISLOCK;
|
2014-04-26 20:57:39 +02:00
|
|
|
data.Stabilization1Settings[3] = FlightModeSettings::STABILIZATION1SETTINGS_MANUAL;
|
2014-02-09 19:33:29 +01:00
|
|
|
data.Stabilization2Settings[0] = FlightModeSettings::STABILIZATION2SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization2Settings[1] = FlightModeSettings::STABILIZATION2SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization2Settings[2] = FlightModeSettings::STABILIZATION2SETTINGS_RATE;
|
2014-05-03 18:38:45 +02:00
|
|
|
data.Stabilization2Settings[3] = FlightModeSettings::STABILIZATION2SETTINGS_MANUAL;
|
2014-02-09 19:33:29 +01:00
|
|
|
data.Stabilization3Settings[0] = FlightModeSettings::STABILIZATION3SETTINGS_RATE;
|
|
|
|
data.Stabilization3Settings[1] = FlightModeSettings::STABILIZATION3SETTINGS_RATE;
|
|
|
|
data.Stabilization3Settings[2] = FlightModeSettings::STABILIZATION3SETTINGS_RATE;
|
2014-05-03 18:38:45 +02:00
|
|
|
data.Stabilization3Settings[3] = FlightModeSettings::STABILIZATION3SETTINGS_MANUAL;
|
|
|
|
data.Stabilization4Settings[0] = FlightModeSettings::STABILIZATION4SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization4Settings[1] = FlightModeSettings::STABILIZATION4SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization4Settings[2] = FlightModeSettings::STABILIZATION4SETTINGS_AXISLOCK;
|
|
|
|
data.Stabilization4Settings[3] = FlightModeSettings::STABILIZATION4SETTINGS_CRUISECONTROL;
|
|
|
|
data.Stabilization5Settings[0] = FlightModeSettings::STABILIZATION5SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization5Settings[1] = FlightModeSettings::STABILIZATION5SETTINGS_ATTITUDE;
|
|
|
|
data.Stabilization5Settings[2] = FlightModeSettings::STABILIZATION5SETTINGS_RATE;
|
|
|
|
data.Stabilization5Settings[3] = FlightModeSettings::STABILIZATION5SETTINGS_CRUISECONTROL;
|
|
|
|
data.Stabilization6Settings[0] = FlightModeSettings::STABILIZATION6SETTINGS_RATE;
|
|
|
|
data.Stabilization6Settings[1] = FlightModeSettings::STABILIZATION6SETTINGS_RATE;
|
|
|
|
data.Stabilization6Settings[2] = FlightModeSettings::STABILIZATION6SETTINGS_RATE;
|
|
|
|
data.Stabilization6Settings[3] = FlightModeSettings::STABILIZATION6SETTINGS_CRUISECONTROL;
|
2014-02-09 19:33:29 +01:00
|
|
|
data2.FlightModeNumber = 3;
|
|
|
|
data.FlightModePosition[0] = FlightModeSettings::FLIGHTMODEPOSITION_STABILIZED1;
|
|
|
|
data.FlightModePosition[1] = FlightModeSettings::FLIGHTMODEPOSITION_STABILIZED2;
|
|
|
|
data.FlightModePosition[2] = FlightModeSettings::FLIGHTMODEPOSITION_STABILIZED3;
|
2014-05-03 18:38:45 +02:00
|
|
|
data.FlightModePosition[3] = FlightModeSettings::FLIGHTMODEPOSITION_STABILIZED4;
|
|
|
|
data.FlightModePosition[4] = FlightModeSettings::FLIGHTMODEPOSITION_STABILIZED5;
|
|
|
|
data.FlightModePosition[5] = FlightModeSettings::FLIGHTMODEPOSITION_STABILIZED6;
|
2014-02-09 19:33:29 +01:00
|
|
|
modeSettings->setData(data);
|
|
|
|
addModifiedObject(modeSettings, tr("Writing flight mode settings 1/2"));
|
|
|
|
controlSettings->setData(data2);
|
|
|
|
addModifiedObject(controlSettings, tr("Writing flight mode settings 2/2"));
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
2013-04-29 15:11:24 +02:00
|
|
|
void VehicleConfigurationHelper::applySensorBiasConfiguration()
|
2012-08-17 00:47:31 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
if (m_configSource->isCalibrationPerformed()) {
|
2013-04-16 19:41:13 +02:00
|
|
|
accelGyroBias bias = m_configSource->getCalibrationBias();
|
2013-04-29 15:11:24 +02:00
|
|
|
float G = 9.81f;
|
|
|
|
|
2013-12-29 18:58:45 +01:00
|
|
|
AccelGyroSettings *accelGyroSettings = AccelGyroSettings::GetInstance(m_uavoManager);
|
|
|
|
Q_ASSERT(accelGyroSettings);
|
|
|
|
AccelGyroSettings::DataFields accelGyroSettingsData = accelGyroSettings->getData();
|
|
|
|
|
|
|
|
accelGyroSettingsData.accel_bias[AccelGyroSettings::ACCEL_BIAS_X] += bias.m_accelerometerXBias;
|
|
|
|
accelGyroSettingsData.accel_bias[AccelGyroSettings::ACCEL_BIAS_Y] += bias.m_accelerometerYBias;
|
|
|
|
accelGyroSettingsData.accel_bias[AccelGyroSettings::ACCEL_BIAS_Z] += bias.m_accelerometerZBias + G;
|
|
|
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_X] = bias.m_gyroXBias;
|
|
|
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Y] = bias.m_gyroYBias;
|
|
|
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Z] = bias.m_gyroZBias;
|
|
|
|
|
|
|
|
accelGyroSettings->setData(accelGyroSettingsData);
|
|
|
|
addModifiedObject(accelGyroSettings, tr("Writing gyro and accelerometer bias settings"));
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getControllerType()) {
|
2013-04-29 15:11:24 +02:00
|
|
|
case VehicleConfigurationSource::CONTROLLER_CC:
|
|
|
|
case VehicleConfigurationSource::CONTROLLER_CC3D:
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
AttitudeSettings *copterControlCalibration = AttitudeSettings::GetInstance(m_uavoManager);
|
2013-04-29 15:11:24 +02:00
|
|
|
Q_ASSERT(copterControlCalibration);
|
|
|
|
AttitudeSettings::DataFields data = copterControlCalibration->getData();
|
|
|
|
|
|
|
|
data.AccelTau = DEFAULT_ENABLED_ACCEL_TAU;
|
2013-06-05 22:24:12 +02:00
|
|
|
data.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_TRUE;
|
|
|
|
|
2013-04-29 15:11:24 +02:00
|
|
|
copterControlCalibration->setData(data);
|
2013-12-29 18:58:45 +01:00
|
|
|
addModifiedObject(copterControlCalibration, tr("Writing board settings"));
|
2013-04-29 15:11:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::CONTROLLER_REVO:
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
RevoCalibration *revolutionCalibration = RevoCalibration::GetInstance(m_uavoManager);
|
2013-04-29 15:11:24 +02:00
|
|
|
Q_ASSERT(revolutionCalibration);
|
|
|
|
RevoCalibration::DataFields data = revolutionCalibration->getData();
|
|
|
|
|
|
|
|
data.BiasCorrectedRaw = RevoCalibration::BIASCORRECTEDRAW_TRUE;
|
|
|
|
|
|
|
|
revolutionCalibration->setData(data);
|
2013-12-29 18:58:45 +01:00
|
|
|
addModifiedObject(revolutionCalibration, tr("Writing board settings"));
|
2013-04-29 15:11:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2013-05-19 16:37:30 +02:00
|
|
|
// Something went terribly wrong.
|
2013-04-29 15:11:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-21 23:10:38 +02:00
|
|
|
void VehicleConfigurationHelper::applyStabilizationConfiguration()
|
|
|
|
{
|
2014-03-08 10:50:32 +01:00
|
|
|
StabilizationSettings *stabSettings = StabilizationSettings::GetInstance(m_uavoManager);
|
2013-05-19 16:37:30 +02:00
|
|
|
|
2012-08-21 23:10:38 +02:00
|
|
|
Q_ASSERT(stabSettings);
|
|
|
|
|
|
|
|
StabilizationSettings defaultSettings;
|
|
|
|
stabSettings->setData(defaultSettings.getData());
|
|
|
|
addModifiedObject(stabSettings, tr("Writing stabilization settings"));
|
|
|
|
}
|
|
|
|
|
2012-10-01 21:50:00 +02:00
|
|
|
void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings channels[])
|
2012-08-19 23:25:50 +02:00
|
|
|
{
|
|
|
|
// Set all mixer data
|
2013-05-19 16:37:30 +02:00
|
|
|
MixerSettings *mSettings = MixerSettings::GetInstance(m_uavoManager);
|
|
|
|
|
2012-08-20 00:14:17 +02:00
|
|
|
Q_ASSERT(mSettings);
|
2012-08-19 23:25:50 +02:00
|
|
|
|
|
|
|
// Set Mixer types and values
|
2013-05-19 16:37:30 +02:00
|
|
|
QString mixerTypePattern = "Mixer%1Type";
|
2012-08-19 23:25:50 +02:00
|
|
|
QString mixerVectorPattern = "Mixer%1Vector";
|
2013-05-19 16:37:30 +02:00
|
|
|
for (int i = 0; i < 10; i++) {
|
2012-08-19 23:25:50 +02:00
|
|
|
UAVObjectField *field = mSettings->getField(mixerTypePattern.arg(i + 1));
|
|
|
|
Q_ASSERT(field);
|
2012-10-01 21:50:00 +02:00
|
|
|
field->setValue(field->getOptions().at(channels[i].type));
|
2012-08-19 23:25:50 +02:00
|
|
|
|
|
|
|
field = mSettings->getField(mixerVectorPattern.arg(i + 1));
|
|
|
|
Q_ASSERT(field);
|
2012-10-01 21:50:00 +02:00
|
|
|
field->setValue((channels[i].throttle1 * 127) / 100, 0);
|
|
|
|
field->setValue((channels[i].throttle2 * 127) / 100, 1);
|
|
|
|
field->setValue((channels[i].roll * 127) / 100, 2);
|
|
|
|
field->setValue((channels[i].pitch * 127) / 100, 3);
|
2013-05-19 16:37:30 +02:00
|
|
|
field->setValue((channels[i].yaw * 127) / 100, 4);
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Apply updates
|
2012-09-09 23:44:42 +02:00
|
|
|
mSettings->setData(mSettings->getData());
|
2012-08-19 23:25:50 +02:00
|
|
|
addModifiedObject(mSettings, tr("Writing mixer settings"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::applyMultiGUISettings(SystemSettings::AirframeTypeOptions airframe, GUIConfigDataUnion guiConfig)
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
SystemSettings *sSettings = SystemSettings::GetInstance(m_uavoManager);
|
|
|
|
|
2012-08-19 23:25:50 +02:00
|
|
|
Q_ASSERT(sSettings);
|
|
|
|
SystemSettings::DataFields data = sSettings->getData();
|
|
|
|
data.AirframeType = airframe;
|
|
|
|
|
|
|
|
for (int i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) {
|
|
|
|
data.GUIConfigData[i] = guiConfig.UAVObject[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
sSettings->setData(data);
|
|
|
|
addModifiedObject(sSettings, tr("Writing vehicle settings"));
|
|
|
|
}
|
|
|
|
|
2012-09-09 23:44:42 +02:00
|
|
|
void VehicleConfigurationHelper::applyManualControlDefaults()
|
|
|
|
{
|
|
|
|
ManualControlSettings *mcSettings = ManualControlSettings::GetInstance(m_uavoManager);
|
2013-05-19 16:37:30 +02:00
|
|
|
|
2012-09-09 23:44:42 +02:00
|
|
|
Q_ASSERT(mcSettings);
|
|
|
|
ManualControlSettings::DataFields cData = mcSettings->getData();
|
2012-09-17 21:40:42 +02:00
|
|
|
|
|
|
|
ManualControlSettings::ChannelGroupsOptions channelType = ManualControlSettings::CHANNELGROUPS_PWM;
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getInputType()) {
|
|
|
|
case VehicleConfigurationSource::INPUT_PWM:
|
|
|
|
channelType = ManualControlSettings::CHANNELGROUPS_PWM;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_PPM:
|
|
|
|
channelType = ManualControlSettings::CHANNELGROUPS_PPM;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_SBUS:
|
|
|
|
channelType = ManualControlSettings::CHANNELGROUPS_SBUS;
|
|
|
|
break;
|
|
|
|
case VehicleConfigurationSource::INPUT_DSMX10:
|
|
|
|
case VehicleConfigurationSource::INPUT_DSMX11:
|
|
|
|
case VehicleConfigurationSource::INPUT_DSM2:
|
|
|
|
channelType = ManualControlSettings::CHANNELGROUPS_DSMMAINPORT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2012-09-17 21:40:42 +02:00
|
|
|
}
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_THROTTLE] = channelType;
|
|
|
|
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_ROLL] = channelType;
|
2012-09-17 21:40:42 +02:00
|
|
|
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_YAW] = channelType;
|
2013-05-19 16:37:30 +02:00
|
|
|
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_PITCH] = channelType;
|
2012-09-17 21:40:42 +02:00
|
|
|
cData.ChannelGroups[ManualControlSettings::CHANNELGROUPS_FLIGHTMODE] = channelType;
|
2012-09-09 23:44:42 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_THROTTLE] = 1;
|
|
|
|
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_ROLL] = 2;
|
2012-09-09 23:44:42 +02:00
|
|
|
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_YAW] = 3;
|
2013-05-19 16:37:30 +02:00
|
|
|
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_PITCH] = 4;
|
2012-09-09 23:44:42 +02:00
|
|
|
cData.ChannelNumber[ManualControlSettings::CHANNELGROUPS_FLIGHTMODE] = 5;
|
|
|
|
|
|
|
|
mcSettings->setData(cData);
|
|
|
|
addModifiedObject(mcSettings, tr("Writing manual control defaults"));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VehicleConfigurationHelper::saveChangesToController(bool save)
|
2012-08-19 23:25:50 +02:00
|
|
|
{
|
|
|
|
qDebug() << "Saving modified objects to controller. " << m_modifiedObjects.count() << " objects in found.";
|
|
|
|
const int OUTER_TIMEOUT = 3000 * 20; // 10 seconds timeout for saving all objects
|
|
|
|
const int INNER_TIMEOUT = 2000; // 1 second timeout on every save attempt
|
|
|
|
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
Q_ASSERT(pm);
|
2013-05-19 16:37:30 +02:00
|
|
|
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
2012-08-19 23:25:50 +02:00
|
|
|
Q_ASSERT(utilMngr);
|
|
|
|
|
|
|
|
QTimer outerTimeoutTimer;
|
|
|
|
outerTimeoutTimer.setSingleShot(true);
|
|
|
|
|
|
|
|
QTimer innerTimeoutTimer;
|
|
|
|
innerTimeoutTimer.setSingleShot(true);
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
connect(utilMngr, SIGNAL(saveCompleted(int, bool)), this, SLOT(uAVOTransactionCompleted(int, bool)));
|
2012-08-19 23:25:50 +02:00
|
|
|
connect(&innerTimeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
|
|
|
|
connect(&outerTimeoutTimer, SIGNAL(timeout()), this, SLOT(saveChangesTimeout()));
|
|
|
|
|
|
|
|
outerTimeoutTimer.start(OUTER_TIMEOUT);
|
2013-05-19 16:37:30 +02:00
|
|
|
for (int i = 0; i < m_modifiedObjects.count(); i++) {
|
|
|
|
QPair<UAVDataObject *, QString> *objPair = m_modifiedObjects.at(i);
|
2012-08-19 23:25:50 +02:00
|
|
|
m_transactionOK = false;
|
2013-05-19 16:37:30 +02:00
|
|
|
UAVDataObject *obj = objPair->first;
|
2012-08-19 23:25:50 +02:00
|
|
|
QString objDescription = objPair->second;
|
2014-03-06 00:41:48 +01:00
|
|
|
if (UAVObject::GetGcsAccess(obj->getMetadata()) != UAVObject::ACCESS_READONLY && obj->isSettingsObject()) {
|
2012-09-23 21:58:37 +02:00
|
|
|
emit saveProgress(m_modifiedObjects.count() + 1, ++m_progress, objDescription);
|
2012-08-19 23:25:50 +02:00
|
|
|
|
|
|
|
m_currentTransactionObjectID = obj->getObjID();
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
connect(obj, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(uAVOTransactionCompleted(UAVObject *, bool)));
|
|
|
|
while (!m_transactionOK && !m_transactionTimeout) {
|
2012-08-19 23:25:50 +02:00
|
|
|
// Allow the transaction to take some time
|
|
|
|
innerTimeoutTimer.start(INNER_TIMEOUT);
|
|
|
|
|
|
|
|
// Set object updated
|
|
|
|
obj->updated();
|
2013-05-19 16:37:30 +02:00
|
|
|
if (!m_transactionOK) {
|
2012-08-19 23:25:50 +02:00
|
|
|
m_eventLoop.exec();
|
|
|
|
}
|
|
|
|
innerTimeoutTimer.stop();
|
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
disconnect(obj, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(uAVOTransactionCompleted(UAVObject *, bool)));
|
|
|
|
if (m_transactionOK) {
|
2012-08-19 23:25:50 +02:00
|
|
|
qDebug() << "Object " << obj->getName() << " was successfully updated.";
|
2013-05-19 16:37:30 +02:00
|
|
|
if (save) {
|
2012-09-09 23:44:42 +02:00
|
|
|
m_transactionOK = false;
|
|
|
|
m_currentTransactionObjectID = obj->getObjID();
|
|
|
|
// Try to save until success or timeout
|
2013-05-19 16:37:30 +02:00
|
|
|
while (!m_transactionOK && !m_transactionTimeout) {
|
2012-09-09 23:44:42 +02:00
|
|
|
// Allow the transaction to take some time
|
|
|
|
innerTimeoutTimer.start(INNER_TIMEOUT);
|
|
|
|
|
|
|
|
// Persist object in controller
|
|
|
|
utilMngr->saveObjectToSD(obj);
|
2013-05-19 16:37:30 +02:00
|
|
|
if (!m_transactionOK) {
|
2012-09-09 23:44:42 +02:00
|
|
|
m_eventLoop.exec();
|
|
|
|
}
|
|
|
|
innerTimeoutTimer.stop();
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
2012-09-09 23:44:42 +02:00
|
|
|
m_currentTransactionObjectID = -1;
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
if (!m_transactionOK) {
|
2012-08-19 23:25:50 +02:00
|
|
|
qDebug() << "Transaction timed out when trying to save: " << obj->getName();
|
2013-05-19 16:37:30 +02:00
|
|
|
} else {
|
2012-08-19 23:25:50 +02:00
|
|
|
qDebug() << "Object " << obj->getName() << " was successfully saved.";
|
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
} else {
|
2012-08-19 23:25:50 +02:00
|
|
|
qDebug() << "Trying to save a UAVDataObject that is read only or is not a settings object.";
|
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
if (m_transactionTimeout) {
|
2012-08-19 23:25:50 +02:00
|
|
|
qDebug() << "Transaction timed out when trying to save " << m_modifiedObjects.count() << " objects.";
|
|
|
|
break;
|
|
|
|
}
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
2012-08-19 23:25:50 +02:00
|
|
|
|
|
|
|
outerTimeoutTimer.stop();
|
|
|
|
disconnect(&outerTimeoutTimer, SIGNAL(timeout()), this, SLOT(saveChangesTimeout()));
|
|
|
|
disconnect(&innerTimeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
|
|
|
|
disconnect(utilMngr, SIGNAL(saveCompleted(int, bool)), this, SLOT(uAVOTransactionCompleted(int, bool)));
|
|
|
|
|
|
|
|
qDebug() << "Finished saving modified objects to controller. Success = " << m_transactionOK;
|
|
|
|
|
|
|
|
return m_transactionOK;
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
2012-08-19 23:25:50 +02:00
|
|
|
void VehicleConfigurationHelper::uAVOTransactionCompleted(int oid, bool success)
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
if (oid == m_currentTransactionObjectID) {
|
2012-08-19 23:25:50 +02:00
|
|
|
m_transactionOK = success;
|
|
|
|
m_eventLoop.quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::uAVOTransactionCompleted(UAVObject *object, bool success)
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
if (object) {
|
2012-08-19 23:25:50 +02:00
|
|
|
uAVOTransactionCompleted(object->getObjID(), success);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::saveChangesTimeout()
|
|
|
|
{
|
|
|
|
m_transactionOK = false;
|
|
|
|
m_transactionTimeout = true;
|
|
|
|
m_eventLoop.quit();
|
|
|
|
}
|
2012-08-17 00:47:31 +02:00
|
|
|
|
|
|
|
void VehicleConfigurationHelper::resetVehicleConfig()
|
|
|
|
{
|
|
|
|
// Reset all vehicle data
|
2013-05-19 16:37:30 +02:00
|
|
|
MixerSettings *mSettings = MixerSettings::GetInstance(m_uavoManager);
|
2012-08-17 00:47:31 +02:00
|
|
|
|
|
|
|
// Reset feed forward, accel times etc
|
|
|
|
mSettings->setFeedForward(0.0f);
|
|
|
|
mSettings->setMaxAccel(1000.0f);
|
|
|
|
mSettings->setAccelTime(0.0f);
|
|
|
|
mSettings->setDecelTime(0.0f);
|
|
|
|
|
|
|
|
// Reset throttle curves
|
|
|
|
QString throttlePattern = "ThrottleCurve%1";
|
2013-05-19 16:37:30 +02:00
|
|
|
for (int i = 1; i <= 2; i++) {
|
2012-08-17 00:47:31 +02:00
|
|
|
UAVObjectField *field = mSettings->getField(throttlePattern.arg(i));
|
|
|
|
Q_ASSERT(field);
|
2014-07-13 01:39:50 +02:00
|
|
|
// Wizard support only Multirotors - Set default curve with 90% max
|
2013-05-19 16:37:30 +02:00
|
|
|
for (quint32 i = 0; i < field->getNumElements(); i++) {
|
2014-07-13 01:39:50 +02:00
|
|
|
field->setValue(i * (0.9f / (field->getNumElements() - 1)), i);
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset Mixer types and values
|
2013-05-19 16:37:30 +02:00
|
|
|
QString mixerTypePattern = "Mixer%1Type";
|
2012-08-17 00:47:31 +02:00
|
|
|
QString mixerVectorPattern = "Mixer%1Vector";
|
2013-05-19 16:37:30 +02:00
|
|
|
for (int i = 1; i <= 10; i++) {
|
2012-08-17 00:47:31 +02:00
|
|
|
UAVObjectField *field = mSettings->getField(mixerTypePattern.arg(i));
|
|
|
|
Q_ASSERT(field);
|
|
|
|
field->setValue(field->getOptions().at(0));
|
|
|
|
|
|
|
|
field = mSettings->getField(mixerVectorPattern.arg(i));
|
|
|
|
Q_ASSERT(field);
|
2013-05-19 16:37:30 +02:00
|
|
|
for (quint32 i = 0; i < field->getNumElements(); i++) {
|
2012-08-17 00:47:31 +02:00
|
|
|
field->setValue(0, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply updates
|
2013-05-19 16:37:30 +02:00
|
|
|
// mSettings->setData(mSettings->getData());
|
2012-08-19 23:25:50 +02:00
|
|
|
addModifiedObject(mSettings, tr("Preparing mixer settings"));
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::resetGUIData()
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
SystemSettings *sSettings = SystemSettings::GetInstance(m_uavoManager);
|
|
|
|
|
2012-08-17 00:47:31 +02:00
|
|
|
Q_ASSERT(sSettings);
|
|
|
|
SystemSettings::DataFields data = sSettings->getData();
|
|
|
|
data.AirframeType = SystemSettings::AIRFRAMETYPE_CUSTOM;
|
2013-05-19 16:37:30 +02:00
|
|
|
for (quint32 i = 0; i < SystemSettings::GUICONFIGDATA_NUMELEM; i++) {
|
2012-08-17 00:47:31 +02:00
|
|
|
data.GUIConfigData[i] = 0;
|
|
|
|
}
|
2012-08-20 00:14:17 +02:00
|
|
|
sSettings->setData(data);
|
2012-08-19 23:25:50 +02:00
|
|
|
addModifiedObject(sSettings, tr("Preparing vehicle settings"));
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::setupTriCopter()
|
|
|
|
{
|
|
|
|
// Typical vehicle setup
|
2012-08-21 01:07:38 +02:00
|
|
|
// 1. Setup mixer data
|
2012-08-17 00:47:31 +02:00
|
|
|
// 2. Setup GUI data
|
2012-08-21 01:07:38 +02:00
|
|
|
// 3. Apply changes
|
2012-08-19 23:25:50 +02:00
|
|
|
|
2012-10-01 21:50:00 +02:00
|
|
|
mixerChannelSettings channels[10];
|
2012-08-21 01:07:38 +02:00
|
|
|
GUIConfigDataUnion guiSettings = getGUIConfigData();
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[0].roll = 100;
|
|
|
|
channels[0].pitch = 50;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[0].yaw = 0;
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[1].roll = -100;
|
|
|
|
channels[1].pitch = 50;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[1].yaw = 0;
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[2].roll = 0;
|
|
|
|
channels[2].pitch = -100;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[2].yaw = 0;
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[3].type = MIXER_TYPE_SERVO;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[3].throttle1 = 0;
|
|
|
|
channels[3].throttle2 = 0;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[3].roll = 0;
|
|
|
|
channels[3].pitch = 0;
|
2012-10-01 21:50:00 +02:00
|
|
|
channels[3].yaw = 100;
|
2012-08-19 23:25:50 +02:00
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorNW = 1;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 2;
|
2013-05-19 16:37:30 +02:00
|
|
|
guiSettings.multi.VTOLMotorS = 3;
|
2012-08-19 23:25:50 +02:00
|
|
|
guiSettings.multi.TRIYaw = 4;
|
|
|
|
|
2012-10-01 21:50:00 +02:00
|
|
|
applyMixerConfiguration(channels);
|
2012-08-19 23:25:50 +02:00
|
|
|
applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_TRI, guiSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
GUIConfigDataUnion VehicleConfigurationHelper::getGUIConfigData()
|
|
|
|
{
|
|
|
|
GUIConfigDataUnion configData;
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
for (int i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) {
|
|
|
|
configData.UAVObject[i] = 0; // systemSettingsData.GUIConfigData[i];
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return configData;
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::setupQuadCopter()
|
|
|
|
{
|
2012-10-01 21:50:00 +02:00
|
|
|
mixerChannelSettings channels[10];
|
2012-08-19 23:25:50 +02:00
|
|
|
GUIConfigDataUnion guiSettings = getGUIConfigData();
|
2014-03-08 10:50:32 +01:00
|
|
|
SystemSettings::AirframeTypeOptions frame = SystemSettings::AIRFRAMETYPE_QUADX;
|
2012-08-19 23:25:50 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getVehicleSubType()) {
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_PLUS:
|
2012-08-19 23:25:50 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
frame = SystemSettings::AIRFRAMETYPE_QUADP;
|
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = 0;
|
|
|
|
channels[0].pitch = 100;
|
|
|
|
channels[0].yaw = -50;
|
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
|
|
|
channels[1].roll = -100;
|
|
|
|
channels[1].pitch = 0;
|
|
|
|
channels[1].yaw = 50;
|
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = 0;
|
|
|
|
channels[2].pitch = -100;
|
|
|
|
channels[2].yaw = -50;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = 100;
|
|
|
|
channels[3].pitch = 0;
|
|
|
|
channels[3].yaw = 50;
|
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorN = 1;
|
|
|
|
guiSettings.multi.VTOLMotorE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorS = 3;
|
|
|
|
guiSettings.multi.VTOLMotorW = 4;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_QUAD_X:
|
|
|
|
{
|
|
|
|
frame = SystemSettings::AIRFRAMETYPE_QUADX;
|
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = 50;
|
|
|
|
channels[0].pitch = 50;
|
|
|
|
channels[0].yaw = -50;
|
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
|
|
|
channels[1].roll = -50;
|
|
|
|
channels[1].pitch = 50;
|
|
|
|
channels[1].yaw = 50;
|
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = -50;
|
|
|
|
channels[2].pitch = -50;
|
|
|
|
channels[2].yaw = -50;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = 50;
|
|
|
|
channels[3].pitch = -50;
|
|
|
|
channels[3].yaw = 50;
|
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorNW = 1;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 4;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2012-08-19 23:25:50 +02:00
|
|
|
}
|
2012-10-01 21:50:00 +02:00
|
|
|
applyMixerConfiguration(channels);
|
2012-08-19 23:25:50 +02:00
|
|
|
applyMultiGUISettings(frame, guiSettings);
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::setupHexaCopter()
|
|
|
|
{
|
2012-10-01 21:50:00 +02:00
|
|
|
mixerChannelSettings channels[10];
|
2012-08-21 01:07:38 +02:00
|
|
|
GUIConfigDataUnion guiSettings = getGUIConfigData();
|
2014-03-08 10:50:32 +01:00
|
|
|
SystemSettings::AirframeTypeOptions frame = SystemSettings::AIRFRAMETYPE_HEXA;
|
2012-08-21 01:07:38 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getVehicleSubType()) {
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA:
|
2012-08-21 01:07:38 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
frame = SystemSettings::AIRFRAMETYPE_HEXA;
|
2014-07-13 01:39:50 +02:00
|
|
|
// HexaPlus according to new mixer table and pitch-roll-yaw mixing at 100%
|
2014-07-14 15:59:26 +02:00
|
|
|
// Pitch Roll Yaw
|
|
|
|
// M1 { 1 , 0 , -1 },
|
|
|
|
// M2 { 0.5, -1, 1 },
|
|
|
|
// M3 { -0.5, -1, -1 },
|
|
|
|
// M4 { -1 , 0 , 1 },
|
|
|
|
// M5 { -0.5, 1 , -1 },
|
|
|
|
// M6 { 0.5, 1 , 1 },
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[0].pitch = 100;
|
|
|
|
channels[0].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[1].roll = -100;
|
|
|
|
channels[1].pitch = 50;
|
|
|
|
channels[1].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[2].roll = -100;
|
|
|
|
channels[2].pitch = -50;
|
|
|
|
channels[2].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[3].pitch = -100;
|
|
|
|
channels[3].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[4].roll = 100;
|
|
|
|
channels[4].pitch = -50;
|
|
|
|
channels[4].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[5].roll = 100;
|
|
|
|
channels[5].pitch = 50;
|
|
|
|
channels[5].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorN = 1;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorS = 4;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 5;
|
|
|
|
guiSettings.multi.VTOLMotorNW = 6;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_COAX_Y:
|
|
|
|
{
|
|
|
|
frame = SystemSettings::AIRFRAMETYPE_HEXACOAX;
|
|
|
|
|
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = 100;
|
|
|
|
channels[0].pitch = 25;
|
|
|
|
channels[0].yaw = -66;
|
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
|
|
|
channels[1].roll = 100;
|
|
|
|
channels[1].pitch = 25;
|
|
|
|
channels[1].yaw = 66;
|
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = -100;
|
|
|
|
channels[2].pitch = 25;
|
|
|
|
channels[2].yaw = -66;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = -100;
|
|
|
|
channels[3].pitch = 25;
|
|
|
|
channels[3].yaw = 66;
|
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
|
|
|
channels[4].roll = 0;
|
|
|
|
channels[4].pitch = -50;
|
|
|
|
channels[4].yaw = -66;
|
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
|
|
|
channels[5].roll = 0;
|
|
|
|
channels[5].pitch = -50;
|
|
|
|
channels[5].yaw = 66;
|
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorNW = 1;
|
|
|
|
guiSettings.multi.VTOLMotorW = 2;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorE = 4;
|
|
|
|
guiSettings.multi.VTOLMotorS = 5;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 6;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_H:
|
|
|
|
{
|
2014-07-10 06:01:28 +02:00
|
|
|
frame = SystemSettings::AIRFRAMETYPE_HEXAH;
|
2014-07-13 01:39:50 +02:00
|
|
|
// HexaH according to new mixer table and pitch-roll-yaw mixing at 100%
|
2014-07-14 15:59:26 +02:00
|
|
|
// Pitch Roll Yaw
|
|
|
|
// M1 { 1 , -0.5, -0.5 },
|
|
|
|
// M2 { 0 , -1 , 1 },
|
|
|
|
// M3 { -1 , -0.5, -0.5 },
|
|
|
|
// M4 { -1 , 0.5, 0.5 },
|
|
|
|
// M5 { 0 , 1 , -1 },
|
|
|
|
// M6 { 1 , 0.5, 0.5 },
|
2014-07-10 06:01:28 +02:00
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[0].roll = -50;
|
|
|
|
channels[0].pitch = 100;
|
|
|
|
channels[0].yaw = -50;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
2014-07-10 06:01:28 +02:00
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[1].roll = -100;
|
2014-07-10 06:01:28 +02:00
|
|
|
channels[1].pitch = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[1].yaw = 100;
|
2014-07-10 06:01:28 +02:00
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[2].roll = -50;
|
|
|
|
channels[2].pitch = -100;
|
|
|
|
channels[2].yaw = -50;
|
2014-07-10 06:01:28 +02:00
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[3].roll = 50;
|
|
|
|
channels[3].pitch = -100;
|
|
|
|
channels[3].yaw = 50;
|
2014-07-10 06:01:28 +02:00
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[4].roll = 100;
|
2014-07-10 06:01:28 +02:00
|
|
|
channels[4].pitch = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[4].yaw = -100;
|
2014-07-10 06:01:28 +02:00
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[5].roll = 50;
|
|
|
|
channels[5].pitch = 100;
|
|
|
|
channels[5].yaw = 50;
|
2014-07-10 06:01:28 +02:00
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorNE = 1;
|
|
|
|
guiSettings.multi.VTOLMotorE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 4;
|
|
|
|
guiSettings.multi.VTOLMotorW = 5;
|
|
|
|
guiSettings.multi.VTOLMotorNW = 6;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_HEXA_X:
|
|
|
|
{
|
|
|
|
frame = SystemSettings::AIRFRAMETYPE_HEXAH;
|
2014-07-13 01:39:50 +02:00
|
|
|
// HexaX according to new mixer table and pitch-roll-yaw mixing at 100%
|
2014-07-14 15:59:26 +02:00
|
|
|
// Pitch Roll Yaw
|
|
|
|
// M1 { 1, -0.5, -1 },
|
|
|
|
// M2 { 0, -1 , 1 },
|
|
|
|
// M3 { -1, -0.5, -1 },
|
|
|
|
// M4 { -1, 0.5, 1 },
|
|
|
|
// M5 { 0, 1 , -1 },
|
|
|
|
// M6 { 1, 0.5, 1 },
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[0].roll = -50;
|
|
|
|
channels[0].pitch = 100;
|
|
|
|
channels[0].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[1].roll = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[1].pitch = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[1].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[2].roll = -50;
|
|
|
|
channels[2].pitch = -100;
|
|
|
|
channels[2].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[3].roll = 50;
|
|
|
|
channels[3].pitch = -100;
|
|
|
|
channels[3].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[4].roll = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[4].pitch = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[4].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
2014-07-13 01:39:50 +02:00
|
|
|
channels[5].roll = 50;
|
|
|
|
channels[5].pitch = 100;
|
|
|
|
channels[5].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorNE = 1;
|
|
|
|
guiSettings.multi.VTOLMotorE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 4;
|
|
|
|
guiSettings.multi.VTOLMotorW = 5;
|
|
|
|
guiSettings.multi.VTOLMotorNW = 6;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2012-08-21 01:07:38 +02:00
|
|
|
}
|
2012-10-01 21:50:00 +02:00
|
|
|
applyMixerConfiguration(channels);
|
2012-08-21 01:07:38 +02:00
|
|
|
applyMultiGUISettings(frame, guiSettings);
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::setupOctoCopter()
|
|
|
|
{
|
2012-10-01 21:50:00 +02:00
|
|
|
mixerChannelSettings channels[10];
|
2012-08-21 01:07:38 +02:00
|
|
|
GUIConfigDataUnion guiSettings = getGUIConfigData();
|
2014-03-08 10:50:32 +01:00
|
|
|
SystemSettings::AirframeTypeOptions frame = SystemSettings::AIRFRAMETYPE_OCTO;
|
2012-08-21 01:07:38 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
switch (m_configSource->getVehicleSubType()) {
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO:
|
2012-08-21 01:07:38 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
frame = SystemSettings::AIRFRAMETYPE_OCTO;
|
2014-07-13 13:58:18 +02:00
|
|
|
// OctoP according to new mixer table and pitch-roll-yaw mixing at 100%
|
2014-07-14 15:59:26 +02:00
|
|
|
// Pitch Roll Yaw
|
|
|
|
// M1{ 1 , 0 , -1 },
|
|
|
|
// M2{ 0.71,-0.71, 1 },
|
|
|
|
// M3{ 0 ,-1 , -1 },
|
|
|
|
// M4{ -0.71,-0.71, 1 },
|
|
|
|
// M5{ -1 , 0 , -1 },
|
|
|
|
// M6{ -0.71, 0.71, 1 },
|
|
|
|
// M7{ 0 , 1 , -1 },
|
|
|
|
// M8{ 0.71, 0.71, 1 }
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[0].pitch = 100;
|
|
|
|
channels[0].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[1].roll = -71;
|
|
|
|
channels[1].pitch = 71;
|
|
|
|
channels[1].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[2].roll = -71;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[2].pitch = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[2].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[3].roll = -71;
|
|
|
|
channels[3].pitch = -71;
|
|
|
|
channels[3].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
|
|
|
channels[4].roll = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[4].pitch = -100;
|
|
|
|
channels[4].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[5].roll = 71;
|
|
|
|
channels[5].pitch = -71;
|
|
|
|
channels[5].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[6].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[6].throttle1 = 100;
|
|
|
|
channels[6].throttle2 = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[6].roll = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
channels[6].pitch = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[6].yaw = -100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
channels[7].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[7].throttle1 = 100;
|
|
|
|
channels[7].throttle2 = 0;
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[7].roll = 71;
|
|
|
|
channels[7].pitch = 71;
|
|
|
|
channels[7].yaw = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorN = 1;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 4;
|
|
|
|
guiSettings.multi.VTOLMotorS = 5;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 6;
|
|
|
|
guiSettings.multi.VTOLMotorW = 7;
|
|
|
|
guiSettings.multi.VTOLMotorNW = 8;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2014-07-13 13:58:18 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_X:
|
|
|
|
{
|
|
|
|
frame = SystemSettings::AIRFRAMETYPE_OCTOX;
|
|
|
|
// OctoX according to new mixer table and pitch-roll-yaw mixing at 100%
|
2014-07-14 15:59:26 +02:00
|
|
|
// Pitch Roll Yaw
|
|
|
|
// M1{ 1 ,-0.41, -1 },
|
|
|
|
// M2{ 0.41, -1 , 1 },
|
|
|
|
// M3{ -0.41, -1 , -1 },
|
|
|
|
// M4{ -1 ,-0.41, 1 },
|
|
|
|
// M5{ -1 , 0.41, -1 },
|
|
|
|
// M6{ -0.41, 1 , 1 },
|
|
|
|
// M7{ 0.41, 1 , -1 },
|
|
|
|
// M8{ 1 , 0.41, 1 }
|
2014-07-13 13:58:18 +02:00
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = -41;
|
|
|
|
channels[0].pitch = 100;
|
|
|
|
channels[0].yaw = -100;
|
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
|
|
|
channels[1].roll = -100;
|
|
|
|
channels[1].pitch = 41;
|
|
|
|
channels[1].yaw = 100;
|
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = -100;
|
|
|
|
channels[2].pitch = -41;
|
|
|
|
channels[2].yaw = -100;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = -41;
|
|
|
|
channels[3].pitch = -100;
|
|
|
|
channels[3].yaw = 100;
|
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
|
|
|
channels[4].roll = 41;
|
|
|
|
channels[4].pitch = -100;
|
|
|
|
channels[4].yaw = -100;
|
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
|
|
|
channels[5].roll = 100;
|
|
|
|
channels[5].pitch = -41;
|
|
|
|
channels[5].yaw = 100;
|
|
|
|
|
|
|
|
channels[6].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[6].throttle1 = 100;
|
|
|
|
channels[6].throttle2 = 0;
|
|
|
|
channels[6].roll = 100;
|
|
|
|
channels[6].pitch = 41;
|
|
|
|
channels[6].yaw = -100;
|
|
|
|
|
|
|
|
channels[7].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[7].throttle1 = 100;
|
|
|
|
channels[7].throttle2 = 0;
|
|
|
|
channels[7].roll = 41;
|
|
|
|
channels[7].pitch = 100;
|
|
|
|
channels[7].yaw = 100;
|
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorNNE = 1;
|
|
|
|
guiSettings.multi.VTOLMotorENE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorESE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorSSE = 4;
|
|
|
|
guiSettings.multi.VTOLMotorSSW = 5;
|
|
|
|
guiSettings.multi.VTOLMotorWSW = 6;
|
|
|
|
guiSettings.multi.VTOLMotorWNW = 7;
|
|
|
|
guiSettings.multi.VTOLMotorNNW = 8;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_X:
|
|
|
|
{
|
|
|
|
frame = SystemSettings::AIRFRAMETYPE_OCTOCOAXX;
|
|
|
|
|
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = 50;
|
|
|
|
channels[0].pitch = 50;
|
|
|
|
channels[0].yaw = -50;
|
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
|
|
|
channels[1].roll = 50;
|
|
|
|
channels[1].pitch = 50;
|
|
|
|
channels[1].yaw = 50;
|
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = -50;
|
|
|
|
channels[2].pitch = 50;
|
|
|
|
channels[2].yaw = -50;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = -50;
|
|
|
|
channels[3].pitch = 50;
|
|
|
|
channels[3].yaw = 50;
|
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
|
|
|
channels[4].roll = -50;
|
|
|
|
channels[4].pitch = -50;
|
|
|
|
channels[4].yaw = -50;
|
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
|
|
|
channels[5].roll = -50;
|
|
|
|
channels[5].pitch = -50;
|
|
|
|
channels[5].yaw = 50;
|
|
|
|
|
|
|
|
channels[6].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[6].throttle1 = 100;
|
|
|
|
channels[6].throttle2 = 0;
|
|
|
|
channels[6].roll = 50;
|
|
|
|
channels[6].pitch = -50;
|
|
|
|
channels[6].yaw = -50;
|
|
|
|
|
|
|
|
channels[7].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[7].throttle1 = 100;
|
|
|
|
channels[7].throttle2 = 0;
|
|
|
|
channels[7].roll = 50;
|
|
|
|
channels[7].pitch = -50;
|
|
|
|
channels[7].yaw = 50;
|
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorNW = 1;
|
|
|
|
guiSettings.multi.VTOLMotorN = 2;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorE = 4;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 5;
|
|
|
|
guiSettings.multi.VTOLMotorS = 6;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 7;
|
|
|
|
guiSettings.multi.VTOLMotorW = 8;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_COAX_PLUS:
|
|
|
|
{
|
|
|
|
frame = SystemSettings::AIRFRAMETYPE_OCTOCOAXP;
|
|
|
|
|
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = 0;
|
|
|
|
channels[0].pitch = 100;
|
|
|
|
channels[0].yaw = -50;
|
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
|
|
|
channels[1].roll = 0;
|
|
|
|
channels[1].pitch = 100;
|
|
|
|
channels[1].yaw = 50;
|
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = -100;
|
|
|
|
channels[2].pitch = 0;
|
|
|
|
channels[2].yaw = -50;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = -100;
|
|
|
|
channels[3].pitch = 0;
|
|
|
|
channels[3].yaw = 50;
|
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
|
|
|
channels[4].roll = 0;
|
|
|
|
channels[4].pitch = -100;
|
|
|
|
channels[4].yaw = -50;
|
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
|
|
|
channels[5].roll = 0;
|
|
|
|
channels[5].pitch = -100;
|
|
|
|
channels[5].yaw = 50;
|
|
|
|
|
|
|
|
channels[6].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[6].throttle1 = 100;
|
|
|
|
channels[6].throttle2 = 0;
|
|
|
|
channels[6].roll = 100;
|
|
|
|
channels[6].pitch = 0;
|
|
|
|
channels[6].yaw = -50;
|
|
|
|
|
|
|
|
channels[7].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[7].throttle1 = 100;
|
|
|
|
channels[7].throttle2 = 0;
|
|
|
|
channels[7].roll = 100;
|
|
|
|
channels[7].pitch = 0;
|
|
|
|
channels[7].yaw = 50;
|
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorN = 1;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 4;
|
|
|
|
guiSettings.multi.VTOLMotorS = 5;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 6;
|
|
|
|
guiSettings.multi.VTOLMotorW = 7;
|
|
|
|
guiSettings.multi.VTOLMotorNW = 8;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VehicleConfigurationSource::MULTI_ROTOR_OCTO_V:
|
|
|
|
{
|
|
|
|
frame = SystemSettings::AIRFRAMETYPE_OCTOV;
|
|
|
|
channels[0].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[0].throttle1 = 100;
|
|
|
|
channels[0].throttle2 = 0;
|
|
|
|
channels[0].roll = -25;
|
|
|
|
channels[0].pitch = 8;
|
|
|
|
channels[0].yaw = -25;
|
|
|
|
|
|
|
|
channels[1].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[1].throttle1 = 100;
|
|
|
|
channels[1].throttle2 = 0;
|
|
|
|
channels[1].roll = -25;
|
|
|
|
channels[1].pitch = 25;
|
|
|
|
channels[1].yaw = 25;
|
|
|
|
|
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = -25;
|
|
|
|
channels[2].pitch = -25;
|
|
|
|
channels[2].yaw = -25;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[3].throttle1 = 100;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = -25;
|
|
|
|
channels[3].pitch = -8;
|
|
|
|
channels[3].yaw = 25;
|
|
|
|
|
|
|
|
channels[4].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[4].throttle1 = 100;
|
|
|
|
channels[4].throttle2 = 0;
|
|
|
|
channels[4].roll = 25;
|
|
|
|
channels[4].pitch = -8;
|
|
|
|
channels[4].yaw = -25;
|
|
|
|
|
|
|
|
channels[5].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[5].throttle1 = 100;
|
|
|
|
channels[5].throttle2 = 0;
|
|
|
|
channels[5].roll = 25;
|
|
|
|
channels[5].pitch = -25;
|
|
|
|
channels[5].yaw = 25;
|
|
|
|
|
|
|
|
channels[6].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[6].throttle1 = 100;
|
|
|
|
channels[6].throttle2 = 0;
|
|
|
|
channels[6].roll = 25;
|
|
|
|
channels[6].pitch = 25;
|
|
|
|
channels[6].yaw = -25;
|
|
|
|
|
|
|
|
channels[7].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[7].throttle1 = 100;
|
|
|
|
channels[7].throttle2 = 0;
|
|
|
|
channels[7].roll = 25;
|
|
|
|
channels[7].pitch = 8;
|
|
|
|
channels[7].yaw = 25;
|
|
|
|
|
|
|
|
guiSettings.multi.VTOLMotorN = 1;
|
|
|
|
guiSettings.multi.VTOLMotorNE = 2;
|
|
|
|
guiSettings.multi.VTOLMotorE = 3;
|
|
|
|
guiSettings.multi.VTOLMotorSE = 4;
|
|
|
|
guiSettings.multi.VTOLMotorS = 5;
|
|
|
|
guiSettings.multi.VTOLMotorSW = 6;
|
|
|
|
guiSettings.multi.VTOLMotorW = 7;
|
|
|
|
guiSettings.multi.VTOLMotorNW = 8;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2012-08-21 01:07:38 +02:00
|
|
|
}
|
|
|
|
|
2012-10-01 21:50:00 +02:00
|
|
|
applyMixerConfiguration(channels);
|
2012-08-21 01:07:38 +02:00
|
|
|
applyMultiGUISettings(frame, guiSettings);
|
2012-08-17 00:47:31 +02:00
|
|
|
}
|
2013-11-24 23:29:38 +01:00
|
|
|
|
2014-06-08 05:04:12 +02:00
|
|
|
void VehicleConfigurationHelper::setupElevon()
|
2013-11-24 23:29:38 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
mixerChannelSettings channels[10];
|
|
|
|
GUIConfigDataUnion guiSettings = getGUIConfigData();
|
|
|
|
|
2014-08-21 23:47:18 +02:00
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = 0;
|
|
|
|
channels[2].pitch = 0;
|
|
|
|
channels[2].yaw = 0;
|
|
|
|
|
|
|
|
channels[0].type = MIXER_TYPE_SERVO;
|
|
|
|
channels[0].throttle1 = 0;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[0].throttle2 = 0;
|
2014-08-21 23:47:18 +02:00
|
|
|
channels[0].roll = -100;
|
|
|
|
channels[0].pitch = 100;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[0].yaw = 0;
|
|
|
|
|
2013-12-18 18:57:35 +01:00
|
|
|
channels[1].type = MIXER_TYPE_SERVO;
|
|
|
|
channels[1].throttle1 = 0;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[1].throttle2 = 0;
|
2014-08-21 23:47:18 +02:00
|
|
|
channels[1].roll = 100;
|
|
|
|
channels[1].pitch = -100;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[1].yaw = 0;
|
|
|
|
|
2014-08-21 23:47:18 +02:00
|
|
|
guiSettings.fixedwing.FixedWingThrottle = 3;
|
|
|
|
guiSettings.fixedwing.FixedWingPitch1 = 1;
|
|
|
|
guiSettings.fixedwing.FixedWingPitch2 = 2;
|
2013-11-24 23:29:38 +01:00
|
|
|
|
|
|
|
applyMixerConfiguration(channels);
|
2014-06-11 20:41:42 +02:00
|
|
|
applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON, guiSettings);
|
2013-11-24 23:29:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void VehicleConfigurationHelper::setupAileron()
|
|
|
|
{
|
|
|
|
// Typical vehicle setup
|
|
|
|
// 1. Setup mixer data
|
|
|
|
// 2. Setup GUI data
|
|
|
|
// 3. Apply changes
|
|
|
|
|
|
|
|
mixerChannelSettings channels[10];
|
|
|
|
GUIConfigDataUnion guiSettings = getGUIConfigData();
|
|
|
|
|
2014-08-21 23:47:18 +02:00
|
|
|
channels[2].type = MIXER_TYPE_MOTOR;
|
|
|
|
channels[2].throttle1 = 100;
|
|
|
|
channels[2].throttle2 = 0;
|
|
|
|
channels[2].roll = 0;
|
|
|
|
channels[2].pitch = 0;
|
|
|
|
channels[2].yaw = 0;
|
|
|
|
|
|
|
|
channels[0].type = MIXER_TYPE_SERVO;
|
|
|
|
channels[0].throttle1 = 0;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[0].throttle2 = 0;
|
2014-08-21 23:47:18 +02:00
|
|
|
channels[0].roll = -100;
|
2013-12-18 18:57:35 +01:00
|
|
|
channels[0].pitch = 0;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[0].yaw = 0;
|
|
|
|
|
2013-12-18 18:57:35 +01:00
|
|
|
channels[1].type = MIXER_TYPE_SERVO;
|
|
|
|
channels[1].throttle1 = 0;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[1].throttle2 = 0;
|
2014-08-21 23:47:18 +02:00
|
|
|
channels[1].roll = 100;
|
2013-12-18 18:57:35 +01:00
|
|
|
channels[1].pitch = 0;
|
2013-11-24 23:29:38 +01:00
|
|
|
channels[1].yaw = 0;
|
|
|
|
|
|
|
|
channels[3].type = MIXER_TYPE_SERVO;
|
|
|
|
channels[3].throttle1 = 0;
|
|
|
|
channels[3].throttle2 = 0;
|
|
|
|
channels[3].roll = 0;
|
2013-12-18 18:57:35 +01:00
|
|
|
channels[3].pitch = 100;
|
|
|
|
channels[3].yaw = 0;
|
2013-11-24 23:29:38 +01:00
|
|
|
|
2014-08-18 01:20:31 +02:00
|
|
|
channels[4].type = MIXER_TYPE_SERVO;
|
|
|
|
channels[4].throttle1 = 0;
|
|
|
|
channels[4].throttle2 = 0;
|
|
|
|
channels[4].roll = 0;
|
|
|
|
channels[4].pitch = 0;
|
|
|
|
channels[4].yaw = 100;
|
2013-11-24 23:29:38 +01:00
|
|
|
|
2014-08-21 23:47:18 +02:00
|
|
|
guiSettings.fixedwing.FixedWingThrottle = 3;
|
|
|
|
guiSettings.fixedwing.FixedWingRoll1 = 1;
|
|
|
|
guiSettings.fixedwing.FixedWingRoll2 = 2;
|
2013-12-18 18:57:35 +01:00
|
|
|
guiSettings.fixedwing.FixedWingPitch1 = 4;
|
|
|
|
guiSettings.fixedwing.FixedWingYaw1 = 5;
|
2013-11-24 23:29:38 +01:00
|
|
|
|
|
|
|
applyMixerConfiguration(channels);
|
2013-12-18 21:14:56 +01:00
|
|
|
applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWING, guiSettings);
|
2013-11-24 23:29:38 +01:00
|
|
|
}
|