d/rs: Add prober and create xrt_device for rs

This commit is contained in:
Christoph Haag 2021-02-09 17:38:35 +01:00
parent 6c6c70f700
commit 13db11901c
8 changed files with 96 additions and 1 deletions

View file

@ -139,6 +139,7 @@ endif()
if(XRT_BUILD_DRIVER_RS)
set(RS_SOURCE_FILES
realsense/rs_6dof.c
realsense/rs_prober.c
)
add_library(drv_rs STATIC ${RS_SOURCE_FILES})

View file

@ -114,6 +114,7 @@ lib_drv_rs = static_library(
files(
'realsense/rs_6dof.c',
'realsense/rs_interface.h',
'realsense/rs_prober.c',
),
include_directories: xrt_include,
dependencies: [aux, rs],

View file

@ -398,7 +398,7 @@ rs_6dof_create(void)
rs->base.get_tracked_pose = rs_6dof_get_tracked_pose;
rs->base.get_view_pose = rs_6dof_get_view_pose;
rs->base.destroy = rs_6dof_destroy;
rs->base.name = XRT_DEVICE_GENERIC_HMD; // This is a lie.
rs->base.name = XRT_DEVICE_REALSENSE;
rs->relation.pose.orientation.w = 1.0f; // All other values set to zero.
rs->base.tracking_origin->type = XRT_TRACKING_TYPE_EXTERNAL_SLAM;

View file

@ -32,6 +32,14 @@ rs_6dof_create(void);
void
rs_update_offset(struct xrt_pose offset, struct xrt_device *xdev);
/*!
* Create a auto prober for rs devices.
*
* @ingroup drv_rs
*/
struct xrt_auto_prober *
rs_create_auto_prober(void);
/*!
* @dir drivers/realsense
*

View file

@ -0,0 +1,74 @@
// Copyright 2021, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Realsense prober code.
* @author Christoph Haag <christoph.haag@collabora.com>
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup drv_rs
*/
#include <stdio.h>
#include <stdlib.h>
#include "xrt/xrt_prober.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "rs_interface.h"
/*!
* @implements xrt_auto_prober
*/
struct rs_prober
{
struct xrt_auto_prober base;
};
//! @private @memberof rs_prober
static inline struct rs_prober *
rs_prober(struct xrt_auto_prober *p)
{
return (struct rs_prober *)p;
}
//! @public @memberof rs_prober
static void
rs_prober_destroy(struct xrt_auto_prober *p)
{
struct rs_prober *dp = rs_prober(p);
free(dp);
}
//! @public @memberof rs_prober
static int
rs_prober_autoprobe(struct xrt_auto_prober *xap,
cJSON *attached_data,
bool no_hmds,
struct xrt_prober *xp,
struct xrt_device **out_xdevs)
{
struct rs_prober *dp = rs_prober(xap);
(void)dp;
struct xrt_device *dev = rs_6dof_create();
if (!dev) {
return 0;
}
out_xdevs[0] = dev;
return 1;
}
struct xrt_auto_prober *
rs_create_auto_prober()
{
struct rs_prober *dp = U_TYPED_CALLOC(struct rs_prober);
dp->base.name = "Realsense";
dp->base.destroy = rs_prober_destroy;
dp->base.lelo_dallas_autoprobe = rs_prober_autoprobe;
return &dp->base;
}

View file

@ -428,6 +428,8 @@ enum xrt_device_name
XRT_DEVICE_HAND_INTERACTION,
XRT_DEVICE_HAND_TRACKER,
XRT_DEVICE_REALSENSE,
};
/*!

View file

@ -338,6 +338,7 @@ public:
case XRT_DEVICE_XBOX_CONTROLLER: break; // TODO
case XRT_DEVICE_VIVE_TRACKER_GEN1: break; // TODO
case XRT_DEVICE_VIVE_TRACKER_GEN2: break; // TODO
case XRT_DEVICE_REALSENSE: break;
case XRT_DEVICE_HAND_INTERACTION: break; // there is no hardware
case XRT_DEVICE_GO_CONTROLLER: break; // hardware has no haptics

View file

@ -66,6 +66,10 @@
#include "illixr/illixr_interface.h"
#endif
#ifdef XRT_BUILD_DRIVER_RS
#include "realsense/rs_interface.h"
#endif
/*!
* Each entry should be a vendor ID (VID), product ID (PID), a "found" function,
* and a string literal name.
@ -154,6 +158,10 @@ xrt_auto_prober_creator target_auto_list[] = {
illixr_create_auto_prober,
#endif
#ifdef XRT_BUILD_DRIVER_RS
rs_create_auto_prober,
#endif
#ifdef XRT_BUILD_DRIVER_DUMMY
// Dummy headset driver last.
dummy_create_auto_prober,