From db63f73859b7a656944f16cd5c74fd96f2b3ae94 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Sun, 11 Nov 2012 15:01:30 +0200 Subject: [PATCH 1/2] GCS vehicle config: do not reset existing camera/accessory mixers [OP-691] Still no fix for helicopter config (some code refactoring is desired). --- HISTORY.txt | 4 +++ KNOWN_ISSUES.txt | 1 + .../configfixedwingwidget.cpp | 31 ++++--------------- .../configgroundvehiclewidget.cpp | 30 ++++-------------- .../configmultirotorwidget.cpp | 8 +---- .../config/cfg_vehicletypes/vehicleconfig.cpp | 12 +++++++ .../config/cfg_vehicletypes/vehicleconfig.h | 1 + 7 files changed, 31 insertions(+), 56 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index 513b368a5..b370a0c29 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,5 +1,9 @@ Short summary of changes. For a complete list see the git log. +2012-11-11 +[OP-691] Camera/accessory mixers won't be reset when a vehicle configuration changed. +Still no fix for helicopter configuration changes, though (some code refactoring is desired). + 2012-10-06 Receiver port can now be configured as PPM *and* PWM inputs. Pin 1 is PPM, other pins are PWM inputs. diff --git a/KNOWN_ISSUES.txt b/KNOWN_ISSUES.txt index 303e6319f..e260cd3ac 100644 --- a/KNOWN_ISSUES.txt +++ b/KNOWN_ISSUES.txt @@ -8,3 +8,4 @@ + XAircraft ESCs uses non-standard PPM range which may cause issues with Vehicle Wizard. + Spectrum Satellite Receivers setup in Radio Wizard may have wrong protocol set. + Old Intel 965 have an OpenGL bug that turns the QML PFD black and while. ++ [OP-691] Helicopter configuration change still resets camera/accessory mixers (some code refactoring is desired). diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 615ca2ef6..04dc21698 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -281,6 +281,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + resetMixers(mixer); // ... and compute the matrix: // In order to make code a bit nicer, we assume: @@ -288,16 +289,8 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) // 1. Assign the servo/motor/none for each channel - int channel; - //disable all - for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) - { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - resetMixerVector(mixer, channel); - } - //motor - channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; + int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); @@ -359,6 +352,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + resetMixers(mixer); // Save the curve: // ... and compute the matrix: @@ -367,17 +361,10 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) // 1. Assign the servo/motor/none for each channel - int channel; double value; - //disable all - for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) - { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - resetMixerVector(mixer, channel); - } //motor - channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; + int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); @@ -437,6 +424,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + resetMixers(mixer); // Save the curve: // ... and compute the matrix: @@ -445,17 +433,10 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) // 1. Assign the servo/motor/none for each channel - int channel; double value; - //disable all - for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) - { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - resetMixerVector(mixer, channel); - } //motor - channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; + int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 45e94dd8e..3f4a62c87 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -295,16 +295,10 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - - int channel; - //disable all - for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - resetMixerVector(mixer, channel); - } + resetMixers(mixer); //motor - channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; + int channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); @@ -352,16 +346,10 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - - int channel; - //disable all - for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - resetMixerVector(mixer, channel); - } + resetMixers(mixer); //left motor - channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; + int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); @@ -407,15 +395,9 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + resetMixers(mixer); - int channel; - //disable all - for (channel=0; (unsigned int) channel < VehicleConfig::CHANNEL_NUMELEM; channel++) { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - resetMixerVector(mixer, channel); - } - - channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; + int channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index ffceaed18..433642bed 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -1032,13 +1032,7 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - - //disable all - for (int channel=0; channel<(int)VehicleConfig::CHANNEL_NUMELEM; channel++) - { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - resetMixerVector(mixer, channel); - } + resetMixers(mixer); // and enable only the relevant channels: double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 57c5f4654..026ec897f 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -181,6 +181,18 @@ void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel) } } +// Disable all servo/motor mixers (but keep camera and accessory ones) +void VehicleConfig::resetMixers(UAVDataObject *mixer) +{ + for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) { + QString type = getMixerType(mixer, channel); + if ((type == "Disabled") || (type == "Motor") || (type == "Servo")) { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED); + resetMixerVector(mixer, channel); + } + } +} + double VehicleConfig::getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName) { Q_ASSERT(mixer); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 2c94a045e..828968218 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -127,6 +127,7 @@ class VehicleConfig: public ConfigTaskWidget double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName); void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value); void resetMixerVector(UAVDataObject* mixer, int channel); + void resetMixers(UAVDataObject* mixer); QString getMixerType(UAVDataObject* mixer, int channel); void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType); double getMixerValue(UAVDataObject* mixer, QString elementName); From 9d6810dda834f288c54b4eb50c4077452ebd5b69 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 14 Nov 2012 02:00:26 +0200 Subject: [PATCH 2/2] GCS vehicle config: use better function name for readability [OP-691] --- .../config/cfg_vehicletypes/configfixedwingwidget.cpp | 6 +++--- .../config/cfg_vehicletypes/configgroundvehiclewidget.cpp | 6 +++--- .../config/cfg_vehicletypes/configmultirotorwidget.cpp | 2 +- .../src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp | 2 +- .../src/plugins/config/cfg_vehicletypes/vehicleconfig.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 04dc21698..ac6d91165 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -281,7 +281,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - resetMixers(mixer); + resetMotorAndServoMixers(mixer); // ... and compute the matrix: // In order to make code a bit nicer, we assume: @@ -352,7 +352,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - resetMixers(mixer); + resetMotorAndServoMixers(mixer); // Save the curve: // ... and compute the matrix: @@ -424,7 +424,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - resetMixers(mixer); + resetMotorAndServoMixers(mixer); // Save the curve: // ... and compute the matrix: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 3f4a62c87..a23b758df 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -295,7 +295,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - resetMixers(mixer); + resetMotorAndServoMixers(mixer); //motor int channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; @@ -346,7 +346,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - resetMixers(mixer); + resetMotorAndServoMixers(mixer); //left motor int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; @@ -395,7 +395,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - resetMixers(mixer); + resetMotorAndServoMixers(mixer); int channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 433642bed..7db57f5d1 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -1032,7 +1032,7 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - resetMixers(mixer); + resetMotorAndServoMixers(mixer); // and enable only the relevant channels: double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 026ec897f..64ab037c8 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -182,7 +182,7 @@ void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel) } // Disable all servo/motor mixers (but keep camera and accessory ones) -void VehicleConfig::resetMixers(UAVDataObject *mixer) +void VehicleConfig::resetMotorAndServoMixers(UAVDataObject *mixer) { for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) { QString type = getMixerType(mixer, channel); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 828968218..5f47d0548 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -127,7 +127,7 @@ class VehicleConfig: public ConfigTaskWidget double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName); void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value); void resetMixerVector(UAVDataObject* mixer, int channel); - void resetMixers(UAVDataObject* mixer); + void resetMotorAndServoMixers(UAVDataObject* mixer); QString getMixerType(UAVDataObject* mixer, int channel); void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType); double getMixerValue(UAVDataObject* mixer, QString elementName);