Request tracking extrapolation on client

Add the timestamp where data was requested, use this to compute how far
in the future the application is requesting samples.
With this information, client requests 2 tracking samples: one at the
current time and one in the future.
Server now keeps track of actual samples + one predicted sample, and is
most of the time in the interpolation use case.
This commit is contained in:
Patrick Nicolas
2024-04-04 13:41:36 +02:00
parent b9c4e04a14
commit 7658f427e6
11 changed files with 126 additions and 45 deletions
+12 -3
View File
@@ -118,10 +118,8 @@ void scenes::stream::tracking()
XrSpace view_space = application::view();
const XrDuration tracking_period = 1'000'000; // Send tracking data every 1ms
const XrDuration dt = 100'000; // Wake up 0.1ms before measuring the position
const XrDuration extrapolation_horizon = 1; // 50'000'000;
XrTime t0 = instance.now();
t0 = t0 - t0 % tracking_period;
while (not exiting)
{
@@ -134,11 +132,16 @@ void scenes::stream::tracking()
// If thread can't keep up, skip timestamps
t0 += tracking_period * ((now - t0) / tracking_period);
for (XrTime Δt = 0; Δt < extrapolation_horizon; Δt += tracking_period)
XrDuration prediction = tracking_prediction_offset;
// 1 or 2 samples
for (XrDuration Δt = 0; Δt <= prediction; Δt += std::max<XrDuration>(1, prediction))
{
from_headset::tracking packet{};
from_headset::hand_tracking hands{};
packet.production_timestamp = t0;
hands.production_timestamp = t0;
packet.timestamp = t0 + Δt;
hands.timestamp = t0 + Δt;
@@ -187,3 +190,9 @@ void scenes::stream::tracking()
}
}
}
void scenes::stream::operator()(to_headset::prediction_offset && packet)
{
if (packet.offset.count() >= 0)
tracking_prediction_offset = packet.offset.count();
}