Monado OpenXR Runtime
|
Driver code for a WMR HMD. More...
#include "xrt/xrt_config_drivers.h"
#include "xrt/xrt_config_have.h"
#include "xrt/xrt_config_build.h"
#include "xrt/xrt_config_os.h"
#include "xrt/xrt_defines.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_tracking.h"
#include "os/os_time.h"
#include "os/os_hid.h"
#include "math/m_api.h"
#include "math/m_mathinclude.h"
#include "math/m_predict.h"
#include "math/m_vec2.h"
#include "util/u_var.h"
#include "util/u_misc.h"
#include "util/u_time.h"
#include "util/u_debug.h"
#include "util/u_device.h"
#include "util/u_trace_marker.h"
#include "util/u_distortion_mesh.h"
#include "util/u_sink.h"
#include "util/u_linux.h"
#include "tracking/t_tracking.h"
#include "wmr_hmd.h"
#include "wmr_common.h"
#include "wmr_config_key.h"
#include "wmr_protocol.h"
#include "wmr_source.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
Macros | |
#define | CAMERA_FREQUENCY 30 |
Observed value (OV7251) More... | |
#define | IMU_FREQUENCY 1000 |
Observed value (ICM20602) More... | |
#define | IMU_SAMPLES_PER_PACKET 4 |
There are 4 samples for each USB IMU packet. More... | |
#define | WMR_TRACE(d, ...) U_LOG_XDEV_IFL_T(&d->base, d->log_level, __VA_ARGS__) |
Specifies whether the user wants to use a SLAM tracker. More... | |
#define | WMR_DEBUG(d, ...) U_LOG_XDEV_IFL_D(&d->base, d->log_level, __VA_ARGS__) |
#define | WMR_DEBUG_HEX(d, data, data_size) U_LOG_XDEV_IFL_D_HEX(&d->base, d->log_level, data, data_size) |
#define | WMR_INFO(d, ...) U_LOG_XDEV_IFL_I(&d->base, d->log_level, __VA_ARGS__) |
#define | WMR_WARN(d, ...) U_LOG_XDEV_IFL_W(&d->base, d->log_level, __VA_ARGS__) |
#define | WMR_ERROR(d, ...) U_LOG_XDEV_IFL_E(&d->base, d->log_level, __VA_ARGS__) |
#define | HID_SEND(hmd, HID, DATA, STR) |
#define | HID_GET(hmd, HID, DATA, STR) |
Functions | |
static int | wmr_hmd_activate_reverb (struct wmr_hmd *wh) |
static void | wmr_hmd_deactivate_reverb (struct wmr_hmd *wh) |
static void | wmr_hmd_screen_enable_reverb (struct wmr_hmd *wh, bool enable) |
static int | wmr_hmd_activate_odyssey_plus (struct wmr_hmd *wh) |
static void | wmr_hmd_deactivate_odyssey_plus (struct wmr_hmd *wh) |
static void | wmr_hmd_screen_enable_odyssey_plus (struct wmr_hmd *wh, bool enable) |
static void | hololens_sensors_decode_packet (struct wmr_hmd *wh, struct hololens_sensors_packet *pkt, const unsigned char *buffer, int size) |
static void | hololens_ensure_controller (struct wmr_hmd *wh, uint8_t controller_id, uint16_t vid, uint16_t pid) |
static void | hololens_handle_unknown (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_control (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_controller_status_packet (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_bt_iface_packet (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_controller_packet (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_debug (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_sensors_avg (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_sensors_all (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static void | hololens_handle_sensors (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static bool | hololens_sensors_read_packets (struct wmr_hmd *wh) |
static void | control_ipd_value_decode (struct wmr_hmd *wh, const unsigned char *buffer, int size) |
static bool | control_read_packets (struct wmr_hmd *wh) |
static void * | wmr_run_thread (void *ptr) |
static void | hololens_sensors_enable_imu (struct wmr_hmd *wh) |
static void | wmr_hmd_refresh_debug_gui (struct wmr_hmd *wh) |
static void | wmr_hmd_screen_enable_toggle (void *wh_ptr) |
static int | wmr_config_command_sync (struct wmr_hmd *wh, unsigned char type, unsigned char *buf, int len) |
static int | wmr_read_config_part (struct wmr_hmd *wh, unsigned char type, unsigned char *data, int len) |
static XRT_MAYBE_UNUSED int | wmr_read_config_raw (struct wmr_hmd *wh, uint8_t **out_data, size_t *out_size) |
static int | wmr_read_config (struct wmr_hmd *wh) |
static xrt_result_t | wmr_hmd_get_3dof_tracked_pose (struct xrt_device *xdev, enum xrt_input_name name, uint64_t at_timestamp_ns, struct xrt_space_relation *out_relation) |
static XRT_MAYBE_UNUSED struct xrt_pose | wmr_hmd_correct_pose_from_basalt (struct xrt_pose pose) |
Specific pose corrections for Basalt and a WMR headset. More... | |
static void | wmr_hmd_get_slam_tracked_pose (struct xrt_device *xdev, enum xrt_input_name name, uint64_t at_timestamp_ns, struct xrt_space_relation *out_relation) |
static xrt_result_t | wmr_hmd_get_tracked_pose (struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation) |
static void | wmr_hmd_destroy (struct xrt_device *xdev) |
static xrt_result_t | compute_distortion_wmr (struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *result) |
static void | compute_distortion_bounds (struct wmr_hmd *wh, int view, float *out_angle_left, float *out_angle_right, float *out_angle_down, float *out_angle_up) |
static XRT_MAYBE_UNUSED struct t_camera_calibration | wmr_hmd_get_cam_calib (struct wmr_hmd *wh, int cam_index) |
static XRT_MAYBE_UNUSED struct xrt_vec2 | wmr_hmd_camera_project (struct wmr_hmd *wh, struct xrt_vec3 p3d) |
static XRT_MAYBE_UNUSED struct t_stereo_camera_calibration * | wmr_hmd_create_stereo_camera_calib (struct wmr_hmd *wh) |
Creates an OpenCV-compatible t_stereo_camera_calibration pointer from the WMR config. More... | |
static XRT_MAYBE_UNUSED void | wmr_hmd_fill_slam_cams_calibration (struct wmr_hmd *wh) |
Extended camera calibration info for SLAM. More... | |
static XRT_MAYBE_UNUSED struct t_imu_calibration | wmr_hmd_get_imu_calib (struct wmr_hmd *wh) |
static XRT_MAYBE_UNUSED void | wmr_hmd_fill_slam_imu_calibration (struct wmr_hmd *wh) |
Extended IMU calibration data for SLAM. More... | |
static XRT_MAYBE_UNUSED void | wmr_hmd_fill_slam_calibration (struct wmr_hmd *wh) |
static void | wmr_hmd_switch_hmd_tracker (void *wh_ptr) |
static struct xrt_slam_sinks * | wmr_hmd_slam_track (struct wmr_hmd *wh) |
static int | wmr_hmd_hand_track (struct wmr_hmd *wh, struct t_stereo_camera_calibration *stereo_calib, struct xrt_hand_masks_sink *masks_sink, struct xrt_slam_sinks **out_sinks, struct xrt_device **out_device) |
static void | wmr_hmd_setup_ui (struct wmr_hmd *wh) |
static bool | wmr_hmd_setup_trackers (struct wmr_hmd *wh, struct xrt_slam_sinks *out_sinks, struct xrt_device **out_handtracker) |
Procedure to setup trackers: 3dof, SLAM and hand tracking. More... | |
static bool | wmr_hmd_request_controller_status (struct wmr_hmd *wh) |
void | wmr_hmd_create (enum wmr_headset_type hmd_type, struct os_hid_device *hid_holo, struct os_hid_device *hid_ctrl, struct xrt_prober_device *dev_holo, enum u_logging_level log_level, struct xrt_device **out_hmd, struct xrt_device **out_handtracker, struct xrt_device **out_left_controller, struct xrt_device **out_right_controller) |
bool | wmr_hmd_send_controller_packet (struct wmr_hmd *hmd, const uint8_t *buffer, uint32_t buf_size) |
int | wmr_hmd_read_sync_from_controller (struct wmr_hmd *hmd, uint8_t *buffer, uint32_t buf_size, int timeout_ms) |
Variables | |
const struct wmr_headset_descriptor | headset_map [] |
const int | headset_map_n = sizeof(headset_map) / sizeof(headset_map[0]) |
Driver code for a WMR HMD.
#define CAMERA_FREQUENCY 30 |
Observed value (OV7251)
#define HID_GET | ( | hmd, | |
HID, | |||
DATA, | |||
STR | |||
) |
#define HID_SEND | ( | hmd, | |
HID, | |||
DATA, | |||
STR | |||
) |
#define IMU_FREQUENCY 1000 |
Observed value (ICM20602)
#define IMU_SAMPLES_PER_PACKET 4 |
There are 4 samples for each USB IMU packet.
#define WMR_TRACE | ( | d, | |
... | |||
) | U_LOG_XDEV_IFL_T(&d->base, d->log_level, __VA_ARGS__) |
Specifies whether the user wants to use a SLAM tracker.
Specifies whether the user wants to use a SLAM tracker. Specifies whether the user wants to use the hand tracker. Specifies the y offset of the views.
|
inlinestatic |
Specific pose corrections for Basalt and a WMR headset.
void wmr_hmd_create | ( | enum wmr_headset_type | hmd_type, |
struct os_hid_device * | hid_holo, | ||
struct os_hid_device * | hid_ctrl, | ||
struct xrt_prober_device * | dev_holo, | ||
enum u_logging_level | log_level, | ||
struct xrt_device ** | out_hmd, | ||
struct xrt_device ** | out_handtracker, | ||
struct xrt_device ** | out_left_controller, | ||
struct xrt_device ** | out_right_controller | ||
) |
|
static |
Creates an OpenCV-compatible t_stereo_camera_calibration pointer from the WMR config.
Note that the camera model used on WMR headsets seems to be the same as the one in Azure-Kinect-Sensor-SDK. That model is slightly different than OpenCV's in the following ways:
Thankfully, parameters of points 1 and 2 tend to be almost zero in practice. For 3, we place metric_radius into the calibration struct so that downstream tracking algorithms can use it as needed.
References T_DISTORTION_WMR, t_stereo_camera_calibration::t_stereo_camera_calibration_alloc(), and t_stereo_camera_calibration::view.
|
static |
|
static |
|
static |
Extended camera calibration info for SLAM.
References t_slam_calibration::cam_count, t_slam_calibration::cams, wmr_hmd::config, xrt_matrix_4x4::math_matrix_4x4_isometry_from_pose(), wmr_inertial_sensor_config::pose, wmr_hmd::slam_calib, wmr_hmd_config::tcam_count, and wmr_hmd::tracking.
|
static |
Extended IMU calibration data for SLAM.
average_imus
might change during runtime but the calibration data will be already submittedReferences wmr_hmd::average_imus, IMU_FREQUENCY, and IMU_SAMPLES_PER_PACKET.
|
static |
Procedure to setup trackers: 3dof, SLAM and hand tracking.
Determines which trackers to initialize and starts them. Fills out_sinks
to stream raw data to for tracking. In the case of hand tracking being enabled, it returns a hand tracker device in out_handtracker
.
wh | the wmr headset device |
out_sinks | sinks to stream video/IMU data to for tracking |
out_handtracker | a newly created hand tracker device |
const struct wmr_headset_descriptor headset_map[] |