diff --git a/CMakeLists.txt b/CMakeLists.txt index ece62d64b..1a6ec17b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,9 @@ endif() # Find a external SLAM implementation set(EXTERNAL_SLAM_SYSTEMS kimera_vio) foreach(slam_system IN LISTS EXTERNAL_SLAM_SYSTEMS) - find_package(${slam_system} CONFIG) + if(PKGCONFIG_FOUND) + pkg_check_modules(${slam_system} ${slam_system}) + endif() if(${slam_system}_FOUND) set(SLAM ON) set(SLAM_NAME ${slam_system}) @@ -209,8 +211,8 @@ cmake_dependent_option(XRT_HAVE_SDL2 "Enable use of SDL2" ON "SDL2_FOUND AND XRT cmake_dependent_option(XRT_HAVE_SYSTEM_CJSON "Enable cJSON from system, instead of bundled source" ON "CJSON_FOUND" OFF) cmake_dependent_option(XRT_HAVE_GST "Enable gstreamer" ON "GST_FOUND" OFF) cmake_dependent_option(XRT_HAVE_ONNXRUNTIME "Enable ONNX runtime support" ON "ONNXRUNTIME_FOUND" OFF) -cmake_dependent_option(XRT_HAVE_SLAM "Enable SLAM tracking support" ON "SLAM;XRT_HAVE_OPENCV" OFF) cmake_dependent_option(XRT_HAVE_KIMERA_SLAM "Enable Kimera support" ON "kimera_vio_FOUND" OFF) +cmake_dependent_option(XRT_HAVE_SLAM "Enable SLAM tracking support" ON "SLAM;XRT_HAVE_OPENCV" OFF) cmake_dependent_option(XRT_BUILD_DRIVER_PSVR "Enable PSVR HMD driver" ON "HIDAPI_FOUND" OFF) cmake_dependent_option(XRT_BUILD_DRIVER_RS "Enable RealSense device driver" ON "realsense2_FOUND" OFF) cmake_dependent_option(XRT_BUILD_DRIVER_VIVE "Enable driver for HTC Vive, Vive Pro, Valve Index, and their controllers" ON "ZLIB_FOUND AND XRT_HAVE_LINUX" OFF) diff --git a/src/xrt/drivers/euroc/euroc_device.c b/src/xrt/drivers/euroc/euroc_device.c index 4ca84342c..a2d9c5db3 100644 --- a/src/xrt/drivers/euroc/euroc_device.c +++ b/src/xrt/drivers/euroc/euroc_device.c @@ -131,8 +131,10 @@ euroc_device_get_tracked_pose(struct xrt_device *xdev, int pose_bits = XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT; bool pose_tracked = out_relation->relation_flags & pose_bits; if (pose_tracked) { -#ifdef XRT_HAVE_KIMERA_SLAM +#if defined(XRT_HAVE_KIMERA_SLAM) ed->pose = euroc_device_correct_pose_from_kimera(out_relation->pose); +#else + ed->pose = out_relation->pose; #endif } } diff --git a/src/xrt/drivers/realsense/rs_hdev.c b/src/xrt/drivers/realsense/rs_hdev.c index aa71e59fe..78c069b02 100644 --- a/src/xrt/drivers/realsense/rs_hdev.c +++ b/src/xrt/drivers/realsense/rs_hdev.c @@ -209,9 +209,10 @@ rs_hdev_correct_pose_from_kimera(struct xrt_pose pose) swapped.orientation.w = pose.orientation.w; // Correct orientation + //! @todo Encode this transformation into constants struct xrt_space_relation out_relation; struct xrt_space_graph space_graph = {0}; - struct xrt_pose pre_correction = (struct xrt_pose){{-0.5, -0.5, -0.5, 0.5}, {0, 0, 0}}; // euler(90, 90, 0) + struct xrt_pose pre_correction = {{-0.5, -0.5, -0.5, 0.5}, {0, 0, 0}}; // euler(90, 90, 0) float sin45 = 0.7071067811865475; struct xrt_pose pos_correction = {{sin45, 0, sin45, 0}, {0, 0, 0}}; // euler(180, 90, 0) m_space_graph_add_pose(&space_graph, &pre_correction); @@ -237,8 +238,10 @@ rs_hdev_get_tracked_pose(struct xrt_device *xdev, bool pose_tracked = out_relation->relation_flags & pose_bits; if (pose_tracked) { -#ifdef XRT_HAVE_KIMERA_SLAM +#if defined(XRT_HAVE_KIMERA_SLAM) rs->pose = rs_hdev_correct_pose_from_kimera(out_relation->pose); +#else + rs->pose = out_relation->pose; #endif } diff --git a/src/xrt/include/xrt/meson.build b/src/xrt/include/xrt/meson.build index dba94e499..fdaa03180 100644 --- a/src/xrt/include/xrt/meson.build +++ b/src/xrt/include/xrt/meson.build @@ -106,9 +106,7 @@ endif if slam.found() and build_tracking have_conf.set('XRT_HAVE_SLAM', true) - if slam.name() == 'kimera_vio' - have_conf.set('XRT_HAVE_KIMERA_SLAM', true) - endif + have_conf.set('XRT_HAVE_KIMERA_SLAM', slam.name() == 'kimera_vio') endif if build_wayland