From 8ad94d6872b2efda06ea1020a50ec9d8a0fa88ba Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Wed, 16 Dec 2020 18:04:40 -0300 Subject: [PATCH] Sub motor test fixes (#9243) * APMSubMotorComponent.qml: do not send motor test messages after disarm command * Vehicle: Change signature of motorTest to allow not showing errors * APMMotorComponent.qml: Update to use new signature of motorTest() * APMSubMotorComponent.qml: Update to use new signature of motorTest() with showErrors=false * MotorComponent.qml: Update to use new signature of motorTest() --- src/AutoPilotPlugins/APM/APMMotorComponent.qml | 2 +- src/AutoPilotPlugins/APM/APMSubMotorComponent.qml | 6 +++--- src/AutoPilotPlugins/Common/MotorComponent.qml | 2 +- src/Vehicle/Vehicle.cc | 4 ++-- src/Vehicle/Vehicle.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMMotorComponent.qml b/src/AutoPilotPlugins/APM/APMMotorComponent.qml index 9be8d51..cd39f3c 100644 --- a/src/AutoPilotPlugins/APM/APMMotorComponent.qml +++ b/src/AutoPilotPlugins/APM/APMMotorComponent.qml @@ -69,7 +69,7 @@ SetupPage { updateValueWhileDragging: false onValueChanged: { - controller.vehicle.motorTest(index + 1, value, value == 0 ? 0 : _motorTimeoutSecs) + controller.vehicle.motorTest(index + 1, value, value == 0 ? 0 : _motorTimeoutSecs, true) if (value != 0) { motorTimer.restart() } diff --git a/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml b/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml index 9400f20..695ec30 100644 --- a/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml +++ b/src/AutoPilotPlugins/APM/APMSubMotorComponent.qml @@ -279,7 +279,7 @@ SetupPage { id: timer interval: 50 repeat: true - running: canRunManualTest + running: canRunManualTest && shouldRunManualTest onTriggered: { if (controller.vehicle.armed) { @@ -288,9 +288,9 @@ SetupPage { var reversed = controller.getParameterFact(-1, "MOT_" + (_lastIndex + 1) + "_DIRECTION").value == -1 if (reversed) { - controller.vehicle.motorTest(_lastIndex, 100 - slider.motorSlider.value, 0) + controller.vehicle.motorTest(_lastIndex, 100 - slider.motorSlider.value, 0, false) } else { - controller.vehicle.motorTest(_lastIndex, slider.motorSlider.value, 0) + controller.vehicle.motorTest(_lastIndex, slider.motorSlider.value, 0, false) } } } diff --git a/src/AutoPilotPlugins/Common/MotorComponent.qml b/src/AutoPilotPlugins/Common/MotorComponent.qml index 0d7494c..95812d7 100644 --- a/src/AutoPilotPlugins/Common/MotorComponent.qml +++ b/src/AutoPilotPlugins/Common/MotorComponent.qml @@ -69,7 +69,7 @@ SetupPage { updateValueWhileDragging: false onValueChanged: { - controller.vehicle.motorTest(index + 1, value, value == 0 ? 0 : _motorTimeoutSecs) + controller.vehicle.motorTest(index + 1, value, value == 0 ? 0 : _motorTimeoutSecs, true) if (value != 0) { motorTimer.restart() } diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 4425722..b7eb2e5 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -3150,9 +3150,9 @@ void Vehicle::setSoloFirmware(bool soloFirmware) } } -void Vehicle::motorTest(int motor, int percent, int timeoutSecs) +void Vehicle::motorTest(int motor, int percent, int timeoutSecs, bool showError) { - sendMavCommand(_defaultComponentId, MAV_CMD_DO_MOTOR_TEST, true, motor, MOTOR_TEST_THROTTLE_PERCENT, percent, timeoutSecs, 0, MOTOR_TEST_ORDER_BOARD); + sendMavCommand(_defaultComponentId, MAV_CMD_DO_MOTOR_TEST, showError, motor, MOTOR_TEST_THROTTLE_PERCENT, percent, timeoutSecs, 0, MOTOR_TEST_ORDER_BOARD); } QString Vehicle::brandImageIndoor() const diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 40db328..d6ae66f 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -372,7 +372,7 @@ public: /// @param motor Motor number, 1-based /// @param percent 0-no power, 100-full power /// @param timeoutSec Disabled motor after this amount of time - Q_INVOKABLE void motorTest(int motor, int percent, int timeoutSecs); + Q_INVOKABLE void motorTest(int motor, int percent, int timeoutSecs, bool showError); Q_INVOKABLE void setPIDTuningTelemetryMode(bool pidTuning);