d/wmr: Wait until first IMU sample to send frames

In an Odyssey+, it seems that before the first IMU sample the frame timestamps
do not make sense and thus can make the SLAM system crash.

Also, this commit enables SLAM submission from start unless specified.
SLAM for WMR headsets now works "out of the box" :)
This commit is contained in:
Mateo de Mayo 2022-05-23 11:15:43 -03:00
parent 24be4b0a98
commit 2785c6bcfa
2 changed files with 10 additions and 2 deletions

View file

@ -68,6 +68,9 @@ DEBUG_GET_ONCE_BOOL_OPTION(wmr_slam, "WMR_SLAM", true)
//! Specifies whether the user wants to use the hand tracker.
DEBUG_GET_ONCE_BOOL_OPTION(wmr_handtracking, "WMR_HANDTRACKING", true)
//! Whether to submit samples to the SLAM tracker from the start.
DEBUG_GET_ONCE_OPTION(slam_submit_from_start, "SLAM_SUBMIT_FROM_START", NULL)
static int
wmr_hmd_activate_reverb(struct wmr_hmd *wh);
static void
@ -1385,6 +1388,9 @@ wmr_hmd_slam_track(struct wmr_hmd *wh,
config.stereo_calib = stereo_calib; // No need to do refcount here
config.imu_calib = imu_calib;
config.extra_calib = extra_calib;
if (debug_get_option_slam_submit_from_start() == NULL) {
config.submit_from_start = true;
}
int create_status = t_slam_create(&wh->tracking.xfctx, &config, &wh->tracking.slam, &sinks);
if (create_status != 0) {

View file

@ -73,6 +73,7 @@ struct wmr_source
struct m_ff_vec3_f32 *accel_ff; //!< Queue of accelerometer data to display in UI
bool is_running; //!< Whether the device is streaming
bool first_imu_received; //!< Don't send frames until first IMU sample
bool average_imus; //!< Average 4 IMU samples before sending them to the sinks
time_duration_ns hw2mono; //!< Estimated offset from IMU to monotonic clock
time_duration_ns cam_hw2mono; //!< Cache for hw2mono used in last left frame
@ -124,7 +125,7 @@ receive_left_frame(struct xrt_frame_sink *sink, struct xrt_frame *xf)
clock_cam_hw2mono(ws, xf, true);
WMR_TRACE(ws, "left img t=%ld source_t=%ld", xf->timestamp, xf->source_timestamp);
u_sink_debug_push_frame(&ws->ui_left_sink, xf);
if (ws->out_sinks.left) {
if (ws->out_sinks.left && ws->first_imu_received) {
xrt_sink_push_frame(ws->out_sinks.left, xf);
}
}
@ -136,7 +137,7 @@ receive_right_frame(struct xrt_frame_sink *sink, struct xrt_frame *xf)
clock_cam_hw2mono(ws, xf, false);
WMR_TRACE(ws, "right img t=%ld source_t=%ld", xf->timestamp, xf->source_timestamp);
u_sink_debug_push_frame(&ws->ui_right_sink, xf);
if (ws->out_sinks.right) {
if (ws->out_sinks.right && ws->first_imu_received) {
xrt_sink_push_frame(ws->out_sinks.right, xf);
}
}
@ -160,6 +161,7 @@ receive_imu_sample(struct xrt_imu_sink *sink, struct xrt_imu_sample *s)
if (ws->out_sinks.imu) {
xrt_sink_push_imu(ws->out_sinks.imu, s);
}
ws->first_imu_received = true;
}