Use separate packet to send generic tracker poses
This commit is contained in:
@@ -232,9 +232,11 @@ void scenes::stream::tracking()
|
||||
|
||||
XrTime t0 = instance.now();
|
||||
XrTime last_hand_sample = t0;
|
||||
XrTime last_body_sample = t0;
|
||||
std::vector<from_headset::tracking> tracking;
|
||||
std::vector<from_headset::tracking> tracking_pool; // pre-allocated objects
|
||||
std::vector<from_headset::hand_tracking> hands;
|
||||
std::vector<from_headset::body_tracking> body;
|
||||
std::vector<XrView> views;
|
||||
|
||||
std::vector<from_headset::trackings> merged_tracking;
|
||||
@@ -286,6 +288,7 @@ void scenes::stream::tracking()
|
||||
{
|
||||
tracking.clear();
|
||||
hands.clear();
|
||||
body.clear();
|
||||
|
||||
XrTime now = instance.now();
|
||||
if (now < t0)
|
||||
@@ -355,6 +358,30 @@ void scenes::stream::tracking()
|
||||
locate_hands(application::get_right_hand(), world_space, t0 + Δt));
|
||||
}
|
||||
|
||||
if (body_tracking != body_none and t0 >= last_body_sample + period and
|
||||
(Δt == 0 or Δt >= prediction - 2 * period))
|
||||
{
|
||||
last_body_sample = t0;
|
||||
if (control.enabled[size_t(tid::generic_tracker)])
|
||||
{
|
||||
auto & body_packet = body.emplace_back(from_headset::body_tracking{
|
||||
.production_timestamp = t0,
|
||||
.timestamp = t0 + Δt,
|
||||
});
|
||||
switch (body_tracking)
|
||||
{
|
||||
case body_none:
|
||||
__builtin_unreachable();
|
||||
case body_fb:
|
||||
body_packet.poses = application::get_fb_body_tracker().locate_spaces(t0 + Δt, world_space);
|
||||
break;
|
||||
case body_pico:
|
||||
body_packet.poses = application::get_pico_body_tracker().locate_spaces(t0 + Δt, world_space);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (control.enabled[size_t(tid::face)])
|
||||
{
|
||||
switch (face_tracking)
|
||||
@@ -379,21 +406,6 @@ void scenes::stream::tracking()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (control.enabled[size_t(tid::generic_tracker)])
|
||||
{
|
||||
switch (body_tracking)
|
||||
{
|
||||
case body_none:
|
||||
break;
|
||||
case body_fb:
|
||||
application::get_fb_body_tracker().locate_spaces(t0 + Δt, packet.device_poses, world_space);
|
||||
break;
|
||||
case body_pico:
|
||||
application::get_pico_body_tracker().locate_spaces(t0 + Δt, packet.device_poses, world_space);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::system_error & e)
|
||||
{
|
||||
@@ -443,7 +455,7 @@ void scenes::stream::tracking()
|
||||
merged_tracking.back().items.emplace_back(std::move(item));
|
||||
}
|
||||
|
||||
packets.resize(std::max(packets.size(), merged_tracking.size() + hands.size()));
|
||||
packets.resize(std::max(packets.size(), merged_tracking.size() + hands.size() + body.size()));
|
||||
size_t packet_count = 0;
|
||||
for (const auto & i: merged_tracking)
|
||||
{
|
||||
@@ -460,6 +472,15 @@ void scenes::stream::tracking()
|
||||
wivrn_session::stream_socket_t::serialize(packet, i);
|
||||
}
|
||||
}
|
||||
for (const auto & i: body)
|
||||
{
|
||||
if (i.poses)
|
||||
{
|
||||
auto & packet = packets[packet_count++];
|
||||
packet.clear();
|
||||
wivrn_session::stream_socket_t::serialize(packet, i);
|
||||
}
|
||||
}
|
||||
|
||||
network_session->send_stream(std::span(packets.data(), packet_count));
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "xr/xr.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
static_assert(xr::pico_body_tracker::joint_whitelist.size() <= wivrn::from_headset::body_tracking::max_tracked_poses);
|
||||
|
||||
xr::fb_body_tracker::fb_body_tracker(instance & inst, session & s) :
|
||||
s(s)
|
||||
{
|
||||
@@ -61,26 +63,11 @@ void xr::fb_body_tracker::stop()
|
||||
CHECK_XR(xrDestroyBodyTrackerFB(std::exchange(handle, nullptr)));
|
||||
}
|
||||
|
||||
void xr::fb_body_tracker::locate_spaces(XrTime time, std::vector<wivrn::from_headset::tracking::pose> & out_poses, XrSpace reference)
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> xr::fb_body_tracker::locate_spaces(XrTime time, XrSpace reference)
|
||||
{
|
||||
auto fill_poses = [&]() {
|
||||
for (auto joint: joint_whitelist)
|
||||
{
|
||||
if (!full_body && joint >= XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META)
|
||||
return;
|
||||
|
||||
wivrn::from_headset::tracking::pose pose{
|
||||
.pose = {},
|
||||
.device = wivrn::device_id::GENERIC_TRACKER,
|
||||
.flags = 0,
|
||||
};
|
||||
out_poses.push_back(std::move(pose));
|
||||
}
|
||||
};
|
||||
if (!handle)
|
||||
{
|
||||
fill_poses();
|
||||
return;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
assert(xrLocateBodyJointsFB);
|
||||
@@ -103,40 +90,38 @@ void xr::fb_body_tracker::locate_spaces(XrTime time, std::vector<wivrn::from_hea
|
||||
if (auto res = xrLocateBodyJointsFB(handle, &locate_info, &joint_locations); !XR_SUCCEEDED(res))
|
||||
{
|
||||
spdlog::warn("xrLocateBodyJointsFB returned {}", xr::to_string(res));
|
||||
|
||||
fill_poses();
|
||||
return;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (!joint_locations.isActive)
|
||||
{
|
||||
spdlog::warn("Body tracker is not active.");
|
||||
fill_poses();
|
||||
return;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
for (auto joint: joint_whitelist)
|
||||
std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses> poses{};
|
||||
for (int i = 0; i < joint_whitelist.size(); i++)
|
||||
{
|
||||
auto joint = joint_whitelist[i];
|
||||
if (!full_body && joint >= XR_FULL_BODY_JOINT_LEFT_UPPER_LEG_META)
|
||||
return;
|
||||
break;
|
||||
|
||||
auto joint_pose = joints[joint];
|
||||
wivrn::from_headset::tracking::pose pose{
|
||||
wivrn::from_headset::body_tracking::pose pose{
|
||||
.pose = joint_pose.pose,
|
||||
.device = wivrn::device_id::GENERIC_TRACKER,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
if (joint_pose.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::position_valid;
|
||||
if (joint_pose.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::orientation_valid;
|
||||
if (joint_pose.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::position_tracked;
|
||||
pose.flags |= wivrn::from_headset::body_tracking::orientation_valid;
|
||||
if (joint_pose.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
pose.flags |= wivrn::from_headset::body_tracking::position_valid;
|
||||
if (joint_pose.locationFlags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::orientation_tracked;
|
||||
pose.flags |= wivrn::from_headset::body_tracking::orientation_tracked;
|
||||
if (joint_pose.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
pose.flags |= wivrn::from_headset::body_tracking::position_tracked;
|
||||
|
||||
out_poses.push_back(std::move(pose));
|
||||
poses[i] = std::move(pose);
|
||||
}
|
||||
return;
|
||||
return poses;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include "xr/meta_body_tracking_fidelity.h"
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace xr
|
||||
@@ -64,6 +65,6 @@ public:
|
||||
void start(bool lower_body);
|
||||
void stop();
|
||||
|
||||
void locate_spaces(XrTime time, std::vector<wivrn::from_headset::tracking::pose> & out_poses, XrSpace reference);
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> locate_spaces(XrTime time, XrSpace reference);
|
||||
};
|
||||
} // namespace xr
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "xr/xr.h"
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
static_assert(xr::pico_body_tracker::joint_whitelist.size() <= wivrn::from_headset::body_tracking::max_tracked_poses);
|
||||
|
||||
static PFN_xrDestroyBodyTrackerBD xrDestroyBodyTrackerBD{};
|
||||
|
||||
XrResult xr::destroy_pico_body_tracker(XrBodyTrackerBD id)
|
||||
@@ -34,24 +36,11 @@ xr::pico_body_tracker::pico_body_tracker(instance & inst, XrBodyTrackerBD h)
|
||||
xrLocateBodyJointsBD = inst.get_proc<PFN_xrLocateBodyJointsBD>("xrLocateBodyJointsBD");
|
||||
}
|
||||
|
||||
void xr::pico_body_tracker::locate_spaces(XrTime time, std::vector<wivrn::from_headset::tracking::pose> & out_poses, XrSpace reference)
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> xr::pico_body_tracker::locate_spaces(XrTime time, XrSpace reference)
|
||||
{
|
||||
auto fill_poses = [&]() {
|
||||
for (auto _: joint_whitelist)
|
||||
{
|
||||
wivrn::from_headset::tracking::pose pose{
|
||||
.pose = {},
|
||||
.device = wivrn::device_id::GENERIC_TRACKER,
|
||||
.flags = 0,
|
||||
};
|
||||
out_poses.push_back(std::move(pose));
|
||||
}
|
||||
};
|
||||
|
||||
if (!xrLocateBodyJointsBD)
|
||||
{
|
||||
fill_poses();
|
||||
return;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
XrBodyJointsLocateInfoBD locate_info{
|
||||
@@ -72,28 +61,28 @@ void xr::pico_body_tracker::locate_spaces(XrTime time, std::vector<wivrn::from_h
|
||||
if (auto res = xrLocateBodyJointsBD(id, &locate_info, &joint_locations); !XR_SUCCEEDED(res))
|
||||
{
|
||||
spdlog::warn("Unable to get body joints: xrLocateBodyJointsBD returned {}", xr::to_string(res));
|
||||
fill_poses();
|
||||
return;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
for (auto & joint: joint_whitelist)
|
||||
std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses> poses{};
|
||||
for (int i = 0; i < joint_whitelist.size(); i++)
|
||||
{
|
||||
auto & joint_location = joints[joint];
|
||||
wivrn::from_headset::tracking::pose pose{
|
||||
auto & joint_location = joints[joint_whitelist[i]];
|
||||
wivrn::from_headset::body_tracking::pose pose{
|
||||
.pose = joint_location.pose,
|
||||
.device = wivrn::device_id::GENERIC_TRACKER,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
if (joint_location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::position_valid;
|
||||
if (joint_location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::orientation_valid;
|
||||
if (joint_location.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::position_tracked;
|
||||
pose.flags |= wivrn::from_headset::body_tracking::orientation_valid;
|
||||
if (joint_location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||
pose.flags |= wivrn::from_headset::body_tracking::position_valid;
|
||||
if (joint_location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT)
|
||||
pose.flags |= wivrn::from_headset::tracking::orientation_tracked;
|
||||
pose.flags |= wivrn::from_headset::body_tracking::orientation_tracked;
|
||||
if (joint_location.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT)
|
||||
pose.flags |= wivrn::from_headset::body_tracking::position_tracked;
|
||||
|
||||
out_poses.push_back(std::move(pose));
|
||||
poses[i] = std::move(pose);
|
||||
}
|
||||
return poses;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
#include "utils/handle.h"
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace xr
|
||||
@@ -52,6 +53,6 @@ public:
|
||||
pico_body_tracker() = default;
|
||||
pico_body_tracker(instance & inst, XrBodyTrackerBD h);
|
||||
|
||||
void locate_spaces(XrTime time, std::vector<wivrn::from_headset::tracking::pose> & out_poses, XrSpace reference);
|
||||
std::optional<std::array<wivrn::from_headset::body_tracking::pose, wivrn::from_headset::body_tracking::max_tracked_poses>> locate_spaces(XrTime time, XrSpace reference);
|
||||
};
|
||||
} // namespace xr
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "openxr/openxr.h"
|
||||
#include "utils/contains.h"
|
||||
#include "xr/fb_body_tracker.h"
|
||||
#include "xr/pico_body_tracker.h"
|
||||
#include "xr/instance.h"
|
||||
#include "xr/pico_body_tracker.h"
|
||||
#include "xr/system.h"
|
||||
#include <ranges>
|
||||
#include <vulkan/vulkan.h>
|
||||
@@ -152,9 +152,9 @@ xr::fb_body_tracker xr::session::create_fb_body_tracker()
|
||||
xr::pico_body_tracker xr::session::create_pico_body_tracker()
|
||||
{
|
||||
XrBodyTrackerCreateInfoBD create_info{
|
||||
.type = XR_TYPE_BODY_TRACKER_CREATE_INFO_BD,
|
||||
.next = nullptr,
|
||||
.jointSet = XR_BODY_JOINT_SET_FULL_BODY_JOINTS_BD,
|
||||
.type = XR_TYPE_BODY_TRACKER_CREATE_INFO_BD,
|
||||
.next = nullptr,
|
||||
.jointSet = XR_BODY_JOINT_SET_FULL_BODY_JOINTS_BD,
|
||||
};
|
||||
|
||||
XrBodyTrackerBD bt;
|
||||
|
||||
+2
-2
@@ -26,12 +26,12 @@
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include "fb_body_tracker.h"
|
||||
#include "fb_face_tracker2.h"
|
||||
#include "hand_tracker.h"
|
||||
#include "htc_face_tracker.h"
|
||||
#include "fb_body_tracker.h"
|
||||
#include "pico_body_tracker.h"
|
||||
#include "passthrough.h"
|
||||
#include "pico_body_tracker.h"
|
||||
#include "pico_face_tracker.h"
|
||||
#include "space.h"
|
||||
|
||||
|
||||
@@ -147,12 +147,12 @@ XrSystemBodyTrackingPropertiesFB xr::system::fb_body_tracking_properties() const
|
||||
throw std::invalid_argument("this");
|
||||
|
||||
XrSystemBodyTrackingPropertiesFB body_tracking_prop{
|
||||
.type = XR_TYPE_SYSTEM_BODY_TRACKING_PROPERTIES_FB,
|
||||
.type = XR_TYPE_SYSTEM_BODY_TRACKING_PROPERTIES_FB,
|
||||
};
|
||||
|
||||
XrSystemProperties prop{
|
||||
.type = XR_TYPE_SYSTEM_PROPERTIES,
|
||||
.next = &body_tracking_prop,
|
||||
.type = XR_TYPE_SYSTEM_PROPERTIES,
|
||||
.next = &body_tracking_prop,
|
||||
};
|
||||
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
|
||||
|
||||
|
||||
+23
-1
@@ -116,7 +116,6 @@ enum class device_id : uint8_t
|
||||
RIGHT_TRACKPAD_FORCE, // /user/hand/right/input/trackpad/force
|
||||
RIGHT_STYLUS_FORCE, // /user/hand/right/input/stylus_fb/force
|
||||
EYE_GAZE, // /user/eyes_ext/input/gaze_ext/pose
|
||||
GENERIC_TRACKER,
|
||||
};
|
||||
|
||||
enum class interaction_profile : uint8_t
|
||||
@@ -339,6 +338,28 @@ struct hand_tracking
|
||||
std::optional<std::array<pose, XR_HAND_JOINT_COUNT_EXT>> joints;
|
||||
};
|
||||
|
||||
struct body_tracking
|
||||
{
|
||||
inline static const size_t max_tracked_poses = 16;
|
||||
enum flags : uint8_t
|
||||
{
|
||||
orientation_valid = 1 << 0,
|
||||
position_valid = 1 << 1,
|
||||
orientation_tracked = 1 << 2,
|
||||
position_tracked = 1 << 3,
|
||||
};
|
||||
struct pose
|
||||
{
|
||||
XrPosef pose{};
|
||||
// maybe add velocity?
|
||||
uint8_t flags{0};
|
||||
};
|
||||
|
||||
XrTime production_timestamp;
|
||||
XrTime timestamp;
|
||||
std::optional<std::array<pose, max_tracked_poses>> poses;
|
||||
};
|
||||
|
||||
struct inputs
|
||||
{
|
||||
struct input_value
|
||||
@@ -401,6 +422,7 @@ using packets = std::variant<
|
||||
trackings,
|
||||
derived_pose,
|
||||
hand_tracking,
|
||||
body_tracking,
|
||||
inputs,
|
||||
timesync_response,
|
||||
battery,
|
||||
|
||||
@@ -70,7 +70,7 @@ xrt_space_relation tracker_pose_list::extrapolate(const xrt_space_relation & a,
|
||||
return res;
|
||||
}
|
||||
|
||||
bool tracker_pose_list::update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::tracking::pose & pose, const clock_offset & offset)
|
||||
bool tracker_pose_list::update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::body_tracking::pose & pose, const clock_offset & offset)
|
||||
{
|
||||
return add_sample(produced_timestamp, timestamp, convert_pose(pose), offset);
|
||||
}
|
||||
@@ -82,22 +82,27 @@ std::pair<std::chrono::nanoseconds, xrt_space_relation> tracker_pose_list::get_p
|
||||
|
||||
static xrt_space_relation_flags convert_flags(uint8_t flags)
|
||||
{
|
||||
static_assert(int(from_headset::tracking::position_valid) == XRT_SPACE_RELATION_POSITION_VALID_BIT);
|
||||
static_assert(int(from_headset::tracking::orientation_valid) == XRT_SPACE_RELATION_ORIENTATION_VALID_BIT);
|
||||
static_assert(int(from_headset::tracking::linear_velocity_valid) == XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT);
|
||||
static_assert(int(from_headset::tracking::angular_velocity_valid) == XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT);
|
||||
static_assert(int(from_headset::tracking::orientation_tracked) == XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT);
|
||||
static_assert(int(from_headset::tracking::position_tracked) == XRT_SPACE_RELATION_POSITION_TRACKED_BIT);
|
||||
return xrt_space_relation_flags(flags);
|
||||
std::underlying_type_t<xrt_space_relation_flags> out_flags = 0;
|
||||
if (flags & from_headset::body_tracking::orientation_valid)
|
||||
out_flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
|
||||
if (flags & from_headset::body_tracking::position_valid)
|
||||
out_flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
|
||||
|
||||
if (flags & from_headset::body_tracking::orientation_tracked)
|
||||
out_flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
|
||||
if (flags & from_headset::body_tracking::position_tracked)
|
||||
out_flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
|
||||
|
||||
return xrt_space_relation_flags(out_flags);
|
||||
}
|
||||
|
||||
xrt_space_relation tracker_pose_list::convert_pose(const from_headset::tracking::pose & pose)
|
||||
xrt_space_relation tracker_pose_list::convert_pose(const from_headset::body_tracking::pose & pose)
|
||||
{
|
||||
return xrt_space_relation{
|
||||
.relation_flags = convert_flags(pose.flags),
|
||||
.pose = xrt_cast(pose.pose),
|
||||
.linear_velocity = xrt_cast(pose.linear_velocity),
|
||||
.angular_velocity = xrt_cast(pose.angular_velocity),
|
||||
.linear_velocity = {},
|
||||
.angular_velocity = {},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -145,7 +150,7 @@ xrt_result_t wivrn_generic_tracker::get_tracked_pose(xrt_input_name name, int64_
|
||||
return XRT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void wivrn_generic_tracker::update_tracking(const from_headset::tracking & tracking, const from_headset::tracking::pose & pose, const clock_offset & offset)
|
||||
void wivrn_generic_tracker::update_tracking(const from_headset::body_tracking & tracking, const from_headset::body_tracking::pose & pose, const clock_offset & offset)
|
||||
{
|
||||
// TODO: Right now we ignore the return value, because if the pose of one of the trackers is not requested for a while, all of them get deactivated, which isn't ideal.
|
||||
poses.update_tracking(tracking.production_timestamp, tracking.timestamp, pose, offset);
|
||||
|
||||
@@ -34,11 +34,11 @@ public:
|
||||
|
||||
tracker_pose_list() = default;
|
||||
|
||||
bool update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::tracking::pose & pose, const clock_offset & offset);
|
||||
bool update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::body_tracking::pose & pose, const clock_offset & offset);
|
||||
|
||||
std::pair<std::chrono::nanoseconds, xrt_space_relation> get_pose_at(XrTime at_timestamp_ns);
|
||||
|
||||
static xrt_space_relation convert_pose(const wivrn::from_headset::tracking::pose &);
|
||||
static xrt_space_relation convert_pose(const wivrn::from_headset::body_tracking::pose &);
|
||||
};
|
||||
|
||||
class wivrn_generic_tracker : public xrt_device
|
||||
@@ -55,6 +55,6 @@ public:
|
||||
xrt_result_t update_inputs();
|
||||
xrt_result_t get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * out_relation);
|
||||
|
||||
void update_tracking(const from_headset::tracking & tracking, const from_headset::tracking::pose & pose, const clock_offset & offset);
|
||||
void update_tracking(const from_headset::body_tracking & tracking, const from_headset::body_tracking::pose & pose, const clock_offset & offset);
|
||||
};
|
||||
} // namespace wivrn
|
||||
@@ -433,29 +433,6 @@ void wivrn_session::operator()(const from_headset::tracking & tracking)
|
||||
fb_face2_tracker->update_tracking(tracking, offset);
|
||||
else if (htc_face_tracker)
|
||||
htc_face_tracker->update_tracking(tracking, offset);
|
||||
|
||||
auto num_trackers = std::ranges::count(tracking.device_poses, device_id::GENERIC_TRACKER, &from_headset::tracking::pose::device);
|
||||
if (num_trackers == generic_trackers.size())
|
||||
{
|
||||
// the generic trackers should always be at end of poses list
|
||||
auto tracker = std::ranges::find(tracking.device_poses, device_id::GENERIC_TRACKER, &from_headset::tracking::pose::device);
|
||||
assert(tracker != tracking.device_poses.cend());
|
||||
for (size_t i = 0; i < num_trackers; ++i, ++tracker)
|
||||
{
|
||||
generic_trackers[i]->update_tracking(tracking, *tracker, offset);
|
||||
}
|
||||
}
|
||||
else if (tracking_control.get_enabled(to_headset::tracking_control::id::generic_tracker))
|
||||
{
|
||||
static std::chrono::steady_clock::time_point last_log{std::chrono::nanoseconds(0)};
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
// rate limit it because the log gets annoying when i'm trying to debug
|
||||
if (now - last_log > std::chrono::milliseconds(100))
|
||||
{
|
||||
U_LOG_W("[rate limited] Generic tracker count mismatch! Expected %" PRIu64 " poses, got %" PRIu64 " poses", generic_trackers.size(), num_trackers);
|
||||
last_log = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(from_headset::derived_pose && derived)
|
||||
@@ -471,6 +448,19 @@ void wivrn_session::operator()(from_headset::hand_tracking && hand_tracking)
|
||||
left_hand.update_hand_tracking(hand_tracking, offset);
|
||||
right_hand.update_hand_tracking(hand_tracking, offset);
|
||||
}
|
||||
void wivrn_session::operator()(from_headset::body_tracking && body_tracking)
|
||||
{
|
||||
auto offset = offset_est.get_offset();
|
||||
|
||||
for (int i = 0; i < generic_trackers.size(); i++)
|
||||
{
|
||||
auto pose = body_tracking.poses ? body_tracking.poses->at(i) : from_headset::body_tracking::pose{
|
||||
.pose = {},
|
||||
.flags = 0,
|
||||
};
|
||||
generic_trackers[i]->update_tracking(body_tracking, pose, offset);
|
||||
}
|
||||
}
|
||||
void wivrn_session::operator()(from_headset::inputs && inputs)
|
||||
{
|
||||
auto offset = get_offset();
|
||||
|
||||
@@ -166,6 +166,7 @@ public:
|
||||
void operator()(const from_headset::tracking &);
|
||||
void operator()(from_headset::derived_pose &&);
|
||||
void operator()(from_headset::hand_tracking &&);
|
||||
void operator()(from_headset::body_tracking &&);
|
||||
void operator()(from_headset::inputs &&);
|
||||
void operator()(from_headset::timesync_response &&);
|
||||
void operator()(from_headset::feedback &&);
|
||||
|
||||
Reference in New Issue
Block a user