QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SensorsComponentController.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QTimer>
4#include <QtQmlIntegration/QtQmlIntegration>
5
7
11{
12 Q_OBJECT
13 QML_ELEMENT
14public:
16
25 Q_ENUM(SideCalState)
26
27
38 Q_ENUM(ActiveCalibration)
39
40
47 Q_ENUM(CalibrationResult)
48
50
51
52 Q_PROPERTY(QString calibrationLog READ calibrationLog NOTIFY calibrationLogChanged)
57 Q_PROPERTY(bool sideAlreadyDone MEMBER _sideAlreadyDone NOTIFY orientationCalSidesStateChanged)
61 Q_PROPERTY(bool magCalInProgress MEMBER _magCalInProgress NOTIFY calibrationActiveChanged)
62
63 Q_PROPERTY(bool showOrientationCalArea MEMBER _showOrientationCalArea NOTIFY showOrientationCalAreaChanged)
64
65 Q_PROPERTY(SideCalState orientationCalDownSideState MEMBER _orientationCalDownSideState NOTIFY orientationCalSidesStateChanged)
66 Q_PROPERTY(SideCalState orientationCalUpsideDownSideState MEMBER _orientationCalUpsideDownSideState NOTIFY orientationCalSidesStateChanged)
67 Q_PROPERTY(SideCalState orientationCalLeftSideState MEMBER _orientationCalLeftSideState NOTIFY orientationCalSidesStateChanged)
68 Q_PROPERTY(SideCalState orientationCalRightSideState MEMBER _orientationCalRightSideState NOTIFY orientationCalSidesStateChanged)
69 Q_PROPERTY(SideCalState orientationCalNoseDownSideState MEMBER _orientationCalNoseDownSideState NOTIFY orientationCalSidesStateChanged)
70 Q_PROPERTY(SideCalState orientationCalTailDownSideState MEMBER _orientationCalTailDownSideState NOTIFY orientationCalSidesStateChanged)
71
72 Q_PROPERTY(bool orientationCalDownSideVisible MEMBER _orientationCalDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
73 Q_PROPERTY(bool orientationCalUpsideDownSideVisible MEMBER _orientationCalUpsideDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
74 Q_PROPERTY(bool orientationCalLeftSideVisible MEMBER _orientationCalLeftSideVisible NOTIFY orientationCalSidesVisibleChanged)
75 Q_PROPERTY(bool orientationCalRightSideVisible MEMBER _orientationCalRightSideVisible NOTIFY orientationCalSidesVisibleChanged)
76 Q_PROPERTY(bool orientationCalNoseDownSideVisible MEMBER _orientationCalNoseDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
77 Q_PROPERTY(bool orientationCalTailDownSideVisible MEMBER _orientationCalTailDownSideVisible NOTIFY orientationCalSidesVisibleChanged)
78
79 Q_PROPERTY(bool waitingForCancel MEMBER _waitingForCancel NOTIFY waitingForCancelChanged)
83
84 Q_INVOKABLE void calibrateCompass(void);
85 Q_INVOKABLE void calibrateGyro(void);
86 Q_INVOKABLE void calibrateAccel(void);
87 Q_INVOKABLE void calibrateLevel(void);
88 Q_INVOKABLE void calibrateAirspeed(void);
89 Q_INVOKABLE void calibrateBaro(void);
92 Q_INVOKABLE void calibrateCompassLargeVehicle(double headingDegrees);
93 Q_INVOKABLE void cancelCalibration(void);
94 Q_INVOKABLE bool usingUDPLink(void);
95 Q_INVOKABLE void resetFactoryParameters();
97 Q_INVOKABLE QString deviceDescription(int deviceId) const;
98
100
101 bool largeVehicleCalibrationPending() const { return _largeVehicleCalibrationPending; }
102
103 double calibrationProgress() const { return _calibrationProgress; }
104
105 QString calibrationLog() const { return _calibrationLog; }
106
107 CalibrationResult calibrationResult() const { return _calibrationResult; }
108
109 QString calibrationFailureText() const { return _calibrationFailureText; }
110
112
119
122
124 static QString largeVehicleCommandFailureText(int failureCode);
125
126signals:
134 void magCalComplete(void);
139 void inlineCalibrationFinished(bool success, const QString& message);
141 void largeVehicleCalibrationFinished(bool success, const QString& message);
143
144private slots:
145 void _handleUASTextMessage(quint32 uasId, int compId, int severity, QString text, const QString& description);
146 void _handleLargeVehicleCalibrationMessage(quint32 uasId, int compId, int severity, QString text,
147 const QString& description);
148 void _handleLargeVehicleCommandResult(quint32 vehicleId, int targetComponent, int command, int ackResult,
149 int failureCode);
150 void _largeVehicleCalibrationTimedOut(void);
151 void _handleParametersReset(bool success);
152
153private:
154 void _startLogCalibration(void);
155 void _startVisualCalibration(void);
156 void _setCalibrationProgress(double progress);
157 void _appendStatusLog(const QString& text);
158 void _refreshParams(void);
159 void _watchLargeVehicleCalibration(void);
160 void _stopWatchingLargeVehicleCalibration(void);
161 void _setLargeVehicleCalibrationPending(bool pending);
162 void _hideAllCalAreas(void);
163 void _setAllSidesState(SideCalState state);
164
165 enum StopCalibrationCode {
166 StopCalibrationSuccess,
167 StopCalibrationFailed,
168 StopCalibrationCancelled
169 };
170 void _stopCalibration(StopCalibrationCode code);
171
172 void _updateAndEmitShowOrientationCalArea(bool show);
173 void _setCalibrationResult(CalibrationResult result);
174
175 bool _showGyroCalArea;
176 bool _showOrientationCalArea;
177
178 bool _gyroCalInProgress;
179 bool _magCalInProgress;
180 bool _accelCalInProgress;
181 bool _airspeedCalInProgress;
182 bool _levelCalInProgress;
183 bool _baroCalInProgress;
184
185 bool _orientationCalDownSideVisible;
186 bool _orientationCalUpsideDownSideVisible;
187 bool _orientationCalLeftSideVisible;
188 bool _orientationCalRightSideVisible;
189 bool _orientationCalNoseDownSideVisible;
190 bool _orientationCalTailDownSideVisible;
191
192 SideCalState _orientationCalDownSideState;
193 SideCalState _orientationCalUpsideDownSideState;
194 SideCalState _orientationCalLeftSideState;
195 SideCalState _orientationCalRightSideState;
196 SideCalState _orientationCalNoseDownSideState;
197 SideCalState _orientationCalTailDownSideState;
198
199 bool _unknownFirmwareVersion;
200 bool _waitingForCancel;
201 bool _sideAlreadyDone = false;
202 QString _calibrationLog;
203 CalibrationResult _calibrationResult = CalibrationResultNone;
204 QString _calibrationFailureText;
205 QString _calibrationDetail;
206 double _calibrationProgress = 0;
207
208 static const int _supportedFirmwareCalVersion = 2;
209 QTimer _largeVehicleCalibrationTimer;
210 bool _largeVehicleCalibrationPending = false;
211 static constexpr int _largeVehicleCalibrationTimeoutMs = 5000;
212};
FactPanelController(QObject *parent=nullptr)
CalibrationResult calibrationResult() const
Q_INVOKABLE void calibrateCompassLargeVehicle(double headingDegrees)
void orientationCalSidesVisibleChanged(void)
ActiveCalibration
Calibration which is running through the firmware's [cal] message protocol.
static QString largeVehicleCommandFailureText(int failureCode)
Why the large vehicle compass calibration command failed, from the failureCode of Vehicle::mavCommand...
void calibrationProgressChanged(void)
CalibrationResult
How the last calibration which the page shows in its panel ended.
@ CalibrationResultNone
Running, cancelled, or none has run.
void inlineCalibrationFinished(bool success, const QString &message)
void waitingForCancelChanged(void)
ActiveCalibration activeCalibration() const
static LargeVehicleCalibrationResult largeVehicleCalibrationResult(const QString &text)
What a status text from the vehicle says about the outcome of a large vehicle compass calibration.
@ SideCalStateIncomplete
Calibration running, side not yet calibrated.
@ SideCalStateInProgress
Side actively being calibrated.
@ SideCalStateIdle
No calibration data to show (neutral preview).
@ SideCalStateCompleted
Side calibration complete.
void largeVehicleCalibrationPendingChanged(void)
void orientationCalSidesStateChanged(void)
Q_INVOKABLE QString deviceDescription(int deviceId) const
Chip and bus of a CAL_*_ID device ID parameter value, empty when the ID is not set.
void largeVehicleCalibrationFinished(bool success, const QString &message)
success is false when the firmware reported a failure, message is its text
Q_INVOKABLE void calibrateCompass(void)
What the firmware has logged during the calibration, one message per line.
void calibrationResultChanged(void)
void calibrationActiveChanged(void)
void showOrientationCalAreaChanged(void)
Result of timestamp-based calibration/matching.