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:
44 enum class Pose {
45 None = -1,
46 TailDown = 0,
47 NoseDown,
48 Left,
49 Right,
52 };
53 static constexpr int kSideCount = 6;
54
55 explicit MockLinkPX4Calibration(MockLink *mockLink);
56
60
64
67 bool cancel();
68
69 bool calibrationActive() const;
70
73 void setPose(Pose pose);
74
76 void run10HzTasks();
77
78private:
79 enum class CalType {
80 None,
81 Mag,
82 Accel,
83 };
84
85 void _startCalibration(CalType calType);
86 void _sideTick();
87 void _magSideTick();
88 void _accelSideTick();
89 void _detectPose();
90 int _doneCount() const;
91
92 MockLink *_mockLink = nullptr;
93
94 mutable QMutex _mutex;
95 CalType _calType = CalType::None;
96 int _requestedPose = -1;
97 int _activeSide = -1;
98 int _sideTickCount = 0;
99 int _finishTickCount = -1;
100 bool _sideDone[kSideCount] = {};
101
102 static constexpr int kTicksPerSide = 5;
103 static constexpr int kTicksToFinish = 10;
104};
Simulates the PX4 commander magnetometer and accelerometer calibration protocols for MockLink.
static constexpr int kSideCount
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 run10HzTasks()
Called by MockLink::run10HzTasks on the worker thread.