From 78e025af392a3c2f41ffd701a6df9c17cd8a245c Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Fri, 23 Jul 2021 20:49:30 +0100 Subject: [PATCH] AP_Compass: add Calibrator index test --- .../CompassCalibrator_index_test.cpp | 52 +++++++++++++++++++ .../CompassCalibrator_index_test/wscript | 7 +++ 2 files changed, 59 insertions(+) create mode 100644 libraries/AP_Compass/examples/CompassCalibrator_index_test/CompassCalibrator_index_test.cpp create mode 100644 libraries/AP_Compass/examples/CompassCalibrator_index_test/wscript diff --git a/libraries/AP_Compass/examples/CompassCalibrator_index_test/CompassCalibrator_index_test.cpp b/libraries/AP_Compass/examples/CompassCalibrator_index_test/CompassCalibrator_index_test.cpp new file mode 100644 index 0000000000..ad6ba6b861 --- /dev/null +++ b/libraries/AP_Compass/examples/CompassCalibrator_index_test/CompassCalibrator_index_test.cpp @@ -0,0 +1,52 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ +#include +#include +#include + +void setup(); +void loop(); + +const AP_HAL::HAL& hal = AP_HAL::get_HAL(); + +class CompassCalibratorAccess : public CompassCalibrator{ +public: + Rotation auto_rotation_index_test(uint8_t n) { return auto_rotation_index(n);} + bool right_angle_rotation_test(Rotation r) { return right_angle_rotation(r);} + +}; + + +CompassCalibratorAccess cal; + +/* + * rotation tests + */ +void setup(void) +{ + hal.console->begin(115200); + hal.console->printf("\n\ncalibration index test\n\n"); + + for (uint8_t n=0; n < ROTATION_MAX; n++) { + Rotation r = cal.auto_rotation_index_test(n); + hal.console->printf("index: %i got %i%s\n",n,r,cal.right_angle_rotation_test(Rotation(n)) ? ", R" : ""); + } + + hal.console->printf("rotation unit tests done\n\n"); +} + +void loop(void) {} + +AP_HAL_MAIN(); diff --git a/libraries/AP_Compass/examples/CompassCalibrator_index_test/wscript b/libraries/AP_Compass/examples/CompassCalibrator_index_test/wscript new file mode 100644 index 0000000000..719ec151ba --- /dev/null +++ b/libraries/AP_Compass/examples/CompassCalibrator_index_test/wscript @@ -0,0 +1,7 @@ +#!/usr/bin/env python +# encoding: utf-8 + +def build(bld): + bld.ap_example( + use='ap', + )