···2424#include <stdint.h>
25252626//! Compatibility with these values should be checked against @ref vit_api_get_version.
2727-#define VIT_HEADER_VERSION_MAJOR 1 //!< API Breakages
2727+#define VIT_HEADER_VERSION_MAJOR 2 //!< API Breakages
2828#define VIT_HEADER_VERSION_MINOR 0 //!< Backwards compatible API changes
2929#define VIT_HEADER_VERSION_PATCH 1 //!< Backw. comp. .h-implemented changes
3030···5757 VIT_ERROR_ALLOCATION_FAILURE = -3,
58585959 /*!
6060- * The operation requires a capability that is not supported.
6060+ * The operation requires an extension that is not supported.
6161 */
6262 VIT_ERROR_NOT_SUPPORTED = -4,
63636464 /*!
6565- * The operation requires a capability that is not enabled.
6565+ * The operation requires an extension that is not enabled.
6666 */
6767 VIT_ERROR_NOT_ENABLED = -5,
6868} vit_result_t;
···9696} vit_camera_distortion_t;
97979898/*!
9999- * Capabilities of the tracker.
9999+ * Optional functionality a tracker can provide.
100100 */
101101-typedef enum vit_tracker_capability {
102102- //! Does the tracker support per pose (frame) timing data.
103103- VIT_TRACKER_CAPABILITY_CAMERA_CALIBRATION = 1 << 0,
104104- //! Does the tracker support per pose (frame) and per camera features.
105105- VIT_TRACKER_CAPABILITY_IMU_CALIBRATION = 1 << 1,
106106-} vit_tracker_capability_t;
101101+typedef enum vit_tracker_extension {
102102+ //! Allows to specify camera calibration data programatically
103103+ VIT_TRACKER_EXTENSION_ADD_CAMERA_CALIBRATION,
104104+ //! Allows to specify IMU calibration data programatically
105105+ VIT_TRACKER_EXTENSION_ADD_IMU_CALIBRATION,
106106+ //! Optionally provide timing information with the returned poses
107107+ VIT_TRACKER_EXTENSION_POSE_TIMING,
108108+ //! Optionally provide feature count information with the returned poses
109109+ VIT_TRACKER_EXTENSION_POSE_FEATURES,
110110+ //! Number of extensions
111111+ VIT_TRACKER_EXTENSION_COUNT,
112112+} vit_tracker_extension_t;
107113108114/*!
109109- * Capabilities of the poses that this tracker produces.
115115+ * Set of extensions. Field order matches enumerators in @ref vit_tracker_extension.
110116 */
111111-typedef enum vit_tracker_pose_capability {
112112- //! Does the tracker support per pose (frame) timing data.
113113- VIT_TRACKER_POSE_CAPABILITY_TIMING = 1 << 0,
114114- //! Does the tracker support per pose (frame) and per camera features.
115115- VIT_TRACKER_POSE_CAPABILITY_FEATURES = 1 << 1,
116116-} vit_tracker_pose_capability_t;
117117+typedef struct vit_tracker_extension_set {
118118+ bool has_add_camera_calibration;
119119+ bool has_add_imu_calibration;
120120+ bool has_pose_timing;
121121+ bool has_pose_features;
122122+} vit_tracker_extension_set_t;
117123118124/*!
119119- * @brief Visual-Inertial Tracking interface, opaque type.
125125+ * Visual-Inertial Tracking interface, opaque type.
120126 */
121127struct vit_tracker;
122128typedef struct vit_tracker vit_tracker_t;
123129124130/*!
125125- * @brief Pose interface, opaque type.
131131+ * Pose interface, opaque type.
126132 */
127133struct vit_pose;
128134typedef struct vit_pose vit_pose_t;
129135130136/*!
131131- * @brief Names of the timestamps returned by `vit_pose_get_timings`
137137+ * Names of the timestamps returned by `vit_pose_get_timings`
132138 */
133139typedef struct vit_tracker_timing_titles {
134140 uint32_t count; //! Number of titles
···136142} vit_tracker_timing_titles;
137143138144/*!
139139- * @brief Parameters for creating the system pipeline.
145145+ * Parameters for creating the system pipeline.
140146 */
141147typedef struct vit_config {
142148 //! Path to a implementation-specific config file. If null, use defaults.
···153159} vit_config_t;
154160155161/*!
156156- * @brief IMU sample type feed into VIT tracker
162162+ * IMU sample type feed into VIT tracker
157163 */
158164typedef struct vit_imu_sample {
159165 //! In nanoseconds
···175181} vit_mask_t;
176182177183/*!
178178- * @brief Image sample type feed into VIT tracker
184184+ * Image sample type feed into VIT tracker
179185 *
180186 * Can easily be converted into an OpenCV Matrix for processing.
181187 */
···302308typedef void (*PFN_vit_tracker_destroy)(vit_tracker_t *tracker);
303309typedef vit_result_t (*PFN_vit_tracker_has_image_format)(const vit_tracker_t *tracker, vit_image_format_t image_format,
304310 bool *out_supported);
305305-typedef vit_result_t (*PFN_vit_tracker_get_capabilities)(const vit_tracker_t *tracker,
306306- vit_tracker_capability_t *out_caps);
307307-typedef vit_result_t (*PFN_vit_tracker_get_pose_capabilities)(const vit_tracker_t *tracker,
308308- vit_tracker_pose_capability_t *out_caps);
309309-typedef vit_result_t (*PFN_vit_tracker_set_pose_capabilities)(vit_tracker_t *tracker,
310310- vit_tracker_pose_capability_t caps, bool value);
311311+typedef vit_result_t (*PFN_vit_tracker_get_supported_extensions)(const vit_tracker_t *tracker,
312312+ vit_tracker_extension_set_t *out_exts);
313313+typedef vit_result_t (*PFN_vit_tracker_get_enabled_extensions)(const vit_tracker_t *tracker,
314314+ vit_tracker_extension_set_t *out_exts);
315315+typedef vit_result_t (*PFN_vit_tracker_enable_extension)(vit_tracker_t *tracker, vit_tracker_extension_t ext,
316316+ bool enable);
311317typedef vit_result_t (*PFN_vit_tracker_start)(vit_tracker_t *tracker);
312318typedef vit_result_t (*PFN_vit_tracker_stop)(vit_tracker_t *tracker);
313319typedef vit_result_t (*PFN_vit_tracker_reset)(vit_tracker_t *tracker);
···336342#ifdef VIT_INTERFACE_IMPLEMENTATION
337343338344/*!
339339- * @brief Returns the API version implemented by the VIT system.
345345+ * Returns the API version implemented by the VIT system.
340346 */
341347vit_result_t vit_api_get_version(uint32_t *out_major, uint32_t *out_minor, uint32_t *out_patch);
342348343349/*!
344344- * @brief Creates a new VIT tracker. The caller is responsible of destroying it when done.
350350+ * Creates a new VIT tracker. The caller is responsible of destroying it when done.
345351 */
346352vit_result_t vit_tracker_create(const vit_config_t *config, vit_tracker_t **out_tracker);
347353348354/*!
349349- * @brief Destroys the VIT tracker and free all resources allocated.
355355+ * Destroys the VIT tracker and free all resources allocated.
350356 */
351357void vit_tracker_destroy(vit_tracker_t *tracker);
352358353359/*!
354354- * @brief Verifies if the tracker supports a given `vit_image_format_t`.
360360+ * Verifies if the tracker supports a given `vit_image_format_t`.
355361 */
356362vit_result_t vit_tracker_has_image_format(const vit_tracker_t *tracker, vit_image_format_t image_format,
357363 bool *out_supported);
358364359365/*!
360360- * @brief Returns a bitfield of capabilities supported by the tracker.
366366+ * Returns a set with the extensions supported by this tracker.
361367 *
362362- * @see vit_tracker_capability_t
368368+ * @see vit_tracker_extension_t
363369 */
364370365365-vit_result_t vit_tracker_get_capabilities(const vit_tracker_t *tracker, vit_tracker_capability_t *out_caps);
371371+vit_result_t vit_tracker_get_supported_extensions(const vit_tracker_t *tracker, vit_tracker_extension_set_t *out_exts);
366372367373/*!
368368- * @brief Returns a bitfield of pose capabilities supported by the tracker.
374374+ * Returns a set with the extensions enabled in this tracker.
369375 *
370370- * @see vit_tracker_pose_capability_t
376376+ * @see vit_tracker_extension_t
371377 */
372372-vit_result_t vit_tracker_get_pose_capabilities(const vit_tracker_t *tracker, vit_tracker_pose_capability_t *out_caps);
378378+379379+vit_result_t vit_tracker_get_enabled_extensions(const vit_tracker_t *tracker, vit_tracker_extension_set_t *out_exts);
373380374381/*!
375375- * @brief Enables or disables multiple tracker pose capabilities.
382382+ * Enables or disables a tracker extension.
376383 *
377377- * @p caps can be a bitfield of `vit_tracker_pose_capability_t`.
378378- *
379379- * @see vit_tracker_pose_capability_t
384384+ * @see vit_tracker_extension_t
380385 */
381381-vit_result_t vit_tracker_set_pose_capabilities(vit_tracker_t *tracker, vit_tracker_pose_capability_t caps, bool value);
386386+vit_result_t vit_tracker_enable_extension(vit_tracker_t *tracker, vit_tracker_extension_t ext, bool value);
382387383388/*!
384384- * @brief Starts the VIT tracker. Image and IMU samples can be pushed and pose can be retrieved.
389389+ * Starts the VIT tracker. Image and IMU samples can be pushed and pose can be retrieved.
385390 *
386391 * This function must be non blocking. The VIT system implementing it is expected to start its own event loop.
387392 */
388393vit_result_t vit_tracker_start(vit_tracker_t *tracker);
389394390395/*!
391391- * @brief Stops the VIT tracker. The tracker wont accept image and IMU samples, and will not return poses.
396396+ * Stops the VIT tracker. The tracker wont accept image and IMU samples, and will not return poses.
392397 */
393398vit_result_t vit_tracker_stop(vit_tracker_t *tracker);
394399395400/*!
396396- * @brief Resets the VIT tracker. The tracker internal state will be set to its original state.
401401+ * Resets the VIT tracker. The tracker internal state will be set to its original state.
397402 */
398403vit_result_t vit_tracker_reset(vit_tracker_t *tracker);
399404400405/*!
401401- * @brief Verifies if the tracker is running.
406406+ * Verifies if the tracker is running.
402407 */
403408vit_result_t vit_tracker_is_running(const vit_tracker_t *tracker, bool *out_bool);
404409405410/*!
406406- * @brief Push an IMU sample into the tracker.
411411+ * Push an IMU sample into the tracker.
407412 *
408413 * There must be a single producer thread pushing samples.
409414 * Samples must have monotonically increasing timestamps.
···413418vit_result_t vit_tracker_push_imu_sample(vit_tracker_t *tracker, const vit_imu_sample_t *sample);
414419415420/*!
416416- * @brief Push an image sample into the tracker.
421421+ * Push an image sample into the tracker.
417422 *
418423 * Same conditions as @ref push_imu_sample apply.
419424 * When using N>1 cameras, the N frames must be pushed following @ref cam_index order.
···422427vit_result_t vit_tracker_push_img_sample(vit_tracker_t *tracker, const vit_img_sample_t *sample);
423428424429/*!
425425- * @brief Adds an inertial measurement unit calibration to the tracker. The tracker must not be started.
430430+ * Adds an inertial measurement unit calibration to the tracker. The tracker must not be started.
426431 *
427427- * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the capability.
432432+ * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the extension.
428433 *
429429- * @see vit_tracker_get_capabilities
430430- * @see vit_tracker_capability_t
434434+ * @see vit_tracker_get_supported_extensions
435435+ * @see vit_tracker_extension_t
431436 */
432437vit_result_t vit_tracker_add_imu_calibration(vit_tracker_t *tracker, const vit_imu_calibration_t *calibration);
433438434439/*!
435435- * @brief Adds a camera calibration to the tracker. The tracker must not be started.
440440+ * Adds a camera calibration to the tracker. The tracker must not be started.
436441 *
437437- * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the capability.
442442+ * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the extension.
438443 *
439439- * @see vit_tracker_get_capabilities
440440- * @see vit_tracker_capability_t
444444+ * @see vit_tracker_get_supported_extensions
445445+ * @see vit_tracker_extension_t
441446 */
442447vit_result_t vit_tracker_add_camera_calibration(vit_tracker_t *tracker, const vit_camera_calibration_t *calibration);
443448444449/*!
445445- * @brief Get the pose from the front of the tracking queue from the VIT tracker
450450+ * Get the pose from the front of the tracking queue from the VIT tracker
446451 *
447452 * This function must be non-blocking and consumed by a single consummer.
448453 *
···453458vit_result_t vit_tracker_pop_pose(vit_tracker_t *tracker, vit_pose_t **out_pose);
454459455460/*!
456456- * @brief Get the titles of the timestamps measured by the pose timings.
461461+ * Get the titles of the timestamps measured by the pose timings.
457462 *
458458- * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the pose timing capability.
463463+ * Returns `VIT_ERROR_NOT_SUPPORTED` if the tracker doesn't offer the pose timing extension.
459464 */
460465vit_result_t vit_tracker_get_timing_titles(const vit_tracker_t *tracker, vit_tracker_timing_titles *out_titles);
461466462467/*!
463463- * @brief Destroys a pose. All of the data, timing and features associated to it will be invalidated.
468468+ * Destroys a pose. All of the data, timing and features associated to it will be invalidated.
464469 */
465470void vit_pose_destroy(vit_pose_t *pose);
466471467472/*!
468468- * @brief Gets the data form a given `vit_pose_t`.
473473+ * Gets the data form a given `vit_pose_t`.
469474 *
470475 * The data becomes invalid when the associated pose gets destroyed.
471476 */
472477vit_result_t vit_pose_get_data(const vit_pose_t *pose, vit_pose_data_t *out_data);
473478474479/*!
475475- * @brief Gets the timing form a given `vit_pose_t`.
480480+ * Gets the timing form a given `vit_pose_t`.
476481 *
477482 * The timing data becomes invalid when the associated pose gets destroyed.
478483 */
479484vit_result_t vit_pose_get_timing(const vit_pose_t *pose, vit_pose_timing_t *out_timing);
480485481486/*!
482482- * @brief Gets the features form a given `vit_pose_t`.
487487+ * Gets the features form a given `vit_pose_t`.
483488 *
484489 * The features data becomes invalid when the associated pose gets destroyed.
485490 */
+12-21
src/xrt/auxiliary/tracking/t_tracker_slam.cpp
···257257 struct xrt_tracked_slam base = {};
258258 struct xrt_frame_node node = {}; //!< Will be called on destruction
259259 struct t_vit_bundle vit; //!< VIT system function pointers
260260- enum vit_tracker_pose_capability caps; //!< VIT tracker bitfield capabilities
260260+ struct vit_tracker_extension_set exts; //!< VIT tracker supported extensions
261261 struct vit_tracker *tracker; //!< Pointer to the tracker created by the loaded VIT system;
262262263263 struct xrt_slam_sinks sinks = {}; //!< Pointers to the sinks below
···416416 u_var_button &btn = t->timing.enable_btn;
417417 bool e = !t->timing.enabled;
418418 snprintf(btn.label, sizeof(btn.label), "%s", msg[e]);
419419- vit_result_t vres =
420420- t->vit.tracker_set_pose_capabilities(t->tracker, VIT_TRACKER_POSE_CAPABILITY_TIMING, e);
419419+ vit_result_t vres = t->vit.tracker_enable_extension(t->tracker, VIT_TRACKER_EXTENSION_POSE_TIMING, e);
421420 if (vres != VIT_SUCCESS) {
422422- U_LOG_IFL_E(t->log_level, "Failed to set tracker timing capability");
421421+ U_LOG_IFL_E(t->log_level, "Failed to set tracker timing extension");
423422 return;
424423 }
425424 t->timing.enabled = e;
426425 };
427426 t.timing.enable_btn.cb = cb;
428428- t.timing.enable_btn.disabled = (t.caps & VIT_TRACKER_POSE_CAPABILITY_TIMING) == 0;
427427+ t.timing.enable_btn.disabled = !t.exts.has_pose_timing;
429428 t.timing.enable_btn.ptr = &t;
430429 u_var_add_button(&t, &t.timing.enable_btn, msg[t.timing.enabled]);
431430···433432 t.timing.columns = {"sampled", "received_by_monado"};
434433435434 // Only fill the timing columns if the tracker supports pose timing
436436- if ((t.caps & VIT_TRACKER_POSE_CAPABILITY_TIMING) != 0) {
435435+ if (t.exts.has_pose_timing) {
437436 vit_tracker_timing_titles titles = {};
438437 vit_result_t vres = t.vit.tracker_get_timing_titles(t.tracker, &titles);
439438 if (vres != VIT_SUCCESS) {
···537536 u_var_button &btn = t->features.enable_btn;
538537 bool e = !t->features.enabled;
539538 snprintf(btn.label, sizeof(btn.label), "%s", msg[e]);
540540- vit_result_t vres =
541541- t->vit.tracker_set_pose_capabilities(t->tracker, VIT_TRACKER_POSE_CAPABILITY_FEATURES, e);
539539+ vit_result_t vres = t->vit.tracker_enable_extension(t->tracker, VIT_TRACKER_EXTENSION_POSE_FEATURES, e);
542540 if (vres != VIT_SUCCESS) {
543543- U_LOG_IFL_E(t->log_level, "Failed to set tracker features capability");
541541+ U_LOG_IFL_E(t->log_level, "Failed to set tracker features extension");
544542 return;
545543 }
546544 t->features.enabled = e;
547545 };
548546 t.features.enable_btn.cb = cb;
549549- t.features.enable_btn.disabled = (t.caps & VIT_TRACKER_POSE_CAPABILITY_FEATURES) == 0;
547547+ t.features.enable_btn.disabled = !t.exts.has_pose_features;
550548 t.features.enable_btn.ptr = &t;
551549 u_var_add_button(&t, &t.features.enable_btn, msg[t.features.enabled]);
552550···11931191static void
11941192send_calibration(const TrackerSlam &t, const t_slam_calibration &c)
11951193{
11961196- vit_tracker_capability_t caps;
11971197- vit_result_t vres = t.vit.tracker_get_capabilities(t.tracker, &caps);
11981198- if (vres != VIT_SUCCESS) {
11991199- SLAM_ERROR("Failed to get VIT tracker capabilities");
12001200- return;
12011201- }
12021202-12031194 // Try to send camera calibration data to the SLAM system
12041204- if ((caps & VIT_TRACKER_CAPABILITY_CAMERA_CALIBRATION) != 0) {
11951195+ if (t.exts.has_add_camera_calibration) {
12051196 for (int i = 0; i < c.cam_count; i++) {
12061197 SLAM_INFO("Sending Camera %d calibration from Monado", i);
12071198 add_camera_calibration(t, &c.cams[i], i);
···12111202 }
1212120312131204 // Try to send IMU calibration data to the SLAM system
12141214- if ((caps & VIT_TRACKER_CAPABILITY_IMU_CALIBRATION) != 0) {
12051205+ if (t.exts.has_add_imu_calibration) {
12151206 SLAM_INFO("Sending IMU calibration from Monado");
12161207 add_imu_calibration(t, &c.imu);
12171208 } else {
···15611552 return -1;
15621553 }
1563155415641564- vres = t.vit.tracker_get_pose_capabilities(t.tracker, &t.caps);
15551555+ vres = t.vit.tracker_get_supported_extensions(t.tracker, &t.exts);
15651556 if (vres != VIT_SUCCESS) {
15661566- SLAM_ERROR("Failed to get VIT tracker pose capabilities (%d)", vres);
15571557+ SLAM_ERROR("Failed to get VIT tracker supported extensions (%d)", vres);
15671558 return -1;
15681559 }
15691560