mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
tests: Add case for Levenberg-Marquardt optimizer
This commit is contained in:
parent
73dbc712ab
commit
b4a29e8b29
|
@ -10,19 +10,19 @@ if(ANDROID)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(tests
|
set(tests
|
||||||
tests_cxx_wrappers
|
tests_cxx_wrappers
|
||||||
tests_generic_callbacks
|
tests_generic_callbacks
|
||||||
tests_history_buf
|
tests_history_buf
|
||||||
tests_id_ringbuffer
|
tests_id_ringbuffer
|
||||||
tests_input_transform
|
tests_input_transform
|
||||||
tests_json
|
tests_json
|
||||||
tests_lowpass_float
|
tests_lowpass_float
|
||||||
tests_lowpass_integer
|
tests_lowpass_integer
|
||||||
tests_pacing
|
tests_pacing
|
||||||
tests_quatexpmap
|
tests_quatexpmap
|
||||||
tests_rational
|
tests_rational
|
||||||
tests_worker
|
tests_worker
|
||||||
tests_pose
|
tests_pose
|
||||||
)
|
)
|
||||||
if(XRT_HAVE_D3D11)
|
if(XRT_HAVE_D3D11)
|
||||||
list(APPEND tests tests_aux_d3d tests_comp_client_d3d11)
|
list(APPEND tests tests_aux_d3d tests_comp_client_d3d11)
|
||||||
|
@ -30,8 +30,11 @@ endif()
|
||||||
if(XRT_HAVE_VULKAN)
|
if(XRT_HAVE_VULKAN)
|
||||||
list(APPEND tests tests_comp_client_vulkan)
|
list(APPEND tests tests_comp_client_vulkan)
|
||||||
endif()
|
endif()
|
||||||
foreach(testname ${tests})
|
if(XRT_BUILD_DRIVER_HANDTRACKING)
|
||||||
|
list(APPEND tests tests_levenbergmarquardt)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(testname ${tests})
|
||||||
add_executable(${testname} ${testname}.cpp)
|
add_executable(${testname} ${testname}.cpp)
|
||||||
target_link_libraries(${testname} PRIVATE tests_main)
|
target_link_libraries(${testname} PRIVATE tests_main)
|
||||||
target_link_libraries(${testname} PRIVATE aux_util)
|
target_link_libraries(${testname} PRIVATE aux_util)
|
||||||
|
@ -49,6 +52,10 @@ target_link_libraries(tests_quatexpmap PRIVATE aux_math)
|
||||||
target_link_libraries(tests_rational PRIVATE aux_math)
|
target_link_libraries(tests_rational PRIVATE aux_math)
|
||||||
target_link_libraries(tests_pose PRIVATE aux_math)
|
target_link_libraries(tests_pose PRIVATE aux_math)
|
||||||
|
|
||||||
|
if(XRT_BUILD_DRIVER_HANDTRACKING)
|
||||||
|
target_link_libraries(tests_levenbergmarquardt PRIVATE aux_math t_ht_mercury_includes t_ht_mercury_kine_lm_includes t_ht_mercury t_ht_mercury_kine_lm)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(XRT_HAVE_D3D11)
|
if(XRT_HAVE_D3D11)
|
||||||
target_link_libraries(tests_aux_d3d PRIVATE aux_d3d)
|
target_link_libraries(tests_aux_d3d PRIVATE aux_d3d)
|
||||||
target_link_libraries(tests_comp_client_d3d11 PRIVATE comp_client comp_mock)
|
target_link_libraries(tests_comp_client_d3d11 PRIVATE comp_client comp_mock)
|
||||||
|
|
60
tests/tests_levenbergmarquardt.cpp
Normal file
60
tests/tests_levenbergmarquardt.cpp
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright 2022, Collabora, Inc.
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
/*!
|
||||||
|
* @file
|
||||||
|
* @brief Test for Levenberg-Marquardt kinematic optimizer
|
||||||
|
* @author Moses Turner <moses@collabora.com>
|
||||||
|
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||||
|
*/
|
||||||
|
#include "util/u_logging.h"
|
||||||
|
#include "xrt/xrt_defines.h"
|
||||||
|
#include <util/u_worker.hpp>
|
||||||
|
#include <math/m_space.h>
|
||||||
|
#include <math/m_vec3.h>
|
||||||
|
|
||||||
|
#include "kine_common.hpp"
|
||||||
|
#include "lm_interface.hpp"
|
||||||
|
|
||||||
|
#include "catch/catch.hpp"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
#include "fenv.h"
|
||||||
|
|
||||||
|
using namespace xrt::tracking::hand::mercury;
|
||||||
|
|
||||||
|
TEST_CASE("LevenbergMarquardt")
|
||||||
|
{
|
||||||
|
// This does very little at the moment:
|
||||||
|
// * It will explode if any floating point exceptions are generated
|
||||||
|
// * You should run it with `valgrind --track-origins=yes` (and compile without optimizations so that origin
|
||||||
|
// tracking works well) to see if we are using any uninitialized values.
|
||||||
|
|
||||||
|
fetestexcept(FE_ALL_EXCEPT);
|
||||||
|
|
||||||
|
struct one_frame_input input = {};
|
||||||
|
|
||||||
|
for (int i = 0; i < 21; i++) {
|
||||||
|
|
||||||
|
input.views[0].rays[i] = m_vec3_normalize({0, (float)i, -1}); //{0,(float)i,-1};
|
||||||
|
input.views[1].rays[i] = m_vec3_normalize({(float)i, 0, -1});
|
||||||
|
input.views[0].confidences[i] = 1;
|
||||||
|
input.views[1].confidences[i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lm::KinematicHandLM *hand;
|
||||||
|
|
||||||
|
xrt_pose left_in_right = XRT_POSE_IDENTITY;
|
||||||
|
left_in_right.position.x = 1;
|
||||||
|
|
||||||
|
lm::optimizer_create(left_in_right, false, U_LOGGING_TRACE, &hand);
|
||||||
|
|
||||||
|
|
||||||
|
xrt_hand_joint_set out;
|
||||||
|
float out_hand_size;
|
||||||
|
float out_reprojection_error;
|
||||||
|
lm::optimizer_run(hand, input, true, true, 0.09, 0.5, out, out_hand_size, out_reprojection_error);
|
||||||
|
|
||||||
|
CHECK(std::isfinite(out_reprojection_error));
|
||||||
|
CHECK(std::isfinite(out_hand_size));
|
||||||
|
}
|
Loading…
Reference in a new issue