Use separate packet to send generic tracker poses
This commit is contained in:
@@ -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