Control the tracking loop from server side

On server side, collect each tracking request, create an explicit pattern
describing how the client shall execute them.
This commit is contained in:
Patrick Nicolas
2026-01-29 09:51:52 +01:00
parent 0a71756024
commit fc01002317
28 changed files with 523 additions and 556 deletions
+17 -27
View File
@@ -23,6 +23,7 @@
#include "driver/xrt_cast.h"
#include "math/m_api.h"
#include "utils/method.h"
#include "wivrn_config.h"
#include "wivrn_session.h"
#include "util/u_logging.h"
@@ -643,12 +644,10 @@ wivrn_controller::wivrn_controller(xrt_device_name name,
math_quat_from_euler_angles(&rotation_angles, &offset.orientation);
palm.set_derived(&grip, offset, true);
cnx->set_enabled(palm.device, false);
}
else if (not cnx->get_info().palm_pose)
{
palm.set_derived(&grip, XRT_POSE_IDENTITY, false);
cnx->set_enabled(palm.device, false);
}
if (name != XRT_DEVICE_EXT_HAND_INTERACTION)
@@ -795,31 +794,32 @@ xrt_result_t wivrn_controller::get_tracked_pose(xrt_input_name name, int64_t at_
{
XrTime production_timestamp;
device_id device;
XrTime now = os_monotonic_get_ns();
auto target_ns = std::min(at_timestamp_ns, now + max_extrapolation_ns);
switch (name)
{
case XRT_INPUT_TOUCH_AIM_POSE:
case XRT_INPUT_HAND_AIM_POSE:
std::tie(production_timestamp, *res, device) = aim.get_pose_at(at_timestamp_ns);
std::tie(production_timestamp, *res, device) = aim.get_pose_at(target_ns);
break;
case XRT_INPUT_TOUCH_GRIP_POSE:
case XRT_INPUT_HAND_GRIP_POSE:
std::tie(production_timestamp, *res, device) = grip.get_pose_at(at_timestamp_ns);
std::tie(production_timestamp, *res, device) = grip.get_pose_at(target_ns);
break;
case XRT_INPUT_GENERIC_PALM_POSE:
std::tie(production_timestamp, *res, device) = palm.get_pose_at(at_timestamp_ns);
std::tie(production_timestamp, *res, device) = palm.get_pose_at(target_ns);
break;
case XRT_INPUT_HAND_PINCH_POSE:
std::tie(production_timestamp, *res, device) = pinch_ext.get_pose_at(at_timestamp_ns);
std::tie(production_timestamp, *res, device) = pinch_ext.get_pose_at(target_ns);
break;
case XRT_INPUT_HAND_POKE_POSE:
std::tie(production_timestamp, *res, device) = poke_ext.get_pose_at(at_timestamp_ns);
std::tie(production_timestamp, *res, device) = poke_ext.get_pose_at(target_ns);
break;
default:
U_LOG_XDEV_UNSUPPORTED_INPUT(this, u_log_get_global_level(), name);
return XRT_ERROR_INPUT_UNSUPPORTED;
}
cnx->set_enabled(device, true);
cnx->add_predict_offset(std::chrono::nanoseconds(at_timestamp_ns - production_timestamp));
cnx->add_tracking_request(device, at_timestamp_ns, production_timestamp, now);
if (auto out = tracking_dump())
{
auto device = [&] {
@@ -852,10 +852,9 @@ xrt_result_t wivrn_controller::get_hand_tracking(xrt_input_name name, int64_t de
case XRT_INPUT_HT_UNOBSTRUCTED_LEFT:
case XRT_INPUT_HT_UNOBSTRUCTED_RIGHT: {
*out_timestamp_ns = desired_timestamp_ns;
std::chrono::nanoseconds extrapolation_time;
std::tie(extrapolation_time, *out_value) = joints.get_at(desired_timestamp_ns);
cnx->add_predict_offset(extrapolation_time);
cnx->set_enabled(joints.hand_id == 0 ? to_headset::tracking_control::id::left_hand : to_headset::tracking_control::id::right_hand, true);
XrTime production_timestamp;
std::tie(production_timestamp, *out_value) = joints.get_at(desired_timestamp_ns);
cnx->add_tracking_request(joints.hand_id == 0 ? device_id::LEFT_HAND : device_id::RIGHT_HAND, desired_timestamp_ns, production_timestamp);
return XRT_SUCCESS;
}
@@ -878,25 +877,16 @@ void wivrn_controller::set_derived_pose(const from_headset::derived_pose & deriv
auto source = list(derived.source);
auto target = list(derived.target);
if (source and target)
{
target->set_derived(source, xrt_cast(derived.relation));
if (source != target)
cnx->set_enabled(derived.target, false);
}
}
void wivrn_controller::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
{
if (not aim.update_tracking(tracking, offset))
cnx->set_enabled(aim.device, false);
if (not grip.update_tracking(tracking, offset))
cnx->set_enabled(grip.device, false);
if (not palm.update_tracking(tracking, offset))
cnx->set_enabled(palm.device, false);
if (not pinch_ext.update_tracking(tracking, offset))
cnx->set_enabled(pinch_ext.device, false);
if (not poke_ext.update_tracking(tracking, offset))
cnx->set_enabled(poke_ext.device, false);
aim.update_tracking(tracking, offset);
grip.update_tracking(tracking, offset);
palm.update_tracking(tracking, offset);
pinch_ext.update_tracking(tracking, offset);
poke_ext.update_tracking(tracking, offset);
if (auto out = tracking_dump(); out and offset)
{
auto locked = out->lock();