27#include <shared_mutex>
39DEBUG_GET_ONCE_LOG_OPTION(constellation_tracker_log,
"CONSTELLATION_TRACKER_LOG",
U_LOGGING_WARN)
41#define CT_TRACE(ct, ...) U_LOG_IFL_T(ct->log_level, __VA_ARGS__)
42#define CT_DEBUG(ct, ...) U_LOG_IFL_D(ct->log_level, __VA_ARGS__)
43#define CT_INFO(ct, ...) U_LOG_IFL_I(ct->log_level, __VA_ARGS__)
44#define CT_WARN(ct, ...) U_LOG_IFL_W(ct->log_level, __VA_ARGS__)
45#define CT_ERROR(ct, ...) U_LOG_IFL_E(ct->log_level, __VA_ARGS__)
47#define MIN_ROT_ERROR DEG_TO_RAD(30)
48#define MIN_POS_ERROR 0.10
60constellation_tracker_camera_destroy(
struct t_blob_sink *tbs);
63constellation_tracker_camera_slow_thread(
void *ptr);
66constellation_tracker_camera_fast_thread(
void *ptr);
69constellation_tracker_node_break_apart(
struct xrt_frame_node *node);
75namespace xrt::tracking::constellation {
77namespace os = xrt::auxiliary::os;
87 struct t_blob blob_storage[XRT_CONSTELLATION_MAX_BLOBS_PER_FRAME];
91 std::array<t_constellation_device_id_t, XRT_CONSTELLATION_MAX_DEVICES> needs_slow_processing;
92 uint32_t num_devices_needing_slow_processing;
95 Take(std::optional<CameraSample> &maybe_sample);
99 std::array<t_constellation_device_id_t, XRT_CONSTELLATION_MAX_DEVICES> &devices_needing_slow_processing,
100 uint32_t num_devices_needing_slow_processing);
109 .
push_blobs = constellation_tracker_camera_push_blobs,
110 .destroy = constellation_tracker_camera_destroy,
115 std::weak_ptr<CameraMosaic> mosaic;
128 } slow_processing_thread_data;
140 } fast_processing_thread_data;
148 bool has_concrete_pose;
157 Camera(ConstellationTracker *
tracker,
158 std::weak_ptr<CameraMosaic> mosaic,
165 Camera(
const Camera &) =
delete;
166 Camera(Camera &&) =
delete;
168 operator=(
const Camera &) =
delete;
170 operator=(Camera &&) =
delete;
172 std::optional<struct xrt_pose>
176 DeferSampleToSlowThread(CameraSample &sample);
181 CameraSample &sample,
183 struct xrt_pose &Tcv_world_device_prior,
184 struct xrt_pose &Tcv_world_device_candidate);
187 TryDeviceBlobRecovery(std::unique_ptr<Device> &device,
188 CameraSample &sample,
190 struct xrt_pose &Tcv_world_device_prior);
193 SlowSampleProcess(CameraSample &sample);
200 PushPose(std::unique_ptr<Device> &device,
209 std::vector<std::unique_ptr<Camera>> cameras;
217 std::optional<struct xrt_pose>
226 t_constellation_device_id_t id;
233 float gravity_error_rad{MIN_ROT_ERROR};
235 mutable os::Mutex data_lock;
239 struct xrt_pose Txr_world_device_last_known;
245 t_constellation_device_id_t
id);
254 .
break_apart = constellation_tracker_node_break_apart,
255 .destroy = constellation_tracker_node_destroy,
265 std::vector<std::shared_ptr<CameraMosaic>> mosaics;
267 std::shared_mutex device_lock;
268 std::vector<std::unique_ptr<Device>> devices;
269 t_constellation_device_id_t next_device_id{0};
279 ~ConstellationTracker();
282 ConstellationTracker(
const ConstellationTracker &) =
delete;
283 ConstellationTracker(ConstellationTracker &&) =
delete;
284 ConstellationTracker &
285 operator=(
const ConstellationTracker &) =
delete;
286 ConstellationTracker &
287 operator=(ConstellationTracker &&) =
delete;
289 t_constellation_device_id_t
293 RemoveDevice(t_constellation_device_id_t device_id);
298 t_constellation_device_id_t device_id,
Ab-initio blob<->LED correspondence search.
u_logging_level
Logging level enum.
Definition u_logging.h:45
@ U_LOGGING_WARN
Warning messages: indicating a potential problem.
Definition u_logging.h:49
int64_t timepoint_ns
Integer timestamp type.
Definition u_time.h:77
#define container_of(ptr, type, field)
Get the holder from a pointer to a field.
Definition xrt_compiler.h:226
LED search model management code.
C interface to math library.
Metrics for constellation tracking poses.
RANSAC PnP pose refinement.
Definition t_rift_blobwatch.c:82
Definition camera_model.h:19
Definition correspondence_search.h:92
All in one helper that handles locking, waiting for change and starting a thread.
Definition os_threading.h:499
Definition pose_metrics.h:85
Definition pose_metrics.h:61
Definition t_constellation.h:74
A generic interface to allow a tracking system to receive "snapshots" of seen t_blob in a frame.
Definition t_constellation.h:95
void(* push_blobs)(struct t_blob_sink *tbs, struct t_blob_observation *observation)
Push a set of blobs into the sink.
Definition t_constellation.h:103
A blob is a 2d position in a camera sensor's view that is being tracked.
Definition t_constellation.h:37
Essential calibration data for a single camera, or single lens/sensor of a stereo camera.
Definition t_tracking.h:236
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:58
A constellation tracker camera is a single camera that the constellation tracker will use to track de...
Definition t_constellation_tracker.h:32
Parameters for adding a device to the constellation tracker.
Definition t_constellation_tracker.h:77
A constellation tracker device is a device that the constellation tracker will attempt to track in 6d...
Definition t_constellation.h:315
The LED model is a series of points which define the real-world positions of all LEDs.
Definition t_constellation.h:260
Definition t_constellation_tracker.h:92
A constellation tracker tracking source is an arbitrary source of tracking data for the constellation...
Definition t_constellation.h:215
Definition t_constellation_tracker_internal.hpp:107
bool TryDevicePose(std::unique_ptr< Device > &device, CameraSample &sample, struct xrt_pose &Tcv_cam_world, struct xrt_pose &Tcv_world_device_prior, struct xrt_pose &Tcv_world_device_candidate)
Fast matching based on prior pose.
Definition t_constellation_tracker.cpp:185
os::Mutex processing_lock
Locks all processing data.
Definition t_constellation_tracker_internal.hpp:143
struct ConstellationTracker * tracker
The owner tracker, so we can retrieve it from the blob sink callback.
Definition t_constellation_tracker_internal.hpp:114
bool FastSampleProcess(CameraSample &sample)
Returns whether a slow search is needed.
Definition t_constellation_tracker.cpp:338
struct os_thread_helper slow_processing_thread
Does "slow" processing for this camera when fast recovery paths fail.
Definition t_constellation_tracker_internal.hpp:122
struct xrt::tracking::constellation::Camera::@322 locked_data
All data protected by the processing lock.
struct os_thread_helper fast_processing_thread
Does "fast" processing for this camera, trying to recover a pose quickly.
Definition t_constellation_tracker_internal.hpp:134
Definition t_constellation_tracker_internal.hpp:208
Definition t_constellation_tracker_internal.hpp:84
Definition t_constellation_tracker_internal.hpp:251
bool running
Whether the constellation tracker is running.
Definition t_constellation_tracker_internal.hpp:259
Definition t_constellation_tracker_internal.hpp:231
Definition t_constellation_tracker_internal.hpp:232
Definition t_constellation_tracker_internal.hpp:222
A interface object used for destroying a frame graph.
Definition xrt_frame.h:87
void(* break_apart)(struct xrt_frame_node *node)
Called first in when the graph is being destroyed, remove any references frames and other objects and...
Definition xrt_frame.h:94
A pose composed of a position and orientation.
Definition xrt_defines.h:492
A 3 element vector with single floats.
Definition xrt_defines.h:289
Header defining the tracking system integration in Monado.
Header defining the constellation tracker parameters and functions.
Basic logging functionality.
Slightly higher level thread safe helpers.
C++ helpers for weak pointers.