|
| 1 | +#include <catch2/catch_all.hpp> |
| 2 | +#include <depthai/depthai.hpp> |
| 3 | +#include <memory> |
| 4 | + |
| 5 | +TEST_CASE("DynamicCalibration - Commands", "[DynamicCalibrationControl]") { |
| 6 | + using DCC = dai::DynamicCalibrationControl; |
| 7 | + |
| 8 | + SECTION("Calibrate command") { |
| 9 | + auto cmd = DCC::calibrate(true); |
| 10 | + REQUIRE(std::holds_alternative<DCC::Commands::Calibrate>(cmd->command)); |
| 11 | + auto& c = std::get<DCC::Commands::Calibrate>(cmd->command); |
| 12 | + REQUIRE(c.force == true); |
| 13 | + } |
| 14 | + |
| 15 | + SECTION("CalibrationQuality command") { |
| 16 | + auto cmd = DCC::calibrationQuality(false); |
| 17 | + REQUIRE(std::holds_alternative<DCC::Commands::CalibrationQuality>(cmd->command)); |
| 18 | + auto& c = std::get<DCC::Commands::CalibrationQuality>(cmd->command); |
| 19 | + REQUIRE(c.force == false); |
| 20 | + } |
| 21 | + |
| 22 | + SECTION("StartCalibration command with custom periods") { |
| 23 | + auto cmd = DCC::startCalibration(1.0f, 10.0f); |
| 24 | + REQUIRE(std::holds_alternative<DCC::Commands::StartCalibration>(cmd->command)); |
| 25 | + auto& c = std::get<DCC::Commands::StartCalibration>(cmd->command); |
| 26 | + REQUIRE(c.loadImagePeriod == Catch::Approx(1.0f)); |
| 27 | + REQUIRE(c.calibrationPeriod == Catch::Approx(10.0f)); |
| 28 | + } |
| 29 | + |
| 30 | + SECTION("StopCalibration command") { |
| 31 | + auto cmd = DCC::stopCalibration(); |
| 32 | + REQUIRE(std::holds_alternative<DCC::Commands::StopCalibration>(cmd->command)); |
| 33 | + } |
| 34 | + |
| 35 | + SECTION("LoadImage command") { |
| 36 | + auto cmd = DCC::loadImage(); |
| 37 | + REQUIRE(std::holds_alternative<DCC::Commands::LoadImage>(cmd->command)); |
| 38 | + } |
| 39 | + |
| 40 | + SECTION("ResetData command") { |
| 41 | + auto cmd = DCC::resetData(); |
| 42 | + REQUIRE(std::holds_alternative<DCC::Commands::ResetData>(cmd->command)); |
| 43 | + } |
| 44 | + |
| 45 | + SECTION("SetPerformanceMode command") { |
| 46 | + auto cmd = DCC::setPerformanceMode(DCC::PerformanceMode::OPTIMIZE_SPEED); |
| 47 | + REQUIRE(std::holds_alternative<DCC::Commands::SetPerformanceMode>(cmd->command)); |
| 48 | + auto& c = std::get<DCC::Commands::SetPerformanceMode>(cmd->command); |
| 49 | + REQUIRE(c.performanceMode == DCC::PerformanceMode::OPTIMIZE_SPEED); |
| 50 | + } |
| 51 | + |
| 52 | + SECTION("ApplyCalibration command") { |
| 53 | + dai::CalibrationHandler calHandler; // Assuming default constructible |
| 54 | + auto cmd = DCC::applyCalibration(calHandler); |
| 55 | + REQUIRE(std::holds_alternative<DCC::Commands::ApplyCalibration>(cmd->command)); |
| 56 | + auto& c = std::get<DCC::Commands::ApplyCalibration>(cmd->command); |
| 57 | + // Optionally verify that calibration matches (if operator== is defined) |
| 58 | + } |
| 59 | +} |
0 commit comments