Skip to content

Commit

Permalink
Added flag to disable use of expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Dafarra committed Oct 25, 2024
1 parent 7443f7c commit 34157de
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/devices/openxrheadset/OpenXrHeadset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ bool yarp::dev::OpenXrHeadset::open(yarp::os::Searchable &cfg)
bool noGaze = cfg.check("no_gaze") && (cfg.find("no_gaze").isNull() || cfg.find("no_gaze").asBool());
m_openXrInterfaceSettings.useGaze = !noGaze;

bool noExpressions = cfg.check("no_expressions") && (cfg.find("no_expressions").isNull() || cfg.find("no_expressions").asBool());
m_openXrInterfaceSettings.useExpressions = !noExpressions;

m_getStickAsAxis = cfg.check("stick_as_axis", yarp::os::Value(false)).asBool();
m_rootFrame = cfg.check("tf_root_frame", yarp::os::Value("openxr_origin")).asString();
m_rootFrameRaw = m_rootFrame + "_raw";
Expand Down
15 changes: 9 additions & 6 deletions src/devices/openxrheadset/OpenXrInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool OpenXrInterface::checkExtensions()
bool depth_supported = false;
bool debug_supported = false;
bool gaze_supported = false;
bool htc_facial_tracking_supported = false;

std::stringstream supported_extensions;
supported_extensions << "Supported extensions: " <<std::endl;
Expand All @@ -66,7 +67,7 @@ bool OpenXrInterface::checkExtensions()
}

if (strcmp(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME, ext_props[i].extensionName) == 0) {
m_pimpl->htc_facial_tracking_extension_supported = true;
htc_facial_tracking_supported = true;
}

if (strcmp(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME, ext_props[i].extensionName) == 0) {
Expand Down Expand Up @@ -102,8 +103,9 @@ bool OpenXrInterface::checkExtensions()
yCWarning(OPENXRHEADSET) << "Runtime does not support the HTC Vive Focus 3 controllers!";
}

if (!m_pimpl->htc_facial_tracking_extension_supported) {
if (!htc_facial_tracking_supported) {
yCWarning(OPENXRHEADSET) << "Runtime does not support the HTC Vive Facial Tracking!";
m_pimpl->use_expressions = false;
}

if (!gaze_supported) {
Expand Down Expand Up @@ -154,7 +156,7 @@ bool OpenXrInterface::prepareXrInstance()
{
requestedExtensions.push_back(XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME);
}
if (m_pimpl->htc_facial_tracking_extension_supported)
if (m_pimpl->use_expressions)
{
requestedExtensions.push_back(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME);
}
Expand Down Expand Up @@ -255,7 +257,7 @@ bool OpenXrInterface::prepareXrInstance()
return false;
}

if (m_pimpl->htc_facial_tracking_extension_supported)
if (m_pimpl->use_expressions)
{
result = xrGetInstanceProcAddr(m_pimpl->instance, "xrCreateFacialTrackerHTC",
(PFN_xrVoidFunction*)&(m_pimpl->pfn_xrCreateFacialTrackerHTC));
Expand Down Expand Up @@ -375,7 +377,7 @@ void OpenXrInterface::checkSystemProperties()
facial_tracking_props.supportEyeFacialTracking = XR_FALSE;
facial_tracking_props.supportLipFacialTracking = XR_FALSE;

if (m_pimpl->htc_facial_tracking_extension_supported)
if (m_pimpl->use_expressions)
{
*next_chain = &facial_tracking_props;
next_chain = &facial_tracking_props.next;
Expand Down Expand Up @@ -409,7 +411,7 @@ void OpenXrInterface::checkSystemProperties()
yCInfo(OPENXRHEADSET, "\tOrientation Tracking: %d", system_props.trackingProperties.orientationTracking);
yCInfo(OPENXRHEADSET, "\tPosition Tracking : %d", system_props.trackingProperties.positionTracking);

if (m_pimpl->htc_facial_tracking_extension_supported)
if (m_pimpl->use_expressions)
{
yCInfo(OPENXRHEADSET, "Facial tracking properties for system %lu: Eye tracking %d, Lip tracking %d",
system_props.systemId, facial_tracking_props.supportEyeFacialTracking, facial_tracking_props.supportLipFacialTracking);
Expand Down Expand Up @@ -1635,6 +1637,7 @@ bool OpenXrInterface::initialize(const OpenXrInterfaceSettings &settings)
m_pimpl->hideWindow = settings.hideWindow;
m_pimpl->renderInPlaySpace = settings.renderInPlaySpace;
m_pimpl->use_gaze = settings.useGaze;
m_pimpl->use_expressions = settings.useExpressions;

#ifdef DEBUG_RENDERING_LOCATION
m_pimpl->renderInPlaySpace = true;
Expand Down
1 change: 1 addition & 0 deletions src/devices/openxrheadset/OpenXrInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct OpenXrInterfaceSettings
bool hideWindow{false};
bool renderInPlaySpace{false};
bool useGaze{ true };
bool useExpressions{ true };
};

class OpenXrInterface
Expand Down
6 changes: 3 additions & 3 deletions src/devices/openxrheadset/impl/OpenXrInterfaceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,6 @@ class OpenXrInterface::Implementation
// flag to check if the HTC VIVE Focus3 controllers are supported by the runtime.
bool focus3_supported = false;

//flag to check if the HTC facial tracking is supported by the runtime.
bool htc_facial_tracking_extension_supported = false;

//flag to check if facial tracking is supported by the headset.
bool htc_eye_facial_tracking_supported = false;

Expand All @@ -330,6 +327,9 @@ class OpenXrInterface::Implementation
std::vector<float> htc_eye_expressions;
std::vector<float> htc_lip_expressions;

// Flag to enable the use of expressions
bool use_expressions = true;

// Flag to enable the use of gaze
bool use_gaze = true;

Expand Down

0 comments on commit 34157de

Please sign in to comment.