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:
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
|
||||
#include "wivrn_hmd.h"
|
||||
#include "os/os_time.h"
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_session.h"
|
||||
|
||||
#include "xrt/xrt_defines.h"
|
||||
@@ -129,9 +131,11 @@ xrt_result_t wivrn_hmd::get_tracked_pose(xrt_input_name name, int64_t at_timesta
|
||||
return XRT_ERROR_INPUT_UNSUPPORTED;
|
||||
}
|
||||
|
||||
auto [production_timestamp, view] = views.get_at(at_timestamp_ns);
|
||||
auto now = os_monotonic_get_ns();
|
||||
auto target_ns = std::min(now + max_extrapolation_ns, at_timestamp_ns);
|
||||
auto [production_timestamp, view] = views.get_at(target_ns);
|
||||
*res = view.relation;
|
||||
cnx->add_predict_offset(std::chrono::nanoseconds(at_timestamp_ns - production_timestamp));
|
||||
cnx->add_tracking_request(device_id::HEAD, at_timestamp_ns, production_timestamp, now);
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -143,7 +147,6 @@ void wivrn_hmd::update_tracking(const from_headset::tracking & tracking, const c
|
||||
void wivrn_hmd::update_battery(const from_headset::battery & new_battery)
|
||||
{
|
||||
// We will only request a new sample if the current one is consumed
|
||||
cnx->set_enabled(to_headset::tracking_control::id::battery, false);
|
||||
std::lock_guard lock(mutex);
|
||||
battery = new_battery;
|
||||
}
|
||||
@@ -163,8 +166,10 @@ xrt_result_t wivrn_hmd::get_view_poses(const xrt_vec3 * default_eye_relation,
|
||||
xrt_fov * out_fovs,
|
||||
xrt_pose * out_poses)
|
||||
{
|
||||
auto [production_timestamp, view] = views.get_at(at_timestamp_ns);
|
||||
cnx->add_predict_offset(std::chrono::nanoseconds(at_timestamp_ns - production_timestamp));
|
||||
auto now = os_monotonic_get_ns();
|
||||
auto target_ns = std::min(now + max_extrapolation_ns, at_timestamp_ns);
|
||||
auto [production_timestamp, view] = views.get_at(target_ns);
|
||||
cnx->add_tracking_request(device_id::HEAD, at_timestamp_ns, production_timestamp, now);
|
||||
|
||||
int flags = view.relation.relation_flags;
|
||||
|
||||
@@ -196,8 +201,6 @@ xrt_result_t wivrn_hmd::get_battery_status(bool * out_present,
|
||||
bool * out_charging,
|
||||
float * out_charge)
|
||||
{
|
||||
cnx->set_enabled(to_headset::tracking_control::id::battery, true);
|
||||
|
||||
std::lock_guard lock(mutex);
|
||||
*out_present = battery.present;
|
||||
*out_charging = battery.charging;
|
||||
|
||||
Reference in New Issue
Block a user