Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions src/plugins/sharpa_avatar/core/avatar_hand_tracking_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,11 @@ void AvatarTracker::refresh_data()
{
continue;
}
if (!state.device->get_device_info().online)
{
state.reset();
continue;
}
// Liveness comes from fetched data, not get_device_info().online: the SDK
// leaves that flag false on a glove first discovered offline and powered on later.
// A haptic-only glove still fetches RAW so the data timeout below can drop a dead handle.
const bool probe_raw = !m_config.human && !m_config.raw && !m_config.robot;

const bool expects_data = m_config.human || m_config.raw || m_config.robot;
// fetch_data() keeps returning a silent glove's last sample, so only a newer
// sample stamp counts as data for the timeout below.
bool fetched_any = false;
Expand Down Expand Up @@ -464,7 +462,7 @@ void AvatarTracker::refresh_data()
}
for (const ::avatar::DeviceDataCategory category : kJointDataCategories)
{
if (!dataset_enabled(category))
if (!dataset_enabled(category) && !(probe_raw && category == ::avatar::DeviceDataCategory::RAW))
{
continue;
}
Expand All @@ -481,18 +479,15 @@ void AvatarTracker::refresh_data()
cached = {};
}
}
if (expects_data)
const auto now = std::chrono::steady_clock::now();
if (fetched_any)
{
const auto now = std::chrono::steady_clock::now();
if (fetched_any)
{
state.last_successful_fetch = now;
}
else if (!state.last_successful_fetch || now - *state.last_successful_fetch >= kAvatarDataTimeout)
{
logger()->warn("{} glove disconnected: no data for {} s.", to_string(side), kAvatarDataTimeout.count());
state.reset();
}
state.last_successful_fetch = now;
}
else if (!state.last_successful_fetch || now - *state.last_successful_fetch >= kAvatarDataTimeout)
{
logger()->warn("{} glove disconnected: no data for {} s.", to_string(side), kAvatarDataTimeout.count());
state.reset();
}
}
}
Expand Down
Loading