From 6b59739c4768165fa40650df7bbd950f7e85cc5a Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Tue, 19 May 2015 13:16:03 +0200 Subject: [PATCH] PX4 Autopilot plugin: Allow horizon level calibration --- src/AutoPilotPlugins/PX4/SensorsComponent.qml | 20 ++++++++++++++++++- .../PX4/SensorsComponentController.cc | 6 ++++++ .../PX4/SensorsComponentController.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.qml b/src/AutoPilotPlugins/PX4/SensorsComponent.qml index eb6abfdf0..7c00bd8bf 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.qml @@ -43,7 +43,8 @@ QGCView { readonly property string compassHelp: "For Compass calibration you will need to rotate your vehicle through a number of positions. For this calibration it is best " + "to be connected to your vehicle via radio instead of USB, since the USB cable will likely get in the way." readonly property string gyroHelp: "For Gyroscope calibration you will need to place your vehicle right side up on solid surface and leave it still." - readonly property string accelHelp: "For Accelerometer calibration you will need to place your vehicle on all six sides and hold it still in each orientation for a few seconds." + readonly property string accelHelp: "For Accelerometer calibration you will need to place your vehicle on all six sides on a level surface and hold it still in each orientation for a few seconds." + readonly property string levelHelp: "To level the horizon you need to place the vehicle in its level flight position." readonly property string airspeedHelp: "For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor." readonly property string statusTextAreaDefaultText: compassHelp + "\n\n" + gyroHelp + "\n\n" + accelHelp + "\n\n" + airspeedHelp + "\n\n" @@ -128,6 +129,8 @@ QGCView { controller.calibrateGyro() } else if (preCalibrationDialogType == "accel") { controller.calibrateAccel() + } else if (preCalibrationDialogType == "level") { + controller.calibrateLevel() } else if (preCalibrationDialogType == "compass") { controller.calibrateCompass() } else if (preCalibrationDialogType == "airspeed") { @@ -330,6 +333,21 @@ QGCView { } } + IndicatorButton { + property Fact fact: Fact { name: "SENS_BOARD_X_OFF" } + + id: levelButton + width: parent.buttonWidth + text: "Level Horizon" + indicatorGreen: fact.value != 0 + + onClicked: { + preCalibrationDialogType = "level" + preCalibrationDialogHelp = levelHelp + showDialog(preCalibrationDialogComponent, "Level Horizon", 50, StandardButton.Cancel | StandardButton.Ok) + } + } + IndicatorButton { property Fact fact: Fact { name: "SENS_DPRES_OFF" } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc index c22b2f570..ebeec5f5e 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc @@ -191,6 +191,12 @@ void SensorsComponentController::calibrateAccel(void) _uas->startCalibration(UASInterface::StartCalibrationAccel); } +void SensorsComponentController::calibrateLevel(void) +{ + _startLogCalibration(); + _uas->startCalibration(UASInterface::StartCalibrationLevel); +} + void SensorsComponentController::calibrateAirspeed(void) { _startLogCalibration(); diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentController.h b/src/AutoPilotPlugins/PX4/SensorsComponentController.h index fac472619..41a17e486 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentController.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponentController.h @@ -85,6 +85,7 @@ public: Q_INVOKABLE void calibrateCompass(void); Q_INVOKABLE void calibrateGyro(void); Q_INVOKABLE void calibrateAccel(void); + Q_INVOKABLE void calibrateLevel(void); Q_INVOKABLE void calibrateAirspeed(void); Q_INVOKABLE void cancelCalibration(void); -- 2.22.0