From 670dbfe9ce5155bf5c3efb90652d364e242d2467 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Fri, 14 Aug 2015 10:54:12 +0200 Subject: [PATCH] LP-92 Remove Feed Forward : flight / ground --- flight/modules/Actuator/actuator.c | 54 +- ground/gcs/src/plugins/config/airframe.ui | 1304 +++++--------------- .../cfg_vehicletypes/configfixedwingwidget.cpp | 3 - .../cfg_vehicletypes/configgroundvehiclewidget.cpp | 4 +- .../src/plugins/config/configvehicletypewidget.cpp | 110 -- .../src/plugins/config/configvehicletypewidget.h | 9 +- .../setupwizard/vehicleconfigurationhelper.cpp | 7 +- shared/uavobjectdefinition/mixersettings.xml | 14 +- 8 files changed, 312 insertions(+), 1193 deletions(-) rewrite ground/gcs/src/plugins/config/airframe.ui (81%) diff --git a/flight/modules/Actuator/actuator.c b/flight/modules/Actuator/actuator.c index d3d2f426d..ea70743c8 100644 --- a/flight/modules/Actuator/actuator.c +++ b/flight/modules/Actuator/actuator.c @@ -86,8 +86,6 @@ static xTaskHandle taskHandle; static FrameType_t frameType = FRAME_TYPE_MULTIROTOR; static SystemSettingsThrustControlOptions thrustType = SYSTEMSETTINGS_THRUSTCONTROL_THROTTLE; -static float lastResult[MAX_MIX_ACTUATORS] = { 0 }; -static float filterAccumulator[MAX_MIX_ACTUATORS] = { 0 }; static uint8_t pinsMode[MAX_MIX_ACTUATORS]; // used to inform the actuator thread that actuator update rate is changed static ActuatorSettingsData actuatorSettings; @@ -111,7 +109,7 @@ static void ActuatorSettingsUpdatedCb(UAVObjEvent *ev); static void SettingsUpdatedCb(UAVObjEvent *ev); float ProcessMixer(const int index, const float curve1, const float curve2, ActuatorDesiredData *desired, - const float period, bool multirotor, bool fixedwing); + bool multirotor, bool fixedwing); // this structure is equivalent to the UAVObjects for one mixer. typedef struct { @@ -196,7 +194,6 @@ static void actuatorTask(__attribute__((unused)) void *parameters) UAVObjEvent ev; portTickType lastSysTime; portTickType thisSysTime; - float dTSeconds; uint32_t dTMilliseconds; ActuatorCommandData command; @@ -246,7 +243,6 @@ static void actuatorTask(__attribute__((unused)) void *parameters) thisSysTime = xTaskGetTickCount(); dTMilliseconds = (thisSysTime == lastSysTime) ? 1 : (thisSysTime - lastSysTime) * portTICK_RATE_MS; lastSysTime = thisSysTime; - dTSeconds = dTMilliseconds * 0.001f; FlightStatusGet(&flightStatus); FlightModeSettingsGet(&settings); @@ -408,12 +404,10 @@ static void actuatorTask(__attribute__((unused)) void *parameters) nonreversible_curve2 = 0.0f; } } - status[ct] = ProcessMixer(ct, nonreversible_curve1, nonreversible_curve2, &desired, dTSeconds, multirotor, fixedwing); + status[ct] = ProcessMixer(ct, nonreversible_curve1, nonreversible_curve2, &desired, multirotor, fixedwing); // If not armed or motors aren't meant to spin all the time if (!armed || (!spinWhileArmed && !positiveThrottle)) { - filterAccumulator[ct] = 0; - lastResult[ct] = 0; status[ct] = -1; // force min throttle } // If armed meant to keep spinning, @@ -426,16 +420,14 @@ static void actuatorTask(__attribute__((unused)) void *parameters) } } } else if (mixer_type == MIXERSETTINGS_MIXER1TYPE_REVERSABLEMOTOR) { - status[ct] = ProcessMixer(ct, curve1, curve2, &desired, dTSeconds, multirotor, fixedwing); + status[ct] = ProcessMixer(ct, curve1, curve2, &desired, multirotor, fixedwing); // Reversable Motors are like Motors but go to neutral instead of minimum // If not armed or motor is inactive - no "spinwhilearmed" for this engine type if (!armed || !activeThrottle) { - filterAccumulator[ct] = 0; - lastResult[ct] = 0; status[ct] = 0; // force neutral throttle } } else if (mixer_type == MIXERSETTINGS_MIXER1TYPE_SERVO) { - status[ct] = ProcessMixer(ct, curve1, curve2, &desired, dTSeconds, multirotor, fixedwing); + status[ct] = ProcessMixer(ct, curve1, curve2, &desired, multirotor, fixedwing); } else { status[ct] = -1; @@ -557,9 +549,9 @@ static void actuatorTask(__attribute__((unused)) void *parameters) * Process mixing for one actuator */ float ProcessMixer(const int index, const float curve1, const float curve2, - ActuatorDesiredData *desired, const float period, bool multirotor, bool fixedwing) + ActuatorDesiredData *desired, bool multirotor, bool fixedwing) { - static float lastFilteredResult[MAX_MIX_ACTUATORS]; + const Mixer_t *mixers = (Mixer_t *)&mixerSettings.Mixer1Type; // pointer to array of mixers in UAVObjects const Mixer_t *mixer = &mixers[index]; float differential = 1.0f; @@ -589,46 +581,12 @@ float ProcessMixer(const int index, const float curve1, const float curve2, (((float)mixer->matrix[MIXERSETTINGS_MIXER1VECTOR_PITCH]) * desired->Pitch) + (((float)mixer->matrix[MIXERSETTINGS_MIXER1VECTOR_YAW]) * desired->Yaw)) / 128.0f; - // note: no feedforward for reversable motors yet for safety reasons if (mixer->type == MIXERSETTINGS_MIXER1TYPE_MOTOR) { if (!multirotor) { // we allow negative throttle with a multirotor if (result < 0.0f) { // zero throttle result = 0.0f; } } - - if (!fixedwing) { - // feed forward, do not apply to fixedwing - float accumulator = filterAccumulator[index]; - accumulator += (result - lastResult[index]) * mixerSettings.FeedForward; - lastResult[index] = result; - result += accumulator; - if (period > 0.0f) { - if (accumulator > 0.0f) { - float invFilter = period / mixerSettings.AccelTime; - if (invFilter > 1) { - invFilter = 1; - } - accumulator -= accumulator * invFilter; - } else { - float invFilter = period / mixerSettings.DecelTime; - if (invFilter > 1) { - invFilter = 1; - } - accumulator -= accumulator * invFilter; - } - } - filterAccumulator[index] = accumulator; - result += accumulator; - - // acceleration limit - float dt = result - lastFilteredResult[index]; - float maxDt = mixerSettings.MaxAccel * period; - if (dt > maxDt) { // we are accelerating too hard - result = lastFilteredResult[index] + maxDt; - } - lastFilteredResult[index] = result; - } } return result; diff --git a/ground/gcs/src/plugins/config/airframe.ui b/ground/gcs/src/plugins/config/airframe.ui dissimilarity index 81% index e08ab3014..92353fbd4 100644 --- a/ground/gcs/src/plugins/config/airframe.ui +++ b/ground/gcs/src/plugins/config/airframe.ui @@ -1,1006 +1,298 @@ - - - AircraftWidget - - - - 0 - 0 - 880 - 608 - - - - Form - - - - 0 - - - - - 0 - - - 0 - - - 0 - - - 9 - - - - - - 0 - 0 - - - - Vehicle name - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 6 - 20 - - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - 20 - - - Enter name of vehicle. Max 20 characters. - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 20 - 20 - - - - - - - - Vehicle Setup Wizard... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Qt::LeftToRight - - - false - - - #vehicleTypeFrame{ - color: rgb(180, 180, 180); - margin-top: -1px; -} - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - 0 - - - - true - - - Mixer Settings - - - - 9 - - - 9 - - - 9 - - - 9 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 255 - 255 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 232 - 232 - 232 - - - - - - - 232 - 232 - 232 - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - 0 - 0 - 820 - 435 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - QFrame::NoFrame - - - -1 - - - - - - - - - - - - true - - - Feed Forward - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - 255 - 255 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 255 - 255 - 255 - - - - - - - 232 - 232 - 232 - - - - - - - - - 232 - 232 - 232 - - - - - - - 232 - 232 - 232 - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - 0 - 0 - 293 - 300 - - - - - 12 - - - 12 - - - 12 - - - 12 - - - - - Feed Forward Configuration - - - - 12 - - - 12 - - - 12 - - - 12 - - - - - - - Decel Time Constant - - - - - - - true - - - Qt::StrongFocus - - - When tuning: Slowly raise decel time from zero to just -under the level where the motor starts to undershoot -its target speed when decelerating. - -Do it after accel time is setup. - - - 3 - - - 100.000000000000000 - - - 0.010000000000000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Accel Time Constant - - - - - - - true - - - Qt::StrongFocus - - - In miliseconds. -When tuning: Slowly raise accel time from zero to just -under the level where the motor starts to overshoot -its target speed. - - - 3 - - - 100.000000000000000 - - - 0.010000000000000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 16777215 - 16 - - - - 1000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - true - - - - 0 - 32 - - - - Qt::StrongFocus - - - Overall level of feed forward (in percentage). - - - 100 - - - 1 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 0 - 32 - - - - Qt::StrongFocus - - - Limits how much the engines can accelerate or decelerate. -In 'units per second', a sound default is 1000. - - - 500 - - - 2000 - - - 1000 - - - Qt::Horizontal - - - false - - - false - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16 - - - - MaxAccel - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 30 - 0 - - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - FeedForward - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 267 - 20 - - - - - - - - Qt::StrongFocus - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:10pt;">Beware! Check </span><span style=" font-family:'Sans'; font-size:10pt; font-weight:600;">all three</span><span style=" font-family:'Sans'; font-size:10pt;"> checkboxes to test Feed Forward.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:10pt;">It will run only if your airframe armed.</span></p></body></html> - - - - - - - - - - Qt::StrongFocus - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:10pt;">Beware! Check </span><span style=" font-family:'Sans'; font-size:10pt; font-weight:600;">all three</span><span style=" font-family:'Sans'; font-size:10pt;"> checkboxes to test Feed Forward.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:10pt;">It will run only if your airframe armed.</span></p></body></html> - - - - - - - - - - Qt::StrongFocus - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:10pt;">Beware! Check </span><span style=" font-family:'Sans'; font-size:10pt; font-weight:600;">all three</span><span style=" font-family:'Sans'; font-size:10pt;"> checkboxes to test Feed Forward.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:10pt;">It will run only if your airframe armed.</span></p></body></html> - - - Enable FF tuning - - - - - - - Qt::Horizontal - - - - 267 - 20 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 40 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> -<tr> -<td style="border: none;"> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD REQUIRES CAUTION</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</span></p></td></tr></table></body></html> - - - - - - - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 9 - - - - - - - - 4 - - - - - Qt::Horizontal - - - - 5 - 25 - - - - - - - - - 0 - 0 - - - - - 25 - 25 - - - - Takes you to the wiki page - - - - - - - :/core/images/helpicon.svg:/core/images/helpicon.svg - - - - 25 - 25 - - - - true - - - - - - - Send to board, but don't save permanently (flash or SD). - - - Apply - - - - - - - Applies and Saves all settings to flash or SD depending on board. - - - Save - - - - - - - - - - QTabBar - QWidget -
qtabbar.h
- 1 -
-
- - nameEdit - vehicleSetupWizardButton - airframesScrollArea - scrollArea_2 - decelTime - accelTime - feedForwardSlider - maxAccelSlider - ffTestBox1 - ffTestBox2 - ffTestBox3 - textBrowser - airframeHelp - saveAircraftToRAM - saveAircraftToSD - tabWidget - - - - - - - feedForwardSlider - valueChanged(int) - feedForwardSliderValue - setNum(int) - - - 248 - 103 - - - 146 - 107 - - - - - maxAccelSlider - valueChanged(int) - maxAccelSliderValue - setNum(int) - - - 272 - 214 - - - 127 - 214 - - - - -
+ + + AircraftWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 9 + + + + + + 0 + 0 + + + + Vehicle name + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 6 + 20 + + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + + + + 20 + + + Enter name of vehicle. Max 20 characters. + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 20 + 20 + + + + + + + + Vehicle Setup Wizard... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + false + + + #vehicleTypeFrame{ + color: rgb(180, 180, 180); + margin-top: -1px; +} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + true + + + + QFrame::NoFrame + + + -1 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 9 + + + + + + + + 4 + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + 0 + 0 + + + + + 25 + 25 + + + + Takes you to the wiki page + + + + + + + :/core/images/helpicon.svg:/core/images/helpicon.svg + + + + 25 + 25 + + + + true + + + + + + + Send to board, but don't save permanently (flash or SD). + + + Apply + + + + + + + Applies and Saves all settings to flash or SD depending on board. + + + Save + + + + + + + + + + QTabBar + QWidget +
qtabbar.h
+ 1 +
+
+ + nameEdit + vehicleSetupWizardButton + airframeHelp + saveAircraftToRAM + saveAircraftToSD + + + + + +
diff --git a/ground/gcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/gcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index d65652927..08f5a03a3 100644 --- a/ground/gcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/gcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -310,9 +310,6 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() Q_ASSERT(mixer); - // Remove Feed Forward, it is pointless on a plane: - setMixerValue(mixer, "FeedForward", 0.0); - // Set the throttle curve setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->fixedWingThrottle->getCurve()); diff --git a/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index b82d27e33..ec94ba07b 100644 --- a/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/gcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -2,6 +2,7 @@ ****************************************************************************** * * @file configgroundvehiclemwidget.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. * @author K. Sebesta & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ @@ -353,9 +354,6 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() // Save the curve (common to all ground vehicle frames) UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - // Remove Feed Forward, it is pointless on a ground vehicle: - setMixerValue(mixer, "FeedForward", 0.0); - // set the throttle curves setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve()); setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve()); diff --git a/ground/gcs/src/plugins/config/configvehicletypewidget.cpp b/ground/gcs/src/plugins/config/configvehicletypewidget.cpp index 00d3d3811..4010c19c9 100644 --- a/ground/gcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/gcs/src/plugins/config/configvehicletypewidget.cpp @@ -135,9 +135,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi addUAVObject("MixerSettings"); addUAVObject("ActuatorSettings"); - m_ffTuningInProgress = false; - m_ffTuningPhase = false; - // The order of the tabs is important since they correspond with the AirframCategory enum m_aircraft->aircraftType->addTab(tr("Multirotor")); m_aircraft->aircraftType->addTab(tr("Fixed Wing")); @@ -148,24 +145,11 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi // Connect aircraft type selection dropbox to callback function connect(m_aircraft->aircraftType, SIGNAL(currentChanged(int)), this, SLOT(switchAirframeType(int))); - // Connect the three feed forward test checkboxes - connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); - connect(m_aircraft->ffTestBox2, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); - connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); - // Connect the help pushbutton connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); refreshWidgetsValues(); - // register FF widgets for dirty state management - addWidget(m_aircraft->feedForwardSlider); - addWidget(m_aircraft->accelTime); - addWidget(m_aircraft->decelTime); - addWidget(m_aircraft->maxAccelSlider); - addWidget(m_aircraft->ffTestBox1); - addWidget(m_aircraft->ffTestBox2); - addWidget(m_aircraft->ffTestBox3); addWidget(m_aircraft->nameEdit); disableMouseWheelEvents(); @@ -183,7 +167,6 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() void ConfigVehicleTypeWidget::switchAirframeType(int index) { m_aircraft->airframesWidget->setCurrentWidget(getVehicleConfigWidget(index)); - m_aircraft->tabWidget->setTabEnabled(1, index != 1); } /** @@ -247,7 +230,6 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *object) } m_aircraft->nameEdit->setText(name); - updateFeedForwardUI(); setDirty(dirty); } @@ -281,17 +263,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() field->setValue(airframeType); } - // Update feed forward settings - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - QPointer vconfig = new VehicleConfig(); - - vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0); - vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value()); - vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); - vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); - field = system->getField(QString("VehicleName")); Q_ASSERT(field); QString name = m_aircraft->nameEdit->text(); @@ -306,7 +277,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() // call refreshWidgetsValues() to reflect actual saved values refreshWidgetsValues(); ConfigTaskWidget::updateObjectsFromWidgets(); - updateFeedForwardUI(); } int ConfigVehicleTypeWidget::frameCategory(QString frameType) @@ -373,86 +343,6 @@ VehicleConfig *ConfigVehicleTypeWidget::createVehicleConfigWidget(int frameCateg } /** - Enables and runs feed forward testing - */ -void ConfigVehicleTypeWidget::enableFFTest() -{ - // Role: - // - Check if all three checkboxes are checked - // - Every other timer event: toggle engine from 45% to 55% - // - Every other time event: send FF settings to flight FW - if (m_aircraft->ffTestBox1->isChecked() && m_aircraft->ffTestBox2->isChecked() - && m_aircraft->ffTestBox3->isChecked()) { - if (!m_ffTuningInProgress) { - // Initiate tuning: - UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject( - QString("ManualControlCommand"))); - UAVObject::Metadata mdata = obj->getMetadata(); - m_accInitialData = mdata; - UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY); - obj->setMetadata(mdata); - } - // Depending on phase, either move actuator or send FF settings: - if (m_ffTuningPhase) { - // Send FF settings to the board - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - QPointer vconfig = new VehicleConfig(); - - // Update feed forward settings - vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0); - vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value()); - vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); - vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); - mixer->updated(); - } else { - // Toggle motor state - UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject( - QString("ManualControlCommand"))); - double value = obj->getField("Throttle")->getDouble(); - double target = (value < 0.5) ? 0.55 : 0.45; - obj->getField("Throttle")->setValue(target); - obj->updated(); - } - m_ffTuningPhase = !m_ffTuningPhase; - m_ffTuningInProgress = true; - QTimer::singleShot(1000, this, SLOT(enableFFTest())); - } else { - // - If no: disarm timer, restore actuatorcommand metadata - // Disarm! - if (m_ffTuningInProgress) { - m_ffTuningInProgress = false; - UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject( - QString("ManualControlCommand"))); - UAVObject::Metadata mdata = obj->getMetadata(); - mdata = m_accInitialData; // Restore metadata - obj->setMetadata(mdata); - } - } -} - -/** - Updates the custom airframe settings based on the current airframe. - - Note: does NOT ask for an object refresh itself! - */ -void ConfigVehicleTypeWidget::updateFeedForwardUI() -{ - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - - Q_ASSERT(mixer); - - QPointer vconfig = new VehicleConfig(); - - // Update feed forward settings - m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer, "FeedForward") * 100); - m_aircraft->accelTime->setValue(vconfig->getMixerValue(mixer, "AccelTime")); - m_aircraft->decelTime->setValue(vconfig->getMixerValue(mixer, "DecelTime")); - m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer, "MaxAccel")); -} - -/** Opens the wiki from the user's default browser */ void ConfigVehicleTypeWidget::openHelp() diff --git a/ground/gcs/src/plugins/config/configvehicletypewidget.h b/ground/gcs/src/plugins/config/configvehicletypewidget.h index 3680e928d..28e8beaf7 100644 --- a/ground/gcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/gcs/src/plugins/config/configvehicletypewidget.h @@ -2,6 +2,7 @@ ****************************************************************************** * * @file configairframetwidget.h + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ @@ -86,17 +87,9 @@ private: VehicleConfig *getVehicleConfigWidget(int frameCategory); VehicleConfig *createVehicleConfigWidget(int frameCategory); - // Feed Forward - void updateFeedForwardUI(); - - bool m_ffTuningInProgress; - bool m_ffTuningPhase; - UAVObject::Metadata m_accInitialData; - private slots: void switchAirframeType(int index); void openHelp(); - void enableFFTest(); }; #endif // CONFIGVEHICLETYPEWIDGET_H diff --git a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index 4e330847c..aea306f20 100644 --- a/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/gcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -2,6 +2,7 @@ ****************************************************************************** * * @file vehicleconfigurationhelper.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup * @{ @@ -1013,12 +1014,6 @@ void VehicleConfigurationHelper::resetVehicleConfig() // Reset all vehicle data MixerSettings *mSettings = MixerSettings::GetInstance(m_uavoManager); - // 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"; for (int i = 1; i <= 2; i++) { diff --git a/shared/uavobjectdefinition/mixersettings.xml b/shared/uavobjectdefinition/mixersettings.xml index 29fe9fd5a..b9349b03a 100644 --- a/shared/uavobjectdefinition/mixersettings.xml +++ b/shared/uavobjectdefinition/mixersettings.xml @@ -1,16 +1,12 @@ Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType - - + - - - - - + + @@ -83,10 +79,10 @@ - + - + -- 2.11.4.GIT