The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/wmr: Guess camera orientation for Reverb G2 based on HT0 twist value

+47 -4
+47 -4
src/xrt/drivers/wmr/wmr_hmd.c
··· 1480 1480 return sinks; 1481 1481 } 1482 1482 1483 + #ifdef XRT_BUILD_DRIVER_HANDTRACKING 1484 + static enum t_camera_orientation 1485 + wmr_hmd_guess_camera_orientation(struct wmr_hmd *wh) 1486 + { 1487 + struct xrt_quat Q_ht0_me = wh->P_ht0_me.orientation; 1488 + struct xrt_vec2 swing = {0}; 1489 + float twist = 0; 1490 + math_quat_to_swing_twist(&Q_ht0_me, &swing, &twist); 1491 + WMR_DEBUG(wh, "HT0 twist value is %f", twist); 1492 + 1493 + float abstwist = fabsf(twist); 1494 + 1495 + // Bottom quadrant 1496 + if (abstwist < M_PI / 4) { 1497 + WMR_DEBUG(wh, "I think this headset has CAMERA_ORIENTATION_0 front cameras!"); 1498 + return CAMERA_ORIENTATION_0; 1499 + } 1500 + 1501 + // Top quadrant 1502 + if (abstwist > 3 * M_PI / 4) { 1503 + WMR_DEBUG(wh, "I think this headset has CAMERA_ORIENTATION_180 front cameras!"); 1504 + return CAMERA_ORIENTATION_180; 1505 + } 1506 + 1507 + // Right quadrant 1508 + if (twist < 0) { 1509 + WMR_DEBUG(wh, "I think this headset has CAMERA_ORIENTATION_90 front cameras!"); 1510 + return CAMERA_ORIENTATION_90; 1511 + } 1512 + 1513 + // Left quadrant 1514 + WMR_DEBUG(wh, "I think this headset has CAMERA_ORIENTATION_270 front cameras!"); 1515 + return CAMERA_ORIENTATION_270; 1516 + } 1517 + #endif 1518 + 1483 1519 static int 1484 1520 wmr_hmd_hand_track(struct wmr_hmd *wh, 1485 1521 struct t_stereo_camera_calibration *stereo_calib, ··· 1492 1528 struct xrt_device *device = NULL; 1493 1529 1494 1530 #ifdef XRT_BUILD_DRIVER_HANDTRACKING 1495 - //!@todo Turning it off is okay for now, but we should plug metric_radius (or whatever it's called) in, at some 1496 - //! point. 1531 + 1497 1532 struct t_camera_extra_info extra_camera_info = {0}; 1498 1533 1499 - extra_camera_info.views[0].camera_orientation = CAMERA_ORIENTATION_0; 1500 - extra_camera_info.views[1].camera_orientation = CAMERA_ORIENTATION_0; 1534 + enum t_camera_orientation ori_guess = CAMERA_ORIENTATION_0; 1501 1535 1536 + if (wh->hmd_desc->hmd_type == WMR_HEADSET_GENERIC || // 1537 + wh->hmd_desc->hmd_type == WMR_HEADSET_REVERB_G2) { 1538 + ori_guess = wmr_hmd_guess_camera_orientation(wh); 1539 + } 1540 + extra_camera_info.views[0].camera_orientation = ori_guess; 1541 + extra_camera_info.views[1].camera_orientation = ori_guess; 1542 + 1543 + //!@todo Turning it off is okay for now, but we should plug metric_radius (or whatever it's called) in, at some 1544 + //! point. 1502 1545 extra_camera_info.views[0].boundary_type = HT_IMAGE_BOUNDARY_NONE; 1503 1546 extra_camera_info.views[1].boundary_type = HT_IMAGE_BOUNDARY_NONE; 1504 1547