Use shared pose_flags enum in packets

This commit is contained in:
Sapphire
2026-07-10 13:22:13 -05:00
parent 2e28b0a4ad
commit 534b4c23e3
12 changed files with 80 additions and 213 deletions
+2 -24
View File
@@ -20,6 +20,7 @@
#include "hand_joints_list.h"
#include "math/m_space.h"
#include "pose_list.h"
#include "wivrn_packets.h"
#include "xrt_cast.h"
static_assert(XRT_HAND_JOINT_COUNT == XR_HAND_JOINT_COUNT_EXT);
@@ -53,33 +54,10 @@ xrt_hand_joint_set hand_joints_list::extrapolate(const xrt_hand_joint_set & a, c
return t <= ta ? a : b;
}
static xrt_space_relation_flags cast_flags(uint8_t in_flags)
{
std::underlying_type_t<xrt_space_relation_flags> flags = 0;
if (in_flags & from_headset::hand_tracking::position_valid)
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
if (in_flags & from_headset::hand_tracking::orientation_valid)
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
if (in_flags & from_headset::hand_tracking::linear_velocity_valid)
flags |= XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT;
if (in_flags & from_headset::hand_tracking::angular_velocity_valid)
flags |= XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT;
if (in_flags & from_headset::hand_tracking::position_tracked)
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
if (in_flags & from_headset::hand_tracking::orientation_tracked)
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
return xrt_space_relation_flags(flags);
}
static xrt_space_relation to_relation(const from_headset::hand_tracking::pose & pose)
{
return {
.relation_flags = cast_flags(pose.flags),
.relation_flags = from_pose_flags(pose.flags),
.pose = xrt_cast(XrPosef{
.orientation = pose.orientation,
.position = pose.position,
+4 -4
View File
@@ -166,19 +166,19 @@ void pose_list::add_sample(XrTime production_timestamp, XrTime timestamp, const
// TODO keep the tracked flag
polynomial_interpolator<3>::sample position{production_timestamp, timestamp};
if (pose.flags & from_headset::tracking::position_valid)
if (pose.flags & from_headset::pose_flags::position_valid)
position.y.emplace(
pose.pose.position.x,
pose.pose.position.y,
pose.pose.position.z);
if (pose.flags & from_headset::tracking::linear_velocity_valid)
if (pose.flags & from_headset::pose_flags::linear_velocity_valid)
position.dy.emplace(
pose.linear_velocity.x,
pose.linear_velocity.y,
pose.linear_velocity.z);
polynomial_interpolator<4, true>::sample orientation{production_timestamp, timestamp};
if (pose.flags & from_headset::tracking::orientation_valid)
if (pose.flags & from_headset::pose_flags::orientation_valid)
{
orientation.y.emplace(
pose.pose.orientation.w,
@@ -186,7 +186,7 @@ void pose_list::add_sample(XrTime production_timestamp, XrTime timestamp, const
pose.pose.orientation.y,
pose.pose.orientation.z);
if (pose.flags & from_headset::tracking::angular_velocity_valid)
if (pose.flags & from_headset::pose_flags::angular_velocity_valid)
{
Eigen::Quaternionf q{
pose.pose.orientation.w,
+3 -37
View File
@@ -34,44 +34,10 @@ static_assert(std::to_underlying(XR_BODY_JOINT_COUNT_FB) == std::to_underlying(X
static_assert(std::to_underlying(XR_FULL_BODY_JOINT_COUNT_META) == std::to_underlying(XRT_FULL_BODY_JOINT_COUNT_META));
static_assert(XR_BODY_JOINT_COUNT_BD == XRT_BODY_JOINT_COUNT_BD);
static xrt_space_relation_flags cast_meta_flags(uint8_t in_flags)
{
std::underlying_type_t<xrt_space_relation_flags> flags = 0;
if (in_flags & wivrn::from_headset::meta_body::position_valid)
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
if (in_flags & wivrn::from_headset::meta_body::orientation_valid)
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
if (in_flags & wivrn::from_headset::meta_body::position_tracked)
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
if (in_flags & wivrn::from_headset::meta_body::orientation_tracked)
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
return xrt_space_relation_flags(flags);
}
static xrt_space_relation_flags cast_bd_flags(uint8_t in_flags)
{
std::underlying_type_t<xrt_space_relation_flags> flags = 0;
if (in_flags & wivrn::from_headset::bd_body::position_valid)
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
if (in_flags & wivrn::from_headset::bd_body::orientation_valid)
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
if (in_flags & wivrn::from_headset::bd_body::position_tracked)
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
if (in_flags & wivrn::from_headset::bd_body::orientation_tracked)
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
return xrt_space_relation_flags(flags);
}
static xrt_space_relation to_relation(const wivrn::from_headset::meta_body::pose & pose)
{
return {
.relation_flags = cast_meta_flags(pose.flags),
.relation_flags = from_pose_flags(pose.flags),
.pose = xrt_cast(XrPosef{
.orientation = pose.orientation,
.position = pose.position,
@@ -81,7 +47,7 @@ static xrt_space_relation to_relation(const wivrn::from_headset::meta_body::pose
static xrt_space_relation to_relation(const wivrn::from_headset::bd_body::pose & pose)
{
return {
.relation_flags = cast_bd_flags(pose.flags),
.relation_flags = from_pose_flags(pose.flags),
.pose = xrt_cast(XrPosef{
.orientation = pose.orientation,
.position = pose.position,
@@ -91,7 +57,7 @@ static xrt_space_relation to_relation(const wivrn::from_headset::bd_body::pose &
static xrt_space_relation to_relation(const wivrn::from_headset::meta_body::pose & base, const wivrn::from_headset::meta_body::packed_pose & pose)
{
return {
.relation_flags = cast_meta_flags(pose.flags),
.relation_flags = from_pose_flags(pose.flags),
.pose = xrt_cast(XrPosef{
.orientation = pose.orientation,
.position = {
+1 -18
View File
@@ -34,23 +34,6 @@
using namespace xrt::auxiliary::math;
static xrt_space_relation_flags cast_flags(uint8_t in_flags)
{
std::underlying_type_t<xrt_space_relation_flags> flags{};
if (in_flags & wivrn::from_headset::htc_body::orientation_valid)
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
if (in_flags & wivrn::from_headset::htc_body::position_valid)
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
if (in_flags & wivrn::from_headset::htc_body::orientation_tracked)
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
if (in_flags & wivrn::from_headset::htc_body::position_tracked)
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
return xrt_space_relation_flags(flags);
}
namespace wivrn
{
@@ -90,7 +73,7 @@ xrt_space_relation tracker_pose_list::extrapolate(const xrt_space_relation & a,
void tracker_pose_list::update_tracking(XrTime produced_timestamp, XrTime timestamp, const from_headset::htc_body::pose & pose, const clock_offset & offset)
{
xrt_space_relation rel{
.relation_flags = cast_flags(pose.flags),
.relation_flags = from_pose_flags(pose.flags),
.pose = xrt_cast(pose.pose),
};
add_sample(produced_timestamp, timestamp, rel, offset);
+20
View File
@@ -18,7 +18,9 @@
*/
#include "xrt_cast.h"
#include "wivrn_packets.h"
#include <cstring>
#include <type_traits>
namespace
{
@@ -45,3 +47,21 @@ XRT_CAST(XrFovf, xrt_fov)
XRT_CAST(xrt_pose, XrPosef)
XRT_CAST(xrt_fov, XrFovf)
xrt_space_relation_flags from_pose_flags(uint8_t in_flags)
{
std::underlying_type_t<xrt_space_relation_flags> flags{};
if (in_flags & wivrn::from_headset::pose_flags::orientation_valid)
flags |= XRT_SPACE_RELATION_ORIENTATION_VALID_BIT;
if (in_flags & wivrn::from_headset::pose_flags::position_valid)
flags |= XRT_SPACE_RELATION_POSITION_VALID_BIT;
if (in_flags & wivrn::from_headset::pose_flags::linear_velocity_valid)
flags |= XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT;
if (in_flags & wivrn::from_headset::pose_flags::angular_velocity_valid)
flags |= XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT;
if (in_flags & wivrn::from_headset::pose_flags::orientation_tracked)
flags |= XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT;
if (in_flags & wivrn::from_headset::pose_flags::position_tracked)
flags |= XRT_SPACE_RELATION_POSITION_TRACKED_BIT;
return xrt_space_relation_flags(flags);
}
+2
View File
@@ -29,3 +29,5 @@ xrt_fov xrt_cast(const XrFovf &);
XrPosef xrt_cast(const xrt_pose &);
XrFovf xrt_cast(const xrt_fov &);
xrt_space_relation_flags from_pose_flags(uint8_t in_flags);