The open source OpenXR runtime

external/vit: Update to 2.0.1

authored by

Mateo de Mayo and committed by
Rylie Pavlik
1742fd85 5771ddd4

+90 -94
+70 -65
src/external/vit_includes/vit/vit_interface.h
··· 24 24 #include <stdint.h> 25 25 26 26 //! Compatibility with these values should be checked against @ref vit_api_get_version. 27 - #define VIT_HEADER_VERSION_MAJOR 1 //!< API Breakages 27 + #define VIT_HEADER_VERSION_MAJOR 2 //!< API Breakages 28 28 #define VIT_HEADER_VERSION_MINOR 0 //!< Backwards compatible API changes 29 29 #define VIT_HEADER_VERSION_PATCH 1 //!< Backw. comp. .h-implemented changes 30 30 ··· 57 57 VIT_ERROR_ALLOCATION_FAILURE = -3, 58 58 59 59 /*! 60 - * The operation requires a capability that is not supported. 60 + * The operation requires an extension that is not supported. 61 61 */ 62 62 VIT_ERROR_NOT_SUPPORTED = -4, 63 63 64 64 /*! 65 - * The operation requires a capability that is not enabled. 65 + * The operation requires an extension that is not enabled. 66 66 */ 67 67 VIT_ERROR_NOT_ENABLED = -5, 68 68 } vit_result_t; ··· 96 96 } vit_camera_distortion_t; 97 97 98 98 /*! 99 - * Capabilities of the tracker. 99 + * Optional functionality a tracker can provide. 100 100 */ 101 - typedef enum vit_tracker_capability { 102 - //! Does the tracker support per pose (frame) timing data. 103 - VIT_TRACKER_CAPABILITY_CAMERA_CALIBRATION = 1 << 0, 104 - //! Does the tracker support per pose (frame) and per camera features. 105 - VIT_TRACKER_CAPABILITY_IMU_CALIBRATION = 1 << 1, 106 - } vit_tracker_capability_t; 101 + typedef enum vit_tracker_extension { 102 + //! Allows to specify camera calibration data programatically 103 + VIT_TRACKER_EXTENSION_ADD_CAMERA_CALIBRATION, 104 + //! Allows to specify IMU calibration data programatically 105 + VIT_TRACKER_EXTENSION_ADD_IMU_CALIBRATION, 106 + //! Optionally provide timing information with the returned poses 107 + VIT_TRACKER_EXTENSION_POSE_TIMING, 108 + //! Optionally provide feature count information with the returned poses 109 + VIT_TRACKER_EXTENSION_POSE_FEATURES, 110 + //! Number of extensions 111 + VIT_TRACKER_EXTENSION_COUNT, 112 + } vit_tracker_extension_t; 107 113 108 114 /*! 109 - * Capabilities of the poses that this tracker produces. 115 + * Set of extensions. Field order matches enumerators in @ref vit_tracker_extension. 110 116 */ 111 - typedef enum vit_tracker_pose_capability { 112 - //! Does the tracker support per pose (frame) timing data. 113 - VIT_TRACKER_POSE_CAPABILITY_TIMING = 1 << 0, 114 - //! Does the tracker support per pose (frame) and per camera features. 115 - VIT_TRACKER_POSE_CAPABILITY_FEATURES = 1 << 1, 116 - } vit_tracker_pose_capability_t; 117 + typedef struct vit_tracker_extension_set { 118 + bool has_add_camera_calibration; 119 + bool has_add_imu_calibration; 120 + bool has_pose_timing; 121 + bool has_pose_features; 122 + } vit_tracker_extension_set_t; 117 123 118 124 /*! 119 - * @brief Visual-Inertial Tracking interface, opaque type. 125 + * Visual-Inertial Tracking interface, opaque type. 120 126 */ 121 127 struct vit_tracker; 122 128 typedef struct vit_tracker vit_tracker_t; 123 129 124 130 /*! 125 - * @brief Pose interface, opaque type. 131 + * Pose interface, opaque type. 126 132 */ 127 133 struct vit_pose; 128 134 typedef struct vit_pose vit_pose_t; 129 135 130 136 /*! 131 - * @brief Names of the timestamps returned by `vit_pose_get_timings` 137 + * Names of the timestamps returned by `vit_pose_get_timings` 132 138 */ 133 139 typedef struct vit_tracker_timing_titles { 134 140 uint32_t count; //! Number of titles ··· 136 142 } vit_tracker_timing_titles; 137 143 138 144 /*! 139 - * @brief Parameters for creating the system pipeline. 145 + * Parameters for creating the system pipeline. 140 146 */ 141 147 typedef struct vit_config { 142 148 //! Path to a implementation-specific config file. If null, use defaults. ··· 153 159 } vit_config_t; 154 160 155 161 /*! 156 - * @brief IMU sample type feed into VIT tracker 162 + * IMU sample type feed into VIT tracker 157 163 */ 158 164 typedef struct vit_imu_sample { 159 165 //! In nanoseconds ··· 175 181 } vit_mask_t; 176 182 177 183 /*! 178 - * @brief Image sample type feed into VIT tracker 184 + * Image sample type feed into VIT tracker 179 185 * 180 186 * Can easily be converted into an OpenCV Matrix for processing. 181 187 */ ··· 302 308 typedef void (*PFN_vit_tracker_destroy)(vit_tracker_t *tracker); 303 309 typedef vit_result_t (*PFN_vit_tracker_has_image_format)(const vit_tracker_t *tracker, vit_image_format_t image_format, 304 310 bool *out_supported); 305 - typedef vit_result_t (*PFN_vit_tracker_get_capabilities)(const vit_tracker_t *tracker, 306 - vit_tracker_capability_t *out_caps); 307 - typedef vit_result_t (*PFN_vit_tracker_get_pose_capabilities)(const vit_tracker_t *tracker, 308 - vit_tracker_pose_capability_t *out_caps); 309 - typedef vit_result_t (*PFN_vit_tracker_set_pose_capabilities)(vit_tracker_t *tracker, 310 - vit_tracker_pose_capability_t caps, bool value); 311 + typedef vit_result_t (*PFN_vit_tracker_get_supported_extensions)(const vit_tracker_t *tracker, 312 + vit_tracker_extension_set_t *out_exts); 313 + typedef vit_result_t (*PFN_vit_tracker_get_enabled_extensions)(const vit_tracker_t *tracker, 314 + vit_tracker_extension_set_t *out_exts); 315 + typedef vit_result_t (*PFN_vit_tracker_enable_extension)(vit_tracker_t *tracker, vit_tracker_extension_t ext, 316 + bool enable); 311 317 typedef vit_result_t (*PFN_vit_tracker_start)(vit_tracker_t *tracker); 312 318 typedef vit_result_t (*PFN_vit_tracker_stop)(vit_tracker_t *tracker); 313 319 typedef vit_result_t (*PFN_vit_tracker_reset)(vit_tracker_t *tracker); ··· 336 342 #ifdef VIT_INTERFACE_IMPLEMENTATION 337 343 338 344 /*! 339 - * @brief Returns the API version implemented by the VIT system. 345 + * Returns the API version implemented by the VIT system. 340 346 */ 341 347 vit_result_t vit_api_get_version(uint32_t *out_major, uint32_t *out_minor, uint32_t *out_patch); 342 348 343 349 /*! 344 - * @brief Creates a new VIT tracker. The caller is responsible of destroying it when done. 350 + * Creates a new VIT tracker. The caller is responsible of destroying it when done. 345 351 */ 346 352 vit_result_t vit_tracker_create(const vit_config_t *config, vit_tracker_t **out_tracker); 347 353 348 354 /*! 349 - * @brief Destroys the VIT tracker and free all resources allocated. 355 + * Destroys the VIT tracker and free all resources allocated. 350 356 */ 351 357 void vit_tracker_destroy(vit_tracker_t *tracker); 352 358 353 359 /*! 354 - * @brief Verifies if the tracker supports a given `vit_image_format_t`. 360 + * Verifies if the tracker supports a given `vit_image_format_t`. 355 361 */ 356 362 vit_result_t vit_tracker_has_image_format(const vit_tracker_t *tracker, vit_image_format_t image_format, 357 363 bool *out_supported); 358 364 359 365 /*! 360 - * @brief Returns a bitfield of capabilities supported by the tracker. 366 + * Returns a set with the extensions supported by this tracker. 361 367 * 362 - * @see vit_tracker_capability_t 368 + * @see vit_tracker_extension_t 363 369 */ 364 370 365 - vit_result_t vit_tracker_get_capabilities(const vit_tracker_t *tracker, vit_tracker_capability_t *out_caps); 371 + vit_result_t vit_tracker_get_supported_extensions(const vit_tracker_t *tracker, vit_tracker_extension_set_t *out_exts); 366 372 367 373 /*! 368 - * @brief Returns a bitfield of pose capabilities supported by the tracker. 374 + * Returns a set with the extensions enabled in this tracker. 369 375 * 370 - * @see vit_tracker_pose_capability_t 376 + * @see vit_tracker_extension_t 371 377 */ 372 - vit_result_t vit_tracker_get_pose_capabilities(const vit_tracker_t *tracker, vit_tracker_pose_capability_t *out_caps); 378 + 379 + vit_result_t vit_tracker_get_enabled_extensions(const vit_tracker_t *tracker, vit_tracker_extension_set_t *out_exts); 373 380 374 381 /*! 375 - * @brief Enables or disables multiple tracker pose capabilities. 382 + * Enables or disables a tracker extension. 376 383 * 377 - * @p caps can be a bitfield of `vit_tracker_pose_capability_t`. 378 - * 379 - * @see vit_tracker_pose_capability_t 384 + * @see vit_tracker_extension_t 380 385 */ 381 - vit_result_t vit_tracker_set_pose_capabilities(vit_tracker_t *tracker, vit_tracker_pose_capability_t caps, bool value); 386 + vit_result_t vit_tracker_enable_extension(vit_tracker_t *tracker, vit_tracker_extension_t ext, bool value); 382 387 383 388 /*! 384 - * @brief Starts the VIT tracker. Image and IMU samples can be pushed and pose can be retrieved. 389 + * Starts the VIT tracker. Image and IMU samples can be pushed and pose can be retrieved. 385 390 * 386 391 * This function must be non blocking. The VIT system implementing it is expected to start its own event loop. 387 392 */ 388 393 vit_result_t vit_tracker_start(vit_tracker_t *tracker); 389 394 390 395 /*! 391 - * @brief Stops the VIT tracker. The tracker wont accept image and IMU samples, and will not return poses. 396 + * Stops the VIT tracker. The tracker wont accept image and IMU samples, and will not return poses. 392 397 */ 393 398 vit_result_t vit_tracker_stop(vit_tracker_t *tracker); 394 399 395 400 /*! 396 - * @brief Resets the VIT tracker. The tracker internal state will be set to its original state. 401 + * Resets the VIT tracker. The tracker internal state will be set to its original state. 397 402 */ 398 403 vit_result_t vit_tracker_reset(vit_tracker_t *tracker); 399 404 400 405 /*! 401 - * @brief Verifies if the tracker is running. 406 + * Verifies if the tracker is running. 402 407 */ 403 408 vit_result_t vit_tracker_is_running(const vit_tracker_t *tracker, bool *out_bool); 404 409 405 410 /*! 406 - * @brief Push an IMU sample into the tracker. 411 + * Push an IMU sample into the tracker. 407 412 * 408 413 * There must be a single producer thread pushing samples. 409 414 * Samples must have monotonically increasing timestamps. ··· 413 418 vit_result_t vit_tracker_push_imu_sample(vit_tracker_t *tracker, const vit_imu_sample_t *sample); 414 419 415 420 /*! 416 - * @brief Push an image sample into the tracker. 421 + * Push an image sample into the tracker. 417 422 * 418 423 * Same conditions as @ref push_imu_sample apply. 419 424 * When using N>1 cameras, the N frames must be pushed following @ref cam_index order. ··· 422 427 vit_result_t vit_tracker_push_img_sample(vit_tracker_t *tracker, const vit_img_sample_t *sample); 423 428 424 429 /*! 425 - * @brief Adds an inertial measurement unit calibration to the tracker. The tracker must not be started. 430 + * Adds an inertial measurement unit calibration to the tracker. The tracker must not be started. 426 431 * 427 - * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the capability. 432 + * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the extension. 428 433 * 429 - * @see vit_tracker_get_capabilities 430 - * @see vit_tracker_capability_t 434 + * @see vit_tracker_get_supported_extensions 435 + * @see vit_tracker_extension_t 431 436 */ 432 437 vit_result_t vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration); 433 438 434 439 /*! 435 - * @brief Adds a camera calibration to the tracker. The tracker must not be started. 440 + * Adds a camera calibration to the tracker. The tracker must not be started. 436 441 * 437 - * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the capability. 442 + * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the extension. 438 443 * 439 - * @see vit_tracker_get_capabilities 440 - * @see vit_tracker_capability_t 444 + * @see vit_tracker_get_supported_extensions 445 + * @see vit_tracker_extension_t 441 446 */ 442 447 vit_result_t vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration); 443 448 444 449 /*! 445 - * @brief Get the pose from the front of the tracking queue from the VIT tracker 450 + * Get the pose from the front of the tracking queue from the VIT tracker 446 451 * 447 452 * This function must be non-blocking and consumed by a single consummer. 448 453 * ··· 453 458 vit_result_t vit_tracker_pop_pose(vit_tracker_t *tracker, vit_pose_t **out_pose); 454 459 455 460 /*! 456 - * @brief Get the titles of the timestamps measured by the pose timings. 461 + * Get the titles of the timestamps measured by the pose timings. 457 462 * 458 - * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the pose timing capability. 463 + * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the pose timing extension. 459 464 */ 460 465 vit_result_t vit_tracker_get_timing_titles(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles); 461 466 462 467 /*! 463 - * @brief Destroys a pose. All of the data, timing and features associated to it will be invalidated. 468 + * Destroys a pose. All of the data, timing and features associated to it will be invalidated. 464 469 */ 465 470 void vit_pose_destroy(vit_pose_t *pose); 466 471 467 472 /*! 468 - * @brief Gets the data form a given `vit_pose_t`. 473 + * Gets the data form a given `vit_pose_t`. 469 474 * 470 475 * The data becomes invalid when the associated pose gets destroyed. 471 476 */ 472 477 vit_result_t vit_pose_get_data(const vit_pose_t *pose, vit_pose_data_t *out_data); 473 478 474 479 /*! 475 - * @brief Gets the timing form a given `vit_pose_t`. 480 + * Gets the timing form a given `vit_pose_t`. 476 481 * 477 482 * The timing data becomes invalid when the associated pose gets destroyed. 478 483 */ 479 484 vit_result_t vit_pose_get_timing(const vit_pose_t *pose, vit_pose_timing_t *out_timing); 480 485 481 486 /*! 482 - * @brief Gets the features form a given `vit_pose_t`. 487 + * Gets the features form a given `vit_pose_t`. 483 488 * 484 489 * The features data becomes invalid when the associated pose gets destroyed. 485 490 */
+12 -21
src/xrt/auxiliary/tracking/t_tracker_slam.cpp
··· 257 257 struct xrt_tracked_slam base = {}; 258 258 struct xrt_frame_node node = {}; //!< Will be called on destruction 259 259 struct t_vit_bundle vit; //!< VIT system function pointers 260 - enum vit_tracker_pose_capability caps; //!< VIT tracker bitfield capabilities 260 + struct vit_tracker_extension_set exts; //!< VIT tracker supported extensions 261 261 struct vit_tracker *tracker; //!< Pointer to the tracker created by the loaded VIT system; 262 262 263 263 struct xrt_slam_sinks sinks = {}; //!< Pointers to the sinks below ··· 416 416 u_var_button &btn = t->timing.enable_btn; 417 417 bool e = !t->timing.enabled; 418 418 snprintf(btn.label, sizeof(btn.label), "%s", msg[e]); 419 - vit_result_t vres = 420 - t->vit.tracker_set_pose_capabilities(t->tracker, VIT_TRACKER_POSE_CAPABILITY_TIMING, e); 419 + vit_result_t vres = t->vit.tracker_enable_extension(t->tracker, VIT_TRACKER_EXTENSION_POSE_TIMING, e); 421 420 if (vres != VIT_SUCCESS) { 422 - U_LOG_IFL_E(t->log_level, "Failed to set tracker timing capability"); 421 + U_LOG_IFL_E(t->log_level, "Failed to set tracker timing extension"); 423 422 return; 424 423 } 425 424 t->timing.enabled = e; 426 425 }; 427 426 t.timing.enable_btn.cb = cb; 428 - t.timing.enable_btn.disabled = (t.caps & VIT_TRACKER_POSE_CAPABILITY_TIMING) == 0; 427 + t.timing.enable_btn.disabled = !t.exts.has_pose_timing; 429 428 t.timing.enable_btn.ptr = &t; 430 429 u_var_add_button(&t, &t.timing.enable_btn, msg[t.timing.enabled]); 431 430 ··· 433 432 t.timing.columns = {"sampled", "received_by_monado"}; 434 433 435 434 // Only fill the timing columns if the tracker supports pose timing 436 - if ((t.caps & VIT_TRACKER_POSE_CAPABILITY_TIMING) != 0) { 435 + if (t.exts.has_pose_timing) { 437 436 vit_tracker_timing_titles titles = {}; 438 437 vit_result_t vres = t.vit.tracker_get_timing_titles(t.tracker, &titles); 439 438 if (vres != VIT_SUCCESS) { ··· 537 536 u_var_button &btn = t->features.enable_btn; 538 537 bool e = !t->features.enabled; 539 538 snprintf(btn.label, sizeof(btn.label), "%s", msg[e]); 540 - vit_result_t vres = 541 - t->vit.tracker_set_pose_capabilities(t->tracker, VIT_TRACKER_POSE_CAPABILITY_FEATURES, e); 539 + vit_result_t vres = t->vit.tracker_enable_extension(t->tracker, VIT_TRACKER_EXTENSION_POSE_FEATURES, e); 542 540 if (vres != VIT_SUCCESS) { 543 - U_LOG_IFL_E(t->log_level, "Failed to set tracker features capability"); 541 + U_LOG_IFL_E(t->log_level, "Failed to set tracker features extension"); 544 542 return; 545 543 } 546 544 t->features.enabled = e; 547 545 }; 548 546 t.features.enable_btn.cb = cb; 549 - t.features.enable_btn.disabled = (t.caps & VIT_TRACKER_POSE_CAPABILITY_FEATURES) == 0; 547 + t.features.enable_btn.disabled = !t.exts.has_pose_features; 550 548 t.features.enable_btn.ptr = &t; 551 549 u_var_add_button(&t, &t.features.enable_btn, msg[t.features.enabled]); 552 550 ··· 1193 1191 static void 1194 1192 send_calibration(const TrackerSlam &t, const t_slam_calibration &c) 1195 1193 { 1196 - vit_tracker_capability_t caps; 1197 - vit_result_t vres = t.vit.tracker_get_capabilities(t.tracker, &caps); 1198 - if (vres != VIT_SUCCESS) { 1199 - SLAM_ERROR("Failed to get VIT tracker capabilities"); 1200 - return; 1201 - } 1202 - 1203 1194 // Try to send camera calibration data to the SLAM system 1204 - if ((caps & VIT_TRACKER_CAPABILITY_CAMERA_CALIBRATION) != 0) { 1195 + if (t.exts.has_add_camera_calibration) { 1205 1196 for (int i = 0; i < c.cam_count; i++) { 1206 1197 SLAM_INFO("Sending Camera %d calibration from Monado", i); 1207 1198 add_camera_calibration(t, &c.cams[i], i); ··· 1211 1202 } 1212 1203 1213 1204 // Try to send IMU calibration data to the SLAM system 1214 - if ((caps & VIT_TRACKER_CAPABILITY_IMU_CALIBRATION) != 0) { 1205 + if (t.exts.has_add_imu_calibration) { 1215 1206 SLAM_INFO("Sending IMU calibration from Monado"); 1216 1207 add_imu_calibration(t, &c.imu); 1217 1208 } else { ··· 1561 1552 return -1; 1562 1553 } 1563 1554 1564 - vres = t.vit.tracker_get_pose_capabilities(t.tracker, &t.caps); 1555 + vres = t.vit.tracker_get_supported_extensions(t.tracker, &t.exts); 1565 1556 if (vres != VIT_SUCCESS) { 1566 - SLAM_ERROR("Failed to get VIT tracker pose capabilities (%d)", vres); 1557 + SLAM_ERROR("Failed to get VIT tracker supported extensions (%d)", vres); 1567 1558 return -1; 1568 1559 } 1569 1560
+4 -4
src/xrt/auxiliary/tracking/t_vit_loader.c
··· 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file 5 - * @brief Visual-Intertial Tracking consumer helper. 5 + * @brief Visual-Inertial Tracking consumer helper. 6 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 7 * @author Simon Zeni <simon.zeni@collabora.com> 8 8 * @ingroup aux_tracking ··· 73 73 GET_PROC(tracker_create); 74 74 GET_PROC(tracker_destroy); 75 75 GET_PROC(tracker_has_image_format); 76 - GET_PROC(tracker_get_capabilities); 77 - GET_PROC(tracker_get_pose_capabilities); 78 - GET_PROC(tracker_set_pose_capabilities); 76 + GET_PROC(tracker_get_supported_extensions); 77 + GET_PROC(tracker_get_enabled_extensions); 78 + GET_PROC(tracker_enable_extension); 79 79 GET_PROC(tracker_start); 80 80 GET_PROC(tracker_stop); 81 81 GET_PROC(tracker_reset);
+4 -4
src/xrt/auxiliary/tracking/t_vit_loader.h
··· 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file 5 - * @brief Visual-Intertial Tracking consumer helper. 5 + * @brief Visual-Inertial Tracking consumer helper. 6 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 7 * @author Simon Zeni <simon.zeni@collabora.com> 8 8 * @ingroup aux_tracking ··· 36 36 PFN_vit_tracker_create tracker_create; 37 37 PFN_vit_tracker_destroy tracker_destroy; 38 38 PFN_vit_tracker_has_image_format tracker_has_image_format; 39 - PFN_vit_tracker_get_capabilities tracker_get_capabilities; 40 - PFN_vit_tracker_get_pose_capabilities tracker_get_pose_capabilities; 41 - PFN_vit_tracker_set_pose_capabilities tracker_set_pose_capabilities; 39 + PFN_vit_tracker_get_supported_extensions tracker_get_supported_extensions; 40 + PFN_vit_tracker_get_enabled_extensions tracker_get_enabled_extensions; 41 + PFN_vit_tracker_enable_extension tracker_enable_extension; 42 42 PFN_vit_tracker_start tracker_start; 43 43 PFN_vit_tracker_stop tracker_stop; 44 44 PFN_vit_tracker_reset tracker_reset;