From a69e3a4e2b6f3fbcdce861752d26ab42198550fc Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sun, 24 Mar 2024 03:33:34 +1100 Subject: [PATCH] d/rift_s: Fix controllers reporting generic tracker pose Allow the constellation tracker to retrieve the generic tracker pose for it to match LEDs against --- src/xrt/drivers/rift_s/rift_s_controller.c | 22 +++++++++++++--------- src/xrt/drivers/rift_s/rift_s_controller.h | 3 +++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/xrt/drivers/rift_s/rift_s_controller.c b/src/xrt/drivers/rift_s/rift_s_controller.c index 945518e18..d02dfc001 100644 --- a/src/xrt/drivers/rift_s/rift_s_controller.c +++ b/src/xrt/drivers/rift_s/rift_s_controller.c @@ -539,21 +539,17 @@ rift_s_controller_get_tracked_pose(struct xrt_device *xdev, { struct rift_s_controller *ctrl = (struct rift_s_controller *)(xdev); - if (name != XRT_INPUT_TOUCH_AIM_POSE && name != XRT_INPUT_TOUCH_GRIP_POSE) { + if (name != XRT_INPUT_TOUCH_AIM_POSE && name != XRT_INPUT_TOUCH_GRIP_POSE && + name != XRT_INPUT_GENERIC_TRACKER_POSE) { U_LOG_XDEV_UNSUPPORTED_INPUT(&ctrl->base, rift_s_log_level, name); return XRT_ERROR_INPUT_UNSUPPORTED; } struct xrt_relation_chain xrc = {0}; - struct xrt_pose pose_correction = {0}; - - /* Rotate the grip/aim pose up by 40 degrees around the X axis */ - struct xrt_vec3 axis = {1.0, 0, 0}; - - math_quat_from_angle_vector(DEG_TO_RAD(40), &axis, &pose_correction.orientation); - - m_relation_chain_push_pose(&xrc, &pose_correction); + if (name == XRT_INPUT_TOUCH_GRIP_POSE) { + m_relation_chain_push_pose(&xrc, &ctrl->P_aim_grip); + } /* Apply the fusion rotation */ struct xrt_space_relation *rel = m_relation_chain_reserve(&xrc); @@ -562,6 +558,8 @@ rift_s_controller_get_tracked_pose(struct xrt_device *xdev, rift_s_controller_get_fusion_pose(ctrl, name, at_timestamp_ns, rel); if (ctrl->last_tracked_pose_ts != 0) { rel->pose.position = ctrl->last_tracked_pose.position; + rel->relation_flags |= (enum xrt_space_relation_flags)(XRT_SPACE_RELATION_POSITION_VALID_BIT | + XRT_SPACE_RELATION_POSITION_TRACKED_BIT); } os_mutex_unlock(&ctrl->mutex); @@ -699,6 +697,12 @@ rift_s_controller_create(struct rift_s_system *sys, enum xrt_device_type device_ os_mutex_init(&ctrl->mutex); + /* Default grip pose up by 40° degrees around the X axis */ + struct xrt_vec3 translation = {0.0, 0, 0.0}; + struct xrt_vec3 axis = {1.0, 0, 0}; + math_quat_from_angle_vector(DEG_TO_RAD(40), &axis, &ctrl->P_aim_grip.orientation); + ctrl->P_aim_grip.position = translation; + u_device_populate_function_pointers(&ctrl->base, rift_s_controller_get_tracked_pose, rift_s_controller_destroy); ctrl->base.update_inputs = rift_s_controller_update_inputs; ctrl->base.get_view_poses = u_device_get_view_poses; diff --git a/src/xrt/drivers/rift_s/rift_s_controller.h b/src/xrt/drivers/rift_s/rift_s_controller.h index 3afccf3fe..223844eac 100644 --- a/src/xrt/drivers/rift_s/rift_s_controller.h +++ b/src/xrt/drivers/rift_s/rift_s_controller.h @@ -83,6 +83,9 @@ struct rift_s_controller struct xrt_vec3 mag; struct m_imu_3dof fusion; + //! Offset for grip pose + struct xrt_pose P_aim_grip; + /* Controls / buttons state */ timepoint_ns last_controls_local_time_ns;