Browse Source

Warn on reversed throttle (#3655)

QGC4.4
Don Gagne 9 years ago committed by GitHub
parent
commit
2418d073bc
  1. 3
      src/AutoPilotPlugins/Common/RadioComponent.qml
  2. 118
      src/AutoPilotPlugins/Common/RadioComponentController.cc
  3. 7
      src/AutoPilotPlugins/Common/RadioComponentController.h

3
src/AutoPilotPlugins/Common/RadioComponent.qml

@ -63,7 +63,8 @@ QGCView {
} }
onChannelCountChanged: updateChannelCount() onChannelCountChanged: updateChannelCount()
onFunctionMappingChangedAPMReboot: showMessage(qsTr("Reboot required"), qsTr("Your stick mappings have changed, you must reboot the vehicle for correct operation."), StandardButton.Ok) onFunctionMappingChangedAPMReboot: showMessage(qsTr("Reboot required"), qsTr("Your stick mappings have changed, you must reboot the vehicle for correct operation."), StandardButton.Ok)
onThrottleReversedCalFailure: showMessage(qsTr("Throttle channel reversed"), qsTr("Calibration failed. The throttle channel on your transmitter is reversed. You must correct this on your transmitter in order to complete calibration."), StandardButton.Ok)
} }
onCompleted: { onCompleted: {

118
src/AutoPilotPlugins/Common/RadioComponentController.cc

@ -325,7 +325,7 @@ void RadioComponentController::_saveAllTrims(void)
// trims reset to correct values. // trims reset to correct values.
for (int i=0; i<_chanCount; i++) { for (int i=0; i<_chanCount; i++) {
qCDebug(RadioComponentControllerLog) << "_saveAllTrims trim" << _rcRawValue[i]; qCDebug(RadioComponentControllerLog) << "_saveAllTrims channel trim" << i<< _rcRawValue[i];
_rgChannelInfo[i].rcTrim = _rcRawValue[i]; _rgChannelInfo[i].rcTrim = _rcRawValue[i];
} }
_advanceState(); _advanceState();
@ -752,71 +752,77 @@ void RadioComponentController::_writeCalibration(void)
_uas->stopCalibration(); _uas->stopCalibration();
} }
_validateCalibration(); if (!_px4Vehicle() && _rgChannelInfo[_rgFunctionChannelMapping[rcCalFunctionThrottle]].reversed) {
// A reversed throttle could lead to dangerous power up issues if the firmware doesn't handle it absolutely correctly in all places.
QString minTpl("RC%1_MIN"); // So in this case fail the calibration for anything other than PX4 which is known to be able to handle this correctly.
QString maxTpl("RC%1_MAX"); emit throttleReversedCalFailure();
QString trimTpl("RC%1_TRIM"); } else {
QString revTpl("RC%1_REV"); _validateCalibration();
// Note that the rc parameters are all float, so you must cast to float in order to get the right QVariant QString minTpl("RC%1_MIN");
for (int chan = 0; chan<_chanMax(); chan++) { QString maxTpl("RC%1_MAX");
struct ChannelInfo* info = &_rgChannelInfo[chan]; QString trimTpl("RC%1_TRIM");
int oneBasedChannel = chan + 1; QString revTpl("RC%1_REV");
if (_px4Vehicle() && _apmPossibleMissingRCChannelParams.contains(chan+1) && !parameterExists(FactSystem::defaultComponentId, minTpl.arg(chan+1))) { // Note that the rc parameters are all float, so you must cast to float in order to get the right QVariant
// RC parameters for this channel are missing from this version of APM for (int chan = 0; chan<_chanMax(); chan++) {
continue; struct ChannelInfo* info = &_rgChannelInfo[chan];
} int oneBasedChannel = chan + 1;
Fact* paramFact = getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(oneBasedChannel)); if (_px4Vehicle() && _apmPossibleMissingRCChannelParams.contains(chan+1) && !parameterExists(FactSystem::defaultComponentId, minTpl.arg(chan+1))) {
if (paramFact) { // RC parameters for this channel are missing from this version of APM
paramFact->setRawValue((float)info->rcTrim); continue;
} }
paramFact = getParameterFact(FactSystem::defaultComponentId, minTpl.arg(oneBasedChannel));
if (paramFact) {
paramFact->setRawValue((float)info->rcMin);
}
paramFact = getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(oneBasedChannel));
if (paramFact) {
paramFact->setRawValue((float)info->rcMax);
}
// For multi-rotor we can determine reverse setting during radio cal. For anything other than multi-rotor, servo installation Fact* paramFact = getParameterFact(FactSystem::defaultComponentId, trimTpl.arg(oneBasedChannel));
// may affect channel reversing so we can't automatically determine it. if (paramFact) {
if (_vehicle->multiRotor()) { paramFact->setRawValue((float)info->rcTrim);
// APM multi-rotor has a backwards interpretation of "reversed" on the Pitch control. So be careful.
float reversedParamValue;
if (_px4Vehicle() || info->function != rcCalFunctionPitch) {
reversedParamValue = info->reversed ? -1.0f : 1.0f;
} else {
reversedParamValue = info->reversed ? 1.0f : -1.0f;
} }
paramFact = getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel)); paramFact = getParameterFact(FactSystem::defaultComponentId, minTpl.arg(oneBasedChannel));
if (paramFact) { if (paramFact) {
paramFact->setRawValue(reversedParamValue); paramFact->setRawValue((float)info->rcMin);
}
paramFact = getParameterFact(FactSystem::defaultComponentId, maxTpl.arg(oneBasedChannel));
if (paramFact) {
paramFact->setRawValue((float)info->rcMax);
} }
}
}
// Write function mapping parameters // For multi-rotor we can determine reverse setting during radio cal. For anything other than multi-rotor, servo installation
for (size_t i=0; i<rcCalFunctionMax; i++) { // may affect channel reversing so we can't automatically determine it.
int32_t paramChannel; if (_vehicle->multiRotor()) {
if (_rgFunctionChannelMapping[i] == _chanMax()) { // APM multi-rotor has a backwards interpretation of "reversed" on the Pitch control. So be careful.
// 0 signals no mapping float reversedParamValue;
paramChannel = 0; if (_px4Vehicle() || info->function != rcCalFunctionPitch) {
} else { reversedParamValue = info->reversed ? -1.0f : 1.0f;
// Note that the channel value is 1-based } else {
paramChannel = _rgFunctionChannelMapping[i] + 1; reversedParamValue = info->reversed ? 1.0f : -1.0f;
}
paramFact = getParameterFact(FactSystem::defaultComponentId, revTpl.arg(oneBasedChannel));
if (paramFact) {
paramFact->setRawValue(reversedParamValue);
}
}
} }
const char* paramName = _functionInfo()[i].parameterName;
if (paramName) {
Fact* paramFact = getParameterFact(FactSystem::defaultComponentId, _functionInfo()[i].parameterName);
if (paramFact && paramFact->rawValue().toInt() != paramChannel) { // Write function mapping parameters
paramFact = getParameterFact(FactSystem::defaultComponentId, _functionInfo()[i].parameterName); for (size_t i=0; i<rcCalFunctionMax; i++) {
if (paramFact) { int32_t paramChannel;
paramFact->setRawValue(paramChannel); if (_rgFunctionChannelMapping[i] == _chanMax()) {
// 0 signals no mapping
paramChannel = 0;
} else {
// Note that the channel value is 1-based
paramChannel = _rgFunctionChannelMapping[i] + 1;
}
const char* paramName = _functionInfo()[i].parameterName;
if (paramName) {
Fact* paramFact = getParameterFact(FactSystem::defaultComponentId, _functionInfo()[i].parameterName);
if (paramFact && paramFact->rawValue().toInt() != paramChannel) {
paramFact = getParameterFact(FactSystem::defaultComponentId, _functionInfo()[i].parameterName);
if (paramFact) {
paramFact->setRawValue(paramChannel);
}
} }
} }
} }

7
src/AutoPilotPlugins/Common/RadioComponentController.h

@ -124,12 +124,15 @@ signals:
void imageHelpChanged(QString source); void imageHelpChanged(QString source);
void transmitterModeChanged(int mode); void transmitterModeChanged(int mode);
// @brief Signalled when in unit test mode and a message box should be displayed by the next button /// Signalled when in unit test mode and a message box should be displayed by the next button
void nextButtonMessageBoxDisplayed(void); void nextButtonMessageBoxDisplayed(void);
// Signaled to QML to indicator reboot is required /// Signalled to QML to indicate reboot is required
void functionMappingChangedAPMReboot(void); void functionMappingChangedAPMReboot(void);
/// Signalled to Qml to indicate cal failure due to reversed throttle
void throttleReversedCalFailure(void);
private slots: private slots:
void _rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels]); void _rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels]);

Loading…
Cancel
Save