|
QGroundControl
Ground Control Station for MAVLink Drones
|
Simulates the PX4 commander magnetometer and accelerometer calibration protocols for MockLink. More...
#include <MockLinkPX4Calibration.h>
Public Types | |
| enum class | Pose { None = -1 , TailDown = 0 , NoseDown , Left , Right , UpsideDown , RightSideUp } |
| Vehicle poses. Order matches the PX4 detect_orientation_return enum. More... | |
Public Member Functions | |
| MockLinkPX4Calibration (MockLink *mockLink) | |
| void | startMagCalibration () |
| void | startAccelCalibration () |
| bool | cancel () |
| bool | calibrationActive () const |
| void | setPose (Pose pose) |
| void | run10HzTasks () |
| Called by MockLink::run10HzTasks on the worker thread. | |
Static Public Attributes | |
| static constexpr int | kSideCount = 6 |
Simulates the PX4 commander magnetometer and accelerometer calibration protocols for MockLink.
Replays the [cal] STATUSTEXT protocol emitted by the PX4 firmware (src/modules/commander/mag_calibration.cpp, accelerometer_calibration.cpp and calibration_routines.cpp). Magnetometer:
[cal] calibration started: 2 mag [cal] <side> orientation detected [cal] <side> side calibration: progress <N> [cal] <side> side done, rotate to a different side [cal] progress <100> [cal] calibration done: mag
Accelerometer:
[cal] calibration started: 2 accel [cal] <side> orientation detected [cal] Hold still, measuring <side> side [cal] <side> side result: [x y z] [cal] progress <17*doneCount> [cal] <side> side done, rotate to a different side [cal] calibration done: accel
The simulation is pose-driven: a unit test places the simulated vehicle into a pose with setPose(). On subsequent 10Hz ticks the state machine detects the orientation, simulates the rotation/sampling phase and completes the side. Setting a pose for an already completed side emits "[cal] <side> side already completed", matching firmware behavior.
All six sides are required, matching CAL_MAG_SIDES=63 in PX4MockLink.params.
An all-zero MAV_CMD_PREFLIGHT_CALIBRATION while a calibration is active cancels it with "[cal] calibration cancelled" (see PX4 calibrate_cancel_check()).
Definition at line 40 of file MockLinkPX4Calibration.h.
|
strong |
Vehicle poses. Order matches the PX4 detect_orientation_return enum.
Definition at line 44 of file MockLinkPX4Calibration.h.
|
explicit |
Definition at line 32 of file MockLinkPX4Calibration.cc.
| bool MockLinkPX4Calibration::calibrationActive | ( | ) | const |
Definition at line 79 of file MockLinkPX4Calibration.cc.
| bool MockLinkPX4Calibration::cancel | ( | ) |
Handles an all-zero MAV_CMD_PREFLIGHT_CALIBRATION (cancel request).
Definition at line 62 of file MockLinkPX4Calibration.cc.
References MockLink::sendStatusTextMessage().
| void MockLinkPX4Calibration::run10HzTasks | ( | ) |
Called by MockLink::run10HzTasks on the worker thread.
Definition at line 91 of file MockLinkPX4Calibration.cc.
References kAccelDeviceId, kMagDeviceId, MockLink::sendStatusTextMessage(), and MockLink::setInt32ParamValue().
Referenced by MockLink::run10HzTasks().
| void MockLinkPX4Calibration::setPose | ( | Pose | pose | ) |
Test API: places the simulated vehicle into the given pose. The state machine advances on subsequent 10Hz ticks. Thread-safe.
Definition at line 85 of file MockLinkPX4Calibration.cc.
Referenced by MockLink::setCalibrationPose().
| void MockLinkPX4Calibration::startAccelCalibration | ( | ) |
Starts simulated accel calibration: sends "[cal] calibration started: 2 accel" and resets the side state machine.
Definition at line 42 of file MockLinkPX4Calibration.cc.
| void MockLinkPX4Calibration::startMagCalibration | ( | ) |
Starts simulated mag calibration: sends "[cal] calibration started: 2 mag" and resets the side state machine.
Definition at line 37 of file MockLinkPX4Calibration.cc.
|
staticconstexpr |
Definition at line 53 of file MockLinkPX4Calibration.h.