The open source OpenXR runtime
0
fork

Configure Feed

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

st/prober: Improve usage of SLAM tracking frameservers

Use a similar "hardcoded" idea as in p_factory_ensure_frameserver.
This fix usage of SLAM sources in other contexts like calibration, at the
cost of requiring a device to call create_tracked_slam at least once.
(again, similar to how psmv/psvr/hand tracking work already)

authored by

Mateo de Mayo and committed by
Jakob Bornecrantz
0202cb92 773eccad

+66 -55
+7 -8
src/xrt/drivers/euroc/euroc_device.c
··· 251 251 xd->get_view_pose = euroc_get_view_pose; 252 252 } 253 253 254 - int ret = xp->tracking->create_tracked_slam(xp->tracking, xd, &ed->slam); 255 - if (ret < 0) { 256 - EUROC_WARN(ed, 257 - "Unable to create the SLAM tracker so the Euroc device won't be tracked.\n\t" 258 - "Did you provide the appropriate SLAM dependency when compiling?"); 259 - // However, we can continue, maybe the user just wants to play with the euroc utilities 260 - } 261 - 262 254 u_var_add_root(ed, dev_name, false); 263 255 u_var_add_pose(ed, &ed->pose, "pose"); 264 256 u_var_add_pose(ed, &ed->offset, "offset"); 265 257 u_var_add_pose(ed, &ed->tracking_origin.offset, "tracking offset"); 258 + 259 + bool tracked = xp->tracking->create_tracked_slam(xp->tracking, xd, &ed->slam) >= 0; 260 + if (!tracked) { 261 + EUROC_WARN(ed, "Unable to setup the SLAM tracker"); 262 + euroc_device_destroy(xd); 263 + return NULL; 264 + } 266 265 267 266 return xd; 268 267 }
+16 -17
src/xrt/state_trackers/prober/p_prober.c
··· 977 977 978 978 XRT_MAYBE_UNUSED struct prober_device *pdev = (struct prober_device *)xpdev; 979 979 980 - #if defined(XRT_BUILD_DRIVER_EUROC) 981 - // TODO: If both VF_PATH and EUROC_PATH are set, VF will be ignored on calibration 982 - const char *euroc_path = debug_get_option_euroc_path(); 983 - if (euroc_path != NULL) { 984 - *out_xfs = euroc_player_create(xfctx, euroc_path); // Euroc will exit if it can't be created 985 - return 0; 986 - } 987 - #endif 988 - 989 980 #if defined(XRT_BUILD_DRIVER_VF) 990 981 const char *path = debug_get_option_vf_path(); 991 982 if (path != NULL) { ··· 994 985 *out_xfs = xfs; 995 986 return 0; 996 987 } 988 + } 989 + #endif 990 + 991 + #if defined(XRT_BUILD_DRIVER_EUROC) 992 + const char *euroc_path = debug_get_option_euroc_path(); 993 + if (euroc_path != NULL) { 994 + *out_xfs = euroc_player_create(xfctx, euroc_path); // Euroc will exit if it can't be created 995 + return 0; 997 996 } 998 997 #endif 999 998 ··· 1020 1019 { 1021 1020 struct prober *p = (struct prober *)xp; 1022 1021 1023 - const char *path = debug_get_option_vf_path(); 1024 - if (path != NULL) { 1025 - cb(xp, NULL, "Video File", "Collabora", path, ptr); 1026 - } 1022 + // Video sources from drivers (at most one will be listed) 1023 + const char *vf_path = debug_get_option_vf_path(); 1024 + const char *euroc_path = debug_get_option_euroc_path(); 1027 1025 1028 - path = debug_get_option_euroc_path(); 1029 - if (path != NULL) { 1030 - cb(xp, NULL, "Euroc Dataset", "Collabora", path, ptr); 1026 + if (vf_path != NULL) { 1027 + cb(xp, NULL, "Video File", "Collabora", vf_path, ptr); 1028 + } else if (euroc_path != NULL) { 1029 + cb(xp, NULL, "Euroc Dataset", "Collabora", euroc_path, ptr); 1031 1030 } 1032 1031 1033 - // Loop over all devices and find video devices. 1032 + // Video sources from video devices 1034 1033 for (size_t i = 0; i < p->num_devices; i++) { 1035 1034 struct prober_device *pdev = &p->devices[i]; 1036 1035
+43 -30
src/xrt/state_trackers/prober/p_tracking.c
··· 234 234 // Start the stream now. 235 235 xrt_fs_stream_start(fact->xfs, xsink, XRT_FS_CAPTURE_TYPE_TRACKING, fact->settings.camera_mode); 236 236 } 237 + 238 + //! @todo Similar to p_factory_ensure_frameserver but for SLAM sources. 239 + //! Therefore we can only have one SLAM tracker at a time, with exactly one SLAM 240 + //! tracked device. It would be good to solve these artificial restrictions. 241 + static bool 242 + p_factory_ensure_slam_frameserver(struct p_factory *fact) 243 + { 244 + // Factory frameserver is already in use 245 + if (fact->xfs != NULL) { 246 + return false; 247 + } 248 + 249 + // SLAM tracker with EuRoC frameserver 250 + 251 + #ifdef XRT_BUILD_DRIVER_EUROC 252 + if (debug_get_option_euroc_path() != NULL) { 253 + struct xrt_slam_sinks empty_sinks = {0}; 254 + struct xrt_slam_sinks *sinks = &empty_sinks; 255 + 256 + xrt_prober_open_video_device(&fact->p->base, NULL, &fact->xfctx, &fact->xfs); 257 + assert(fact->xfs->source_id == 0xECD0FEED && "xfs is not Euroc, unsynced open_video_device?"); 258 + 259 + #ifdef XRT_HAVE_SLAM 260 + int ret = t_slam_create(&fact->xfctx, &fact->xts, &sinks); 261 + if (ret != 0) { 262 + U_LOG_W("Unable to initialize SLAM tracking, the Euroc driver will not be tracked"); 263 + } 264 + #else 265 + U_LOG_W("SLAM tracking support is disabled, the Euroc driver will not be tracked"); 266 + #endif 267 + 268 + xrt_fs_slam_stream_start(fact->xfs, sinks); 269 + 270 + return true; 271 + } 272 + #endif 273 + 274 + // No SLAM sources were started 275 + return false; 276 + } 277 + 237 278 #endif 238 279 239 280 ··· 344 385 345 386 struct xrt_tracked_slam *xts = NULL; 346 387 347 - #ifdef XRT_BUILD_DRIVER_EUROC 348 - if (debug_get_option_euroc_path() != NULL) { 349 - // The euroc slam tracker was already created on p_tracking_init because the 350 - // euroc player is not a device so it needs to be started from somewhere 351 - goto end; 352 - } 353 - #endif 354 - 355 - end: 388 + p_factory_ensure_slam_frameserver(fact); 356 389 357 390 if (!fact->started_xts) { 358 391 xts = fact->xts; ··· 371 404 return -1; 372 405 #endif 373 406 } 407 + 374 408 375 409 /* 376 410 * ··· 401 435 402 436 // Finally set us as the tracking factory. 403 437 p->base.tracking = &fact->base; 404 - 405 - #ifdef XRT_BUILD_DRIVER_EUROC 406 - if (debug_get_option_euroc_path() != NULL) { 407 - struct xrt_slam_sinks empty_sinks = {0}; 408 - struct xrt_slam_sinks *sinks = &empty_sinks; 409 - 410 - // fact->xfs *will* be an euroc frame server after open, because of prober open_video_device 411 - xrt_prober_open_video_device(&fact->p->base, NULL, &fact->xfctx, &fact->xfs); 412 - 413 - #ifdef XRT_HAVE_SLAM 414 - int ret = t_slam_create(&fact->xfctx, &fact->xts, &sinks); 415 - if (ret != 0) { 416 - U_LOG_W("Unable to initialize SLAM tracking, the Euroc driver will not be tracked"); 417 - } 418 - #else 419 - U_LOG_W("SLAM tracking support is disabled, the Euroc driver will not be tracked"); 420 - #endif 421 - 422 - xrt_fs_slam_stream_start(fact->xfs, sinks); 423 - } 424 - #endif 425 438 426 439 return 0; 427 440 }