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
+6 -18
View File
@@ -30,7 +30,6 @@
#include "xrt/xrt_defines.h"
#include "xrt/xrt_results.h"
#include "xrt_cast.h"
#include <chrono>
#include <format>
using namespace xrt::auxiliary::math;
@@ -76,11 +75,6 @@ bool tracker_pose_list::update_tracking(XrTime produced_timestamp, XrTime timest
return add_sample(produced_timestamp, timestamp, convert_pose(pose), offset);
}
std::pair<std::chrono::nanoseconds, xrt_space_relation> tracker_pose_list::get_pose_at(XrTime at_timestamp_ns)
{
return get_at(at_timestamp_ns);
}
static xrt_space_relation_flags convert_flags(uint8_t flags)
{
std::underlying_type_t<xrt_space_relation_flags> out_flags = 0;
@@ -121,8 +115,7 @@ wivrn_generic_tracker::wivrn_generic_tracker(int index, xrt_device * hmd, wivrn_
.get_tracked_pose = method_pointer<&wivrn_generic_tracker::get_tracked_pose>,
.destroy = [](xrt_device *) {},
},
cnx(cnx),
index(index)
cnx(cnx)
{
auto unique_name = std::format("WiVRn Generic Tracker #{}", index + 1);
strlcpy(str, unique_name.c_str(), std::size(str));
@@ -140,17 +133,16 @@ xrt_result_t wivrn_generic_tracker::update_inputs()
{
return XRT_SUCCESS;
}
xrt_result_t wivrn_generic_tracker::get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * res)
{
std::chrono::nanoseconds extrapolation_time;
XrTime production_timestamp;
if (name == XRT_INPUT_GENERIC_TRACKER_POSE)
{
std::tie(extrapolation_time, *res) = poses.get_pose_at(at_timestamp_ns);
std::tie(production_timestamp, *res) = poses.get_at(at_timestamp_ns);
active = true;
cnx.update_tracker_enabled();
cnx.add_predict_offset(extrapolation_time);
cnx.add_tracking_request(device_id::BODY, at_timestamp_ns, production_timestamp);
return XRT_SUCCESS;
}
@@ -160,10 +152,6 @@ xrt_result_t wivrn_generic_tracker::get_tracked_pose(xrt_input_name name, int64_
void wivrn_generic_tracker::update_tracking(const from_headset::body_tracking & tracking, const from_headset::body_tracking::pose & pose, const clock_offset & offset)
{
if (!poses.update_tracking(tracking.production_timestamp, tracking.timestamp, pose, offset))
{
active = false;
cnx.update_tracker_enabled();
}
poses.update_tracking(tracking.production_timestamp, tracking.timestamp, pose, offset);
}
} // namespace wivrn