12#include "xrt/xrt_config_build.h"
43#include <ceres/context.h>
48#include <shared_mutex>
54#define CT_TRACE(ct, ...) U_LOG_IFL_T(ct->log_level, __VA_ARGS__)
55#define CT_DEBUG(ct, ...) U_LOG_IFL_D(ct->log_level, __VA_ARGS__)
56#define CT_INFO(ct, ...) U_LOG_IFL_I(ct->log_level, __VA_ARGS__)
57#define CT_WARN(ct, ...) U_LOG_IFL_W(ct->log_level, __VA_ARGS__)
58#define CT_ERROR(ct, ...) U_LOG_IFL_E(ct->log_level, __VA_ARGS__)
60#define MIN_ROT_ERROR DEG_TO_RAD(30)
61#define MIN_POS_ERROR 0.10
70constellation_tracker_camera_slow_thread(
void *ptr);
73constellation_tracker_camera_fast_thread(
void *ptr);
76namespace xrt::tracking::constellation {
78using namespace xrt::tracking::constellation::optimizer;
80namespace os = xrt::auxiliary::os;
91 xrt_pose Tcv_cam_device XRT_POSE_IDENTITY;
92 float average_blob_brightness;
105 t_constellation_device_id_t
device_id{XRT_CONSTELLATION_INVALID_DEVICE_ID};
124 uint64_t sequence_id{};
125 int64_t timestamp_ns{};
126 t_blob blobs[XRT_CONSTELLATION_MAX_BLOBS_PER_FRAME]{};
127 uint32_t blob_count{};
132 std::array<t_constellation_device_id_t, XRT_CONSTELLATION_MAX_DEVICES> device_ids_by_distance{};
133 std::array<DeviceState, XRT_CONSTELLATION_MAX_DEVICES> device_states{};
134 uint32_t device_count{};
136 uint32_t mosaic_index;
137 uint32_t camera_index;
140 std::optional<DeviceState *>
141 getDeviceState(t_constellation_device_id_t device_id);
144 putDeviceState(t_constellation_device_id_t device_id);
153 t_constellation_device_id_t device_id,
157 toBlobObservation() const &
160 .source = this->source,
162 .sequence_id = this->sequence_id,
163 .timestamp_ns = this->timestamp_ns,
164 .blobs =
const_cast<t_blob *
>(this->blobs),
165 .num_blobs = this->blob_count,
173 toBlobObservation() && =
delete;
175 toBlobObservation() const && = delete;
182 bool draw_blobs{
true};
184 bool draw_blob_ids{
false};
186 bool draw_blob_device_ids{
true};
188 bool draw_blob_led_ids{
false};
191 bool draw_prior{
false};
193 bool draw_found{
false};
197 setupDebugTracking(
void *root);
205 std::weak_ptr<CameraMosaic> mosaic;
220 std::optional<CameraSample> sample{std::nullopt};
225 } slow_processing_thread_data;
234 std::optional<CameraSample> sample{std::nullopt};
239 } fast_processing_thread_data;
247 bool has_concrete_pose;
250 std::atomic<uint32_t> shallow_searches_failed{0};
261 std::weak_ptr<CameraMosaic> mosaic,
272 operator=(
const Camera &) =
delete;
274 operator=(
Camera &&) =
delete;
276 std::optional<xrt_pose>
284 tryDevicePose(
Device *device,
287 bool need_matching_ids,
288 const std::optional<xrt_space_relation> &Tcv_cam_device_prior,
289 const xrt_pose &Tcv_cam_device_candidate);
292 tryDeviceBlobRecovery(
Device *device,
295 const std::optional<xrt_space_relation> &Tcv_cam_device_prior);
303 handleProcessingComplete(
CameraSample &sample,
const std::span<Device *> devices);
328 std::vector<std::unique_ptr<Camera>> cameras;
341 std::optional<xrt_pose>
362 t_constellation_device_id_t id;
365 std::atomic<bool> enabled{
false};
370 std::unique_ptr<sensor_fusion::SensorFusion> sensor_fusion{};
378 xrt_vec3 prior_pos_error{MIN_POS_ERROR, MIN_POS_ERROR, MIN_POS_ERROR};
379 xrt_vec3 prior_rot_error{MIN_ROT_ERROR, MIN_ROT_ERROR, MIN_ROT_ERROR};
380 float gravity_error_rad{MIN_ROT_ERROR};
382 mutable os::Mutex data_lock;
385 std::optional<DeviceLastPose> last_known_pose;
390 std::optional<int64_t> last_seen_sequence_id{std::nullopt};
391 } per_camera[XRT_CONSTELLATION_MAX_TRACKING_MOSAICS * XRT_TRACKING_MAX_FRAME_SOURCES];
399 t_constellation_device_id_t
id);
407 operator=(
const Device &) =
delete;
409 operator=(
Device &&) =
delete;
428 bool deterministic{
false};
430 std::vector<std::shared_ptr<CameraMosaic>> mosaics;
433 std::unique_ptr<ceres::Context> ceres_context{};
435 std::shared_mutex device_lock;
436 std::vector<std::unique_ptr<Device>> devices;
437 t_constellation_device_id_t next_device_id{0};
439 std::unique_ptr<DataRecorder> data_recorder{};
441 mutable os::Mutex rig_calibration_lock{};
443 bool running_calibration{
false};
444 std::unique_ptr<rig_calibration::RigCalibration> rig_calibration{};
446#ifdef XRT_FEATURE_RERUN
447 std::unique_ptr<struct RerunContext> rerun_stream{};
459 Get(t_constellation_tracker *tracker)
477 needSensorCalibration();
480 checkSensorCalibration();
483 setupVariableTracking();
485 t_constellation_device_id_t
489 removeDevice(t_constellation_device_id_t device_id);
CRTP glue wrapper for t_blob_sink.
Definition g_blob_sink.hpp:38
CRTP glue wrapper for xrt_frame_node.
Definition g_frame_node.hpp:33
CRTP glue wrapper for xrt_imu_sink.
Definition g_imu_sink.hpp:34
Ab-initio blob<->LED correspondence search.
Header for glue classes to wrap constellation blob sink interfaces.
Header for glue classes to wrap xrt frame node interfaces.
Header for glue classes to wrap xrt IMU sink interfaces.
u_logging_level
Logging level enum.
Definition u_logging.h:45
int64_t timepoint_ns
Integer timestamp type.
Definition u_time.h:77
LED search model management code.
C interface to math library.
Metrics for constellation tracking poses.
RANSAC PnP pose refinement.
Constellation tracker rig calibration.
Constellation tracker sensor fusion.
Definition t_rift_blobwatch.c:85
Definition camera_model.h:21
Definition correspondence_search.h:95
Definition u_pacing_compositor.c:59
All in one helper that handles locking, waiting for change and starting a thread.
Definition os_threading.h:587
Definition pose_metrics.h:105
Definition pose_metrics.h:79
Definition t_constellation.h:104
A generic interface to allow a tracking system to receive "snapshots" of seen t_blob in a frame.
Definition t_constellation.h:136
A blob is a 2d position in a camera sensor's view that is being tracked.
Definition t_constellation.h:51
Definition t_constellation.h:187
Essential calibration data for a single camera, or single lens/sensor of a stereo camera.
Definition t_tracking.h:269
Definition led_search_model.h:40
A constellation tracker camera mosaic is a set of cameras that may or may not be physically attached,...
Definition t_constellation_tracker.h:60
A constellation tracker camera is a single camera that the constellation tracker will use to track de...
Definition t_constellation_tracker.h:34
Parameters for adding a device to the constellation tracker.
Definition t_constellation_tracker.h:79
A constellation tracker device is a device that the constellation tracker will attempt to track in 6d...
Definition t_constellation.h:415
The LED model is a series of points which define the real-world positions of all LEDs.
Definition t_constellation.h:313
Definition t_constellation_tracker.h:108
A constellation tracker tracking source is an arbitrary source of tracking data for the constellation...
Definition t_constellation.h:256
Allows more safely to debug sink inputs and outputs.
Definition u_sink.h:214
Definition t_constellation_tracker_internal.hpp:201
os::Mutex processing_lock
Locks all processing data.
Definition t_constellation_tracker_internal.hpp:242
uint32_t index
The index in the mosaic.
Definition t_constellation_tracker_internal.hpp:214
ConstellationTracker * tracker
The owner tracker, so we can retrieve it from the blob sink callback.
Definition t_constellation_tracker_internal.hpp:204
Definition t_constellation_tracker_internal.hpp:326
uint32_t index
The index of this mosaic in the tracker.
Definition t_constellation_tracker_internal.hpp:330
Definition t_constellation_tracker_internal.hpp:120
std::optional< xrt_pose > Txr_world_cam
The camera's position in the constellation tracker's tracking origin.
Definition t_constellation_tracker_internal.hpp:130
Definition t_constellation_tracker_internal.hpp:179
Definition t_constellation_tracker_internal.hpp:417
Definition t_constellation_tracker_dataset.hpp:124
Definition t_constellation_tracker_internal.hpp:357
ConstellationTracker * tracker
The owner tracker, so we can retrieve it from the IMU sink callback.
Definition t_constellation_tracker_internal.hpp:368
Definition t_constellation_tracker_internal.hpp:346
Definition t_constellation_tracker_internal.hpp:103
std::optional< xrt_space_relation > Tcv_cam_device_predicted
The predicted pose of the device relative to the camera at the time of the sample.
Definition t_constellation_tracker_internal.hpp:110
t_constellation_device_id_t device_id
The ID of the device.
Definition t_constellation_tracker_internal.hpp:105
std::optional< xrt_pose > Txr_world_device_prior
The predicted pose of the device in the world at the time of the sample.
Definition t_constellation_tracker_internal.hpp:108
std::optional< FoundDevicePose > found_pose
The final found pose of the device in this specific sample.
Definition t_constellation_tracker_internal.hpp:113
bool needs_slow_processing
Whether the device needs to have the slow processing thread run over it.
Definition t_constellation_tracker_internal.hpp:116
Definition t_constellation_tracker_internal.hpp:90
bool handled
Whether a found pose was already handled, this is present so that if a single sample is torn between ...
Definition t_constellation_tracker_internal.hpp:99
A interface object used for destroying a frame graph.
Definition xrt_frame.h:87
IMU Sample.
Definition xrt_tracking.h:179
A pose composed of a position and orientation.
Definition xrt_defines.h:535
A relation with two spaces, includes velocity and acceleration.
Definition xrt_defines.h:726
A tracking system or device origin.
Definition xrt_tracking.h:115
A 3 element vector with single floats.
Definition xrt_defines.h:323
Header defining the tracking system integration in Monado.
Header defining the constellation tracker parameters and functions.
xrt_frame helpers for scribbling onto frames.
Basic logging functionality.
xrt_frame_sink converters and other helpers.
Slightly higher level thread safe helpers.
C++ helpers for weak pointers.
Header defining the tracking system integration in Monado.