Monado OpenXR Runtime
wmr_source.c File Reference

WMR camera and IMU data source. More...

#include "wmr_source.h"
#include "wmr_camera.h"
#include "wmr_config.h"
#include "wmr_protocol.h"
#include "math/m_api.h"
#include "math/m_clock_offset.h"
#include "math/m_filter_fifo.h"
#include "util/u_debug.h"
#include "util/u_sink.h"
#include "util/u_var.h"
#include "util/u_trace_marker.h"
#include "xrt/xrt_tracking.h"
#include "xrt/xrt_frameserver.h"
#include <assert.h>
#include <stdio.h>
#include <inttypes.h>
Include dependency graph for wmr_source.c:

Data Structures

struct  wmr_source
 Handles all the data sources from the WMR driver. More...
 

Macros

#define WMR_SOURCE_STR   "WMR Source"
 
#define WMR_TRACE(w, ...)   U_LOG_IFL_T(w->log_level, __VA_ARGS__)
 
#define WMR_DEBUG(w, ...)   U_LOG_IFL_D(w->log_level, __VA_ARGS__)
 
#define WMR_INFO(w, ...)   U_LOG_IFL_I(w->log_level, __VA_ARGS__)
 
#define WMR_WARN(w, ...)   U_LOG_IFL_W(w->log_level, __VA_ARGS__)
 
#define WMR_ERROR(w, ...)   U_LOG_IFL_E(w->log_level, __VA_ARGS__)
 
#define WMR_ASSERT(predicate, ...)
 
#define WMR_ASSERT_(predicate)   WMR_ASSERT(predicate, "Assertion failed " #predicate)
 
#define DEFINE_RECEIVE_CAM(cam_id)
 

Functions

static void receive_cam0 (struct xrt_frame_sink *sink, struct xrt_frame *xf)
 
static void receive_cam1 (struct xrt_frame_sink *sink, struct xrt_frame *xf)
 
static void receive_cam2 (struct xrt_frame_sink *sink, struct xrt_frame *xf)
 
static void receive_cam3 (struct xrt_frame_sink *sink, struct xrt_frame *xf)
 
static void receive_imu_sample (struct xrt_imu_sink *sink, struct xrt_imu_sample *s)
 
static struct wmr_sourcewmr_source_from_xfs (struct xrt_fs *xfs)
 
static bool wmr_source_enumerate_modes (struct xrt_fs *xfs, struct xrt_fs_mode **out_modes, uint32_t *out_count)
 
static bool wmr_source_configure_capture (struct xrt_fs *xfs, struct xrt_fs_capture_parameters *cp)
 
static bool wmr_source_stream_stop (struct xrt_fs *xfs)
 
static bool wmr_source_is_running (struct xrt_fs *xfs)
 
static bool wmr_source_stream_start (struct xrt_fs *xfs, struct xrt_frame_sink *xs, enum xrt_fs_capture_type capture_type, uint32_t descriptor_index)
 
static bool wmr_source_slam_stream_start (struct xrt_fs *xfs, struct xrt_slam_sinks *sinks)
 
static void wmr_source_node_break_apart (struct xrt_frame_node *node)
 
static void wmr_source_node_destroy (struct xrt_frame_node *node)
 
struct xrt_fswmr_source_create (struct xrt_frame_context *xfctx, struct xrt_prober_device *dev_holo, struct wmr_hmd_config cfg)
 Create and open the frame server for IMU/camera streaming. More...
 
void wmr_source_push_imu_packet (struct xrt_fs *xfs, timepoint_ns t, struct xrt_vec3 accel, struct xrt_vec3 gyro)
 

Variables

void(* receive_cam [4])(struct xrt_frame_sink *, struct xrt_frame *)
 Define a function for each WMR_MAX_CAMERAS and reference it in this array. More...
 

Detailed Description

WMR camera and IMU data source.

Author
Mateo de Mayo mateo.nosp@m..dem.nosp@m.ayo@c.nosp@m.olla.nosp@m.bora..nosp@m.com

Macro Definition Documentation

◆ DEFINE_RECEIVE_CAM

#define DEFINE_RECEIVE_CAM (   cam_id)
Value:
static void receive_cam##cam_id(struct xrt_frame_sink *sink, struct xrt_frame *xf) \
{ \
struct wmr_source *ws = container_of(sink, struct wmr_source, cam_sinks[cam_id]); \
if (cam_id == 0) { \
ws->cam_hw2mono = ws->hw2mono; \
} \
xf->timestamp += ws->cam_hw2mono; \
WMR_TRACE(ws, "cam" #cam_id " img t=%" PRId64 " source_t=%" PRId64, xf->timestamp, \
xf->source_timestamp); \
u_sink_debug_push_frame(&ws->ui_cam_sinks[cam_id], xf); \
if (ws->out_sinks.cams[cam_id] && ws->first_imu_received) { \
xrt_sink_push_frame(ws->out_sinks.cams[cam_id], xf); \
} \
}
#define container_of(ptr, type, field)
Get the holder from a pointer to a field.
Definition: xrt_compiler.h:148
Handles all the data sources from the WMR driver.
Definition: wmr_source.c:56
A object that is sent frames.
Definition: xrt_frame.h:58
Basic frame data structure - holds a pointer to buffer.
Definition: xrt_frame.h:25
void(* receive_cam[4])(struct xrt_frame_sink *, struct xrt_frame *)
Define a function for each WMR_MAX_CAMERAS and reference it in this array.
Definition: wmr_source.c:110

◆ WMR_ASSERT

#define WMR_ASSERT (   predicate,
  ... 
)
Value:
do { \
bool p = predicate; \
if (!p) { \
U_LOG(U_LOGGING_ERROR, __VA_ARGS__); \
assert(false && "WMR_ASSERT failed: " #predicate); \
exit(EXIT_FAILURE); \
} \
} while (false);
@ U_LOGGING_ERROR
Error messages: indicating a problem.
Definition: u_logging.h:45

Function Documentation

◆ receive_imu_sample()

static void receive_imu_sample ( struct xrt_imu_sink sink,
struct xrt_imu_sample s 
)
static

Variable Documentation

◆ receive_cam

void(* receive_cam[ 4 ])(struct xrt_frame_sink *, struct xrt_frame *) ( struct xrt_frame_sink ,
struct xrt_frame  
)
Initial value:
= {
receive_cam0,
receive_cam1,
receive_cam2,
receive_cam3,
}

Define a function for each WMR_MAX_CAMERAS and reference it in this array.