From ce3c5d59fb2edeb94879071c66420048bdee511c Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 24 Apr 2023 16:45:21 +0100 Subject: [PATCH] d/wmr: Add a slider to adjust all tracked pose timestamps --- src/xrt/drivers/wmr/wmr_hmd.c | 10 ++++++++++ src/xrt/drivers/wmr/wmr_hmd.h | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/xrt/drivers/wmr/wmr_hmd.c b/src/xrt/drivers/wmr/wmr_hmd.c index c89d697f5..733fecd3a 100644 --- a/src/xrt/drivers/wmr/wmr_hmd.c +++ b/src/xrt/drivers/wmr/wmr_hmd.c @@ -1091,6 +1091,9 @@ wmr_hmd_get_tracked_pose(struct xrt_device *xdev, DRV_TRACE_MARKER(); struct wmr_hmd *wh = wmr_hmd(xdev); + + at_timestamp_ns += (uint64_t)(wh->tracked_offset_ms.val * (double)U_TIME_1MS_IN_NS); + if (wh->tracking.slam_enabled && wh->slam_over_3dof) { wmr_hmd_get_slam_tracked_pose(xdev, name, at_timestamp_ns, out_relation); } else { @@ -1617,6 +1620,7 @@ wmr_hmd_setup_ui(struct wmr_hmd *wh) u_var_add_pose(wh, &wh->pose, "Tracked Pose"); u_var_add_pose(wh, &wh->offset, "Pose Offset"); u_var_add_bool(wh, &wh->average_imus, "Average IMU samples"); + u_var_add_draggable_f32(wh, &wh->tracked_offset_ms, "Timecode offset(ms)"); u_var_add_gui_header(wh, NULL, "3DoF Tracking"); m_imu_3dof_add_vars(&wh->fusion.i3dof, wh, ""); @@ -1887,6 +1891,12 @@ wmr_hmd_create(enum wmr_headset_type hmd_type, wh->pose = (struct xrt_pose)XRT_POSE_IDENTITY; wh->offset = (struct xrt_pose)XRT_POSE_IDENTITY; wh->average_imus = true; + wh->tracked_offset_ms = (struct u_var_draggable_f32){ + .val = 0.0, + .min = -40.0, + .step = 0.1, + .max = +120.0, + }; /* Now that we have the config loaded, iterate the map of known headsets and see if we have * an entry for this specific headset (otherwise the generic entry will be used) diff --git a/src/xrt/drivers/wmr/wmr_hmd.h b/src/xrt/drivers/wmr/wmr_hmd.h index ac93daec2..f4a52798e 100644 --- a/src/xrt/drivers/wmr/wmr_hmd.h +++ b/src/xrt/drivers/wmr/wmr_hmd.h @@ -1,6 +1,6 @@ // Copyright 2018, Philipp Zabel. // Copyright 2020-2021, N Madsen. -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -174,6 +174,13 @@ struct wmr_hmd //! Average 4 IMU samples before sending them to the trackers bool average_imus; + /*! + * Offset for tracked pose offsets (applies to both fusion and SLAM). + * Applied when getting the tracked poses, so is effectivily a offset + * to increase or decrease prediction. + */ + struct u_var_draggable_f32 tracked_offset_ms; + struct { struct u_var_button hmd_screen_enable_btn;