QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MockLinkPX4Calibration.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QMutex>
4
5class MockLink;
6
41{
42public:
53 static constexpr int kSideCount = 6;
54
55 explicit MockLinkPX4Calibration(MockLink *mockLink);
56
60
64
67 void startBaroCalibration(bool fails);
68
71 void startLevelCalibration(bool fails);
72
75 void startGyroCalibration(bool fails);
76
78 void setInlineCalibrationStalls(bool stalls);
79
82 bool cancel();
83
86 bool fail();
87
88 bool calibrationActive() const;
89
92 void setPose(Pose pose);
93
95 void run10HzTasks();
96
97private:
98 enum class CalType {
99 None,
100 Mag,
101 Accel,
102 Baro,
103 Level,
104 Gyro,
105 };
106
107 static QString _calTypeName(CalType calType);
108 void _finishCalibration(CalType calType);
109
110 void _startCalibration(CalType calType);
111 void _sideTick();
112 void _magSideTick();
113 void _accelSideTick();
114 void _detectPose();
115 int _doneCount() const;
116
117 MockLink *_mockLink = nullptr;
118
119 mutable QMutex _mutex;
120 CalType _calType = CalType::None;
121 int _requestedPose = -1;
122 int _activeSide = -1;
123 int _sideTickCount = 0;
124 int _finishTickCount = -1;
125 bool _baroFails = false;
126 bool _levelFails = false;
127 bool _gyroFails = false;
128 bool _inlineStalls = false;
129 bool _sideDone[kSideCount] = {};
130
131 static constexpr int kTicksPerSide = 5;
132 static constexpr int kTicksToFinish = 10;
133};
static constexpr int kSideCount
MockLinkPX4Calibration(MockLink *mockLink)
Pose
Vehicle poses. Order matches the PX4 detect_orientation_return enum.
@ Right
"right" accel [ 0, -g, 0 ]
@ Left
"left" accel [ 0, g, 0 ]
@ NoseDown
"front" accel [ -g, 0, 0 ]
@ RightSideUp
"down" accel [ 0, 0, -g ]
@ UpsideDown
"up" accel [ 0, 0, g ]
@ TailDown
"back" accel [ g, 0, 0 ]
void startGyroCalibration(bool fails)
void startLevelCalibration(bool fails)
void startBaroCalibration(bool fails)
void run10HzTasks()
Called by MockLink::run10HzTasks on the worker thread.
void setInlineCalibrationStalls(bool stalls)
Makes the simulated barometer, level horizon and gyroscope calibrations run until they are cancelled.