From 43ebc19a0644f32b5f604d86b46146b0b95f3a29 Mon Sep 17 00:00:00 2001 From: lbgos <285507185+lbgos@users.noreply.github.com> Date: Mon, 12 Oct 2026 00:23:31 +0300 Subject: [PATCH] Exercise installed Basalt defaults in the complete test suite --- tests/tests_quatexpmap.cpp | 12 ++++++++---- tests/tests_slam_recovery.cpp | 11 +++++++---- tests/tests_slam_restart.cpp | 13 ++++++++----- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/tests_quatexpmap.cpp b/tests/tests_quatexpmap.cpp index 88eb89d03..bebe479c7 100644 --- a/tests/tests_quatexpmap.cpp +++ b/tests/tests_quatexpmap.cpp @@ -50,19 +50,23 @@ TEST_CASE("m_quatexpmap") INFO("vel=" << vel.x << ", " << vel.y << ", " << vel.z); INFO("new_vel=" << new_vel.x << ", " << new_vel.y << ", " << new_vel.z); - CHECK(m_vec3_len(new_vel - vel) <= 0.001); + // At exactly 180 degrees either axis sign describes the same shortest rotation. + bool half_turn = std::abs(m_vec3_len(vel) * dt - M_PI) <= 0.000001; + CHECK((m_vec3_len(new_vel - vel) <= 0.001 || + (half_turn && m_vec3_len(new_vel + vel) <= 0.001))); } } } SECTION("Test quat_exp and quat_ln are inverses") { - // We use rotations with less than PI radians as quat_ln will return the negative rotation otherwise + // This API takes half-Rodrigues vectors. Its shortest-rotation log is inverse + // inside the PI/2 vector-norm domain, corresponding to rotations below PI. vector aas = { {0, 0, 0}, axis1 * (float)M_PI * 0.01f, - axis2 * (float)M_PI * 0.5f, - axis3 * (float)M_PI * 0.99f, + axis2 * (float)M_PI * 0.25f, + axis3 * (float)M_PI * 0.49f, }; for (xrt_vec3 aa : aas) { diff --git a/tests/tests_slam_recovery.cpp b/tests/tests_slam_recovery.cpp index 3fab51dc0..641824877 100644 --- a/tests/tests_slam_recovery.cpp +++ b/tests/tests_slam_recovery.cpp @@ -13,6 +13,7 @@ #include #include #include +#include struct Motion { @@ -76,9 +77,6 @@ render(xrt_frame *frame, double baseline, double t) int main() { - const char *library = std::getenv("VIT_SYSTEM_LIBRARY_PATH"); - if (!library) - return 77; t_slam_calibration calibration{}; const char *camera_count = std::getenv("SLAM_TEST_CAM_COUNT"); const int cameras = camera_count && std::strcmp(camera_count, "5") == 0 ? 5 : 2; @@ -105,7 +103,12 @@ main() } t_slam_tracker_config config{}; t_slam_fill_default_config(&config); - config.vit_system_library_path = library; + void *library = dlopen(config.vit_system_library_path, RTLD_LAZY | RTLD_LOCAL); + if (!library) { + puts("VIT backend unavailable for the recovery check"); + return std::getenv("VIT_SYSTEM_LIBRARY_PATH") ? 1 : 77; + } + dlclose(library); config.cam_count = cameras; config.submit_from_start = true; config.slam_calib = &calibration; diff --git a/tests/tests_slam_restart.cpp b/tests/tests_slam_restart.cpp index 7d2c8f4f9..b7ad1fe6d 100644 --- a/tests/tests_slam_restart.cpp +++ b/tests/tests_slam_restart.cpp @@ -11,16 +11,13 @@ #include #include #include +#include #ifdef SLAM_TEST_HAVE_TBB #include #endif int main() { - if (!std::getenv("VIT_SYSTEM_LIBRARY_PATH")) { - puts("Set VIT_SYSTEM_LIBRARY_PATH to run the backend lifecycle check"); - return 77; - } t_slam_calibration calibration{}; calibration.cam_count = 2; // Use the default Basalt pipeline IMU rate for this lifecycle-only check. @@ -48,7 +45,13 @@ main() // Exercise the production default. The backend must advertise safe recreation. t_slam_tracker_config config{}; t_slam_fill_default_config(&config); - config.vit_system_library_path = std::getenv("VIT_SYSTEM_LIBRARY_PATH"); + // Resolve the installed backend exactly as the ordinary driver launch does. + void *library = dlopen(config.vit_system_library_path, RTLD_LAZY | RTLD_LOCAL); + if (!library) { + puts("VIT backend unavailable for the lifecycle check"); + return std::getenv("VIT_SYSTEM_LIBRARY_PATH") ? 1 : 77; + } + dlclose(library); config.cam_count = 2; config.submit_from_start = true; config.slam_calib = &calibration;