Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hand tracking gestures #1794

Merged
merged 47 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ee30b6a
add settings for hand tracking
barnabwhy Aug 16, 2023
a2176b0
hands_to_gestures to get gestures from hand data
barnabwhy Aug 16, 2023
83a9327
activate button presses for gestures
barnabwhy Aug 16, 2023
3ba7909
adjust some values to improve gesture accuracy
barnabwhy Aug 16, 2023
e00abc8
move gesture binds into hands_to_gestures
barnabwhy Aug 16, 2023
c28461d
remember to set empty binds on dummy list
barnabwhy Aug 16, 2023
bc52852
fix build issues
barnabwhy Aug 16, 2023
82972ae
remove unnecessary enumerate
barnabwhy Aug 16, 2023
7af35de
support curl and add grip gesture
barnabwhy Aug 17, 2023
3a95b26
make finger thresholds slightly larger
barnabwhy Aug 17, 2023
d6727c1
add curl distance settings
barnabwhy Aug 17, 2023
c574af6
curl: use min of proximal and metacarpal
barnabwhy Aug 17, 2023
0a00862
add joystick press gesture + correct curl maths
barnabwhy Aug 17, 2023
0565e17
improve help strings for curl and pinch values
barnabwhy Aug 17, 2023
b5171fc
remove warns for curling
barnabwhy Aug 17, 2023
4edb859
fix broken right hand binds
barnabwhy Aug 17, 2023
92c4008
remove button press workaround
barnabwhy Aug 17, 2023
61e7da2
support vertical joystick control using thumb
barnabwhy Aug 17, 2023
fa01816
disable index pinching when controlling the joystick
barnabwhy Aug 17, 2023
580c404
0.0 not 0 :c
barnabwhy Aug 17, 2023
20d6dbf
dual axis joystick support
barnabwhy Aug 17, 2023
15dc07e
add gesture joystick deadzone
barnabwhy Aug 17, 2023
ed5b26d
config joystick deadzone and offset
barnabwhy Aug 17, 2023
e1eaabe
fix clippy errors
barnabwhy Aug 17, 2023
4b2551e
format
barnabwhy Aug 21, 2023
716b8eb
initial refactor work
barnabwhy Aug 25, 2023
27e60dc
migration to handgesturemanager (untested)
barnabwhy Aug 26, 2023
a57d7cf
make gesture activation work
barnabwhy Aug 30, 2023
55ef7e3
touch binds + correct click binds
barnabwhy Aug 30, 2023
6ff930c
increase default stop delay
barnabwhy Aug 30, 2023
0b00d58
rename gesture delay settings
barnabwhy Aug 30, 2023
0a11357
fix joystick click
barnabwhy Aug 30, 2023
8acbd6a
fmt
barnabwhy Aug 30, 2023
c8f4a8a
I DID IT !!!! JOYSTICK !!!!!!!
barnabwhy Aug 30, 2023
21041a7
rename hover to value
barnabwhy Aug 30, 2023
5563f97
remove hand tracking toggle
barnabwhy Aug 30, 2023
9e7163c
handed abxy IDs
barnabwhy Sep 5, 2023
3ff070d
format
barnabwhy Sep 5, 2023
de15928
use button mapping manager (slightly broken?)
barnabwhy Sep 5, 2023
9ce879b
format
barnabwhy Sep 5, 2023
808162c
review response :)
barnabwhy Sep 10, 2023
6f307b1
fmt
barnabwhy Sep 10, 2023
f207be8
add joystick range setting + increase default deadzone
barnabwhy Sep 10, 2023
de0704a
review response sequel
barnabwhy Sep 11, 2023
d2c9fc1
fmt
barnabwhy Sep 11, 2023
0889776
fix collapsible on hand tracking settings
barnabwhy Sep 11, 2023
66e5500
code smell :c
barnabwhy Sep 11, 2023
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
69 changes: 66 additions & 3 deletions alvr/server/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
bitrate::BitrateManager,
face_tracking::FaceTrackingSink,
hand_gestures::{trigger_hand_gesture_actions, HandGestureManager, HAND_GESTURE_BUTTON_SET},
haptics,
input_mapping::ButtonMappingManager,
sockets::WelcomeSocket,
Expand Down Expand Up @@ -643,9 +644,27 @@ fn try_connect(mut client_ips: HashMap<IpAddr, String>) -> ConResult {
};

let tracking_manager = Arc::new(Mutex::new(TrackingManager::new()));
let hand_gesture_manager = Arc::new(Mutex::new(HandGestureManager::new()));

let tracking_receive_thread = thread::spawn({
let tracking_manager = Arc::clone(&tracking_manager);
let hand_gesture_manager = Arc::clone(&hand_gesture_manager);

let mut gestures_button_mapping_manager = SERVER_DATA_MANAGER
.read()
.settings()
.headset
.controllers
.as_option()
.and_then(|config| {
config.hand_tracking.use_gestures.as_option().and_then(|_| {
Some(ButtonMappingManager::new_automatic(
&HAND_GESTURE_BUTTON_SET,
&config.button_mapping_config,
))
})
});

move || {
let mut face_tracking_sink =
settings
Expand All @@ -657,7 +676,7 @@ fn try_connect(mut client_ips: HashMap<IpAddr, String>) -> ConResult {
});

let mut track_controllers = 0u32;
if let Switch::Enabled(config) = settings.headset.controllers {
if let Switch::Enabled(config) = &settings.headset.controllers {
track_controllers = config.tracked.into();
}

Expand All @@ -679,6 +698,7 @@ fn try_connect(mut client_ips: HashMap<IpAddr, String>) -> ConResult {
{
let data_manager_lock = SERVER_DATA_MANAGER.read();
let config = &data_manager_lock.settings().headset;

motions = tracking_manager_lock.transform_motions(
config,
&tracking.device_motions,
Expand Down Expand Up @@ -740,14 +760,57 @@ fn try_connect(mut client_ips: HashMap<IpAddr, String>) -> ConResult {
.into_iter()
.map(|(id, motion)| tracking::to_ffi_motion(id, motion))
.collect::<Vec<_>>();
let ffi_left_hand_skeleton = left_hand_skeleton.map(tracking::to_ffi_skeleton);
let ffi_right_hand_skeleton = right_hand_skeleton.map(tracking::to_ffi_skeleton);
let mut ffi_left_hand_skeleton = left_hand_skeleton.map(tracking::to_ffi_skeleton);
let mut ffi_right_hand_skeleton =
right_hand_skeleton.map(tracking::to_ffi_skeleton);

drop(tracking_manager_lock);

if let Some(stats) = &mut *STATISTICS_MANAGER.lock() {
stats.report_tracking_received(tracking.target_timestamp);

// Handle hand gestures
if let Switch::Enabled(controllers_config) = &settings.headset.controllers {
if let Switch::Enabled(gestures_config) =
&controllers_config.hand_tracking.use_gestures
{
let mut hand_gesture_manager_lock = hand_gesture_manager.lock();

if let Some(hand_skeleton) = tracking.hand_skeletons[0] {
trigger_hand_gesture_actions(
gestures_button_mapping_manager.as_mut().unwrap(),
barnabwhy marked this conversation as resolved.
Show resolved Hide resolved
*LEFT_HAND_ID,
&hand_gesture_manager_lock.get_active_gestures(
hand_skeleton,
gestures_config.clone(),
*LEFT_HAND_ID,
),
);
}
if let Some(hand_skeleton) = tracking.hand_skeletons[1] {
trigger_hand_gesture_actions(
gestures_button_mapping_manager.as_mut().unwrap(),
*RIGHT_HAND_ID,
&hand_gesture_manager_lock.get_active_gestures(
hand_skeleton,
gestures_config.clone(),
*RIGHT_HAND_ID,
),
);
}
}
}

let data_manager_lock = SERVER_DATA_MANAGER.read();
let config = &data_manager_lock.settings().headset;

if let Switch::Enabled(controllers) = &config.controllers {
if !controllers.hand_tracking.enable_skeleton {
ffi_left_hand_skeleton = None;
ffi_right_hand_skeleton = None;
}
}

unsafe {
crate::SetTracking(
tracking.target_timestamp.as_nanos() as _,
Expand Down
Loading
Loading