d/simulated: Rename the simulated device driver.

This commit is contained in:
Ryan Pavlik 2022-05-17 15:18:08 -05:00
parent a0ebc103d6
commit 56a1c25378
10 changed files with 180 additions and 180 deletions

View file

@ -280,7 +280,7 @@ option_with_deps(XRT_BUILD_DRIVER_ULV2 "Enable Ultraleap v2 driver" DEPENDS Leap
option_with_deps(XRT_BUILD_DRIVER_VF "Build video frame driver (for video file support, uses gstreamer)" DEPENDS XRT_HAVE_GST)
option_with_deps(XRT_BUILD_DRIVER_VIVE "Enable driver for HTC Vive, Vive Pro, Valve Index, and their controllers" DEPENDS ZLIB_FOUND XRT_HAVE_LINUX)
option_with_deps(XRT_BUILD_DRIVER_WMR "Enable Windows Mixed Reality driver" DEPENDS "NOT WIN32")
option(XRT_BUILD_DRIVER_DUMMY "Enable dummy driver" ON)
option(XRT_BUILD_DRIVER_SIMULATED "Enable simulated driver" ON)
option(XRT_BUILD_SAMPLES "Enable compiling sample code implementations that will not be linked into any final targets" ON)
@ -314,7 +314,7 @@ list(
"ANDROID"
"ARDUINO"
"DAYDREAM"
"DUMMY"
"SIMULATED"
"HANDTRACKING"
"HDK"
"HYDRA"
@ -477,7 +477,7 @@ message(STATUS "# DRIVER_ANDROID: ${XRT_BUILD_DRIVER_ANDROID}")
message(STATUS "# DRIVER_ARDUINO: ${XRT_BUILD_DRIVER_ARDUINO}")
message(STATUS "# DRIVER_DAYDREAM: ${XRT_BUILD_DRIVER_DAYDREAM}")
message(STATUS "# DRIVER_DEPTHAI: ${XRT_BUILD_DRIVER_DEPTHAI}")
message(STATUS "# DRIVER_DUMMY: ${XRT_BUILD_DRIVER_DUMMY}")
message(STATUS "# DRIVER_SIMULATED: ${XRT_BUILD_DRIVER_SIMULATED}")
message(STATUS "# DRIVER_EUROC: ${XRT_BUILD_DRIVER_EUROC}")
message(STATUS "# DRIVER_HANDTRACKING: ${XRT_BUILD_DRIVER_HANDTRACKING}")
message(STATUS "# DRIVER_HDK: ${XRT_BUILD_DRIVER_HDK}")

View file

@ -43,10 +43,10 @@ if(XRT_BUILD_DRIVER_DEPTHAI)
list(APPEND ENABLED_DRIVERS depthai)
endif()
if(XRT_BUILD_DRIVER_DUMMY)
add_library(drv_dummy STATIC dummy/dummy_hmd.c dummy/dummy_interface.h dummy/dummy_prober.c)
target_link_libraries(drv_dummy PRIVATE xrt-interfaces aux_util)
list(APPEND ENABLED_HEADSET_DRIVERS dummy)
if(XRT_BUILD_DRIVER_SIMULATED)
add_library(drv_simulated STATIC simulated/simulated_hmd.c simulated/simulated_interface.h simulated/simulated_prober.c)
target_link_libraries(drv_simulated PRIVATE xrt-interfaces aux_util)
list(APPEND ENABLED_HEADSET_DRIVERS simulated)
endif()
if(XRT_BUILD_DRIVER_QWERTY)

View file

@ -1,48 +0,0 @@
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Interface to dummy driver.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup drv_dummy
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/*!
* @defgroup drv_dummy Dummy driver
* @ingroup drv
*
* @brief Simple do-nothing dummy driver.
*/
/*!
* Create a auto prober for dummy devices.
*
* @ingroup drv_dummy
*/
struct xrt_auto_prober *
dummy_create_auto_prober(void);
/*!
* Create a dummy hmd.
*
* @ingroup drv_dummy
*/
struct xrt_device *
dummy_hmd_create(void);
/*!
* @dir drivers/dummy
*
* @brief @ref drv_dummy files.
*/
#ifdef __cplusplus
}
#endif

View file

@ -1,73 +0,0 @@
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Dummy prober code.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup drv_dummy
*/
#include <stdio.h>
#include <stdlib.h>
#include "xrt/xrt_prober.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "dummy_interface.h"
/*!
* @implements xrt_auto_prober
*/
struct dummy_prober
{
struct xrt_auto_prober base;
};
//! @private @memberof dummy_prober
static inline struct dummy_prober *
dummy_prober(struct xrt_auto_prober *p)
{
return (struct dummy_prober *)p;
}
//! @public @memberof dummy_prober
static void
dummy_prober_destroy(struct xrt_auto_prober *p)
{
struct dummy_prober *dp = dummy_prober(p);
free(dp);
}
//! @public @memberof dummy_prober
static int
dummy_prober_autoprobe(struct xrt_auto_prober *xap,
cJSON *attached_data,
bool no_hmds,
struct xrt_prober *xp,
struct xrt_device **out_xdevs)
{
struct dummy_prober *dp = dummy_prober(xap);
(void)dp;
// Do not create a dummy HMD if we are not looking for HMDs.
if (no_hmds) {
return 0;
}
out_xdevs[0] = dummy_hmd_create();
return 1;
}
struct xrt_auto_prober *
dummy_create_auto_prober()
{
struct dummy_prober *dp = U_TYPED_CALLOC(struct dummy_prober);
dp->base.name = "Dummy";
dp->base.destroy = dummy_prober_destroy;
dp->base.lelo_dallas_autoprobe = dummy_prober_autoprobe;
return &dp->base;
}

View file

@ -2,9 +2,9 @@
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Dummy HMD device.
* @brief Simulated HMD device.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup drv_dummy
* @ingroup drv_simulated
*/
#include "xrt/xrt_device.h"
@ -31,10 +31,10 @@
*
*/
enum dummy_movement
enum simulated_movement
{
DUMMY_WOBBLE,
DUMMY_ROTATE,
SIMULATED_WOBBLE,
SIMULATED_ROTATE,
};
@ -43,7 +43,7 @@ enum dummy_movement
*
* @implements xrt_device
*/
struct dummy_hmd
struct simulated_hmd
{
struct xrt_device base;
@ -54,7 +54,7 @@ struct dummy_hmd
float diameter_m;
enum u_logging_level log_level;
enum dummy_movement movement;
enum simulated_movement movement;
};
@ -64,23 +64,23 @@ struct dummy_hmd
*
*/
static inline struct dummy_hmd *
dummy_hmd(struct xrt_device *xdev)
static inline struct simulated_hmd *
simulated_hmd(struct xrt_device *xdev)
{
return (struct dummy_hmd *)xdev;
return (struct simulated_hmd *)xdev;
}
DEBUG_GET_ONCE_LOG_OPTION(dummy_log, "DUMMY_LOG", U_LOGGING_WARN)
DEBUG_GET_ONCE_BOOL_OPTION(dummy_rotate, "DUMMY_ROTATE", false)
DEBUG_GET_ONCE_LOG_OPTION(simulated_log, "SIMULATED_LOG", U_LOGGING_WARN)
DEBUG_GET_ONCE_BOOL_OPTION(simulated_rotate, "SIMULATED_ROTATE", false)
#define DH_TRACE(p, ...) U_LOG_XDEV_IFL_T(&dh->base, dh->log_level, __VA_ARGS__)
#define DH_DEBUG(p, ...) U_LOG_XDEV_IFL_D(&dh->base, dh->log_level, __VA_ARGS__)
#define DH_ERROR(p, ...) U_LOG_XDEV_IFL_E(&dh->base, dh->log_level, __VA_ARGS__)
static void
dummy_hmd_destroy(struct xrt_device *xdev)
simulated_hmd_destroy(struct xrt_device *xdev)
{
struct dummy_hmd *dh = dummy_hmd(xdev);
struct simulated_hmd *dh = simulated_hmd(xdev);
// Remove the variable tracking.
u_var_remove_root(dh);
@ -89,18 +89,18 @@ dummy_hmd_destroy(struct xrt_device *xdev)
}
static void
dummy_hmd_update_inputs(struct xrt_device *xdev)
simulated_hmd_update_inputs(struct xrt_device *xdev)
{
// Empty, you should put code to update the attached inputs fields.
}
static void
dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
simulated_hmd_get_tracked_pose(struct xrt_device *xdev,
enum xrt_input_name name,
uint64_t at_timestamp_ns,
struct xrt_space_relation *out_relation)
{
struct dummy_hmd *dh = dummy_hmd(xdev);
struct simulated_hmd *dh = simulated_hmd(xdev);
if (name != XRT_INPUT_GENERIC_HEAD_POSE) {
DH_ERROR(dh, "unknown input name");
@ -118,7 +118,7 @@ dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
switch (dh->movement) {
default:
case DUMMY_WOBBLE:
case SIMULATED_WOBBLE:
// Wobble time.
dh->pose.position.x = dh->center.x + sin((time_s / t2) * M_PI) * d2 - d;
dh->pose.position.y = dh->center.y + sin((time_s / t) * M_PI) * d;
@ -128,7 +128,7 @@ dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
dh->pose.orientation.w = 1;
math_quat_normalize(&dh->pose.orientation);
break;
case DUMMY_ROTATE:
case SIMULATED_ROTATE:
// Reset position.
dh->pose.position = dh->center;
@ -144,7 +144,7 @@ dummy_hmd_get_tracked_pose(struct xrt_device *xdev,
}
static void
dummy_hmd_get_view_poses(struct xrt_device *xdev,
simulated_hmd_get_view_poses(struct xrt_device *xdev,
const struct xrt_vec3 *default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
@ -157,25 +157,25 @@ dummy_hmd_get_view_poses(struct xrt_device *xdev,
}
struct xrt_device *
dummy_hmd_create(void)
simulated_hmd_create(void)
{
enum u_device_alloc_flags flags =
(enum u_device_alloc_flags)(U_DEVICE_ALLOC_HMD | U_DEVICE_ALLOC_TRACKING_NONE);
struct dummy_hmd *dh = U_DEVICE_ALLOCATE(struct dummy_hmd, flags, 1, 0);
dh->base.update_inputs = dummy_hmd_update_inputs;
dh->base.get_tracked_pose = dummy_hmd_get_tracked_pose;
dh->base.get_view_poses = dummy_hmd_get_view_poses;
dh->base.destroy = dummy_hmd_destroy;
struct simulated_hmd *dh = U_DEVICE_ALLOCATE(struct simulated_hmd, flags, 1, 0);
dh->base.update_inputs = simulated_hmd_update_inputs;
dh->base.get_tracked_pose = simulated_hmd_get_tracked_pose;
dh->base.get_view_poses = simulated_hmd_get_view_poses;
dh->base.destroy = simulated_hmd_destroy;
dh->base.name = XRT_DEVICE_GENERIC_HMD;
dh->base.device_type = XRT_DEVICE_TYPE_HMD;
dh->pose.orientation.w = 1.0f; // All other values set to zero.
dh->created_ns = os_monotonic_get_ns();
dh->diameter_m = 0.05f;
dh->log_level = debug_get_log_option_dummy_log();
dh->log_level = debug_get_log_option_simulated_log();
// Print name.
snprintf(dh->base.str, XRT_DEVICE_NAME_LEN, "Dummy HMD");
snprintf(dh->base.serial, XRT_DEVICE_NAME_LEN, "Dummy HMD");
snprintf(dh->base.str, XRT_DEVICE_NAME_LEN, "Simulated HMD");
snprintf(dh->base.serial, XRT_DEVICE_NAME_LEN, "Simulated HMD");
// Setup input.
dh->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;
@ -193,18 +193,18 @@ dummy_hmd_create(void)
if (!u_device_setup_split_side_by_side(&dh->base, &info)) {
DH_ERROR(dh, "Failed to setup basic device info");
dummy_hmd_destroy(&dh->base);
simulated_hmd_destroy(&dh->base);
return NULL;
}
// Select the type of movement.
dh->movement = DUMMY_WOBBLE;
if (debug_get_bool_option_dummy_rotate()) {
dh->movement = DUMMY_ROTATE;
dh->movement = SIMULATED_WOBBLE;
if (debug_get_bool_option_simulated_rotate()) {
dh->movement = SIMULATED_ROTATE;
}
// Setup variable tracker.
u_var_add_root(dh, "Dummy HMD", true);
u_var_add_root(dh, "Simulated HMD", true);
u_var_add_pose(dh, &dh->pose, "pose");
u_var_add_vec3_f32(dh, &dh->center, "center");
u_var_add_f32(dh, &dh->diameter_m, "diameter_m");

View file

@ -0,0 +1,48 @@
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Interface to simulated driver.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup drv_simulated
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/*!
* @defgroup drv_simulated Simulated driver
* @ingroup drv
*
* @brief Simple do-nothing simulated driver.
*/
/*!
* Create a auto prober for simulated devices.
*
* @ingroup drv_simulated
*/
struct xrt_auto_prober *
simulated_create_auto_prober(void);
/*!
* Create a simulated hmd.
*
* @ingroup drv_simulated
*/
struct xrt_device *
simulated_hmd_create(void);
/*!
* @dir drivers/simulated
*
* @brief @ref drv_simulated files.
*/
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,73 @@
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Simulated prober code.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup drv_simulated
*/
#include <stdio.h>
#include <stdlib.h>
#include "xrt/xrt_prober.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "simulated_interface.h"
/*!
* @implements xrt_auto_prober
*/
struct simulated_prober
{
struct xrt_auto_prober base;
};
//! @private @memberof simulated_prober
static inline struct simulated_prober *
simulated_prober(struct xrt_auto_prober *p)
{
return (struct simulated_prober *)p;
}
//! @public @memberof simulated_prober
static void
simulated_prober_destroy(struct xrt_auto_prober *p)
{
struct simulated_prober *dp = simulated_prober(p);
free(dp);
}
//! @public @memberof simulated_prober
static int
simulated_prober_autoprobe(struct xrt_auto_prober *xap,
cJSON *attached_data,
bool no_hmds,
struct xrt_prober *xp,
struct xrt_device **out_xdevs)
{
struct simulated_prober *dp = simulated_prober(xap);
(void)dp;
// Do not create a simulated HMD if we are not looking for HMDs.
if (no_hmds) {
return 0;
}
out_xdevs[0] = simulated_hmd_create();
return 1;
}
struct xrt_auto_prober *
simulated_create_auto_prober()
{
struct simulated_prober *dp = U_TYPED_CALLOC(struct simulated_prober);
dp->base.name = "Simulated";
dp->base.destroy = simulated_prober_destroy;
dp->base.lelo_dallas_autoprobe = simulated_prober_autoprobe;
return &dp->base;
}

View file

@ -30,8 +30,8 @@ if(XRT_BUILD_DRIVER_DAYDREAM)
target_link_libraries(target_lists PRIVATE drv_daydream)
endif()
if(XRT_BUILD_DRIVER_DUMMY)
target_link_libraries(target_lists PRIVATE drv_dummy)
if(XRT_BUILD_DRIVER_SIMULATED)
target_link_libraries(target_lists PRIVATE drv_simulated)
endif()
if(XRT_BUILD_DRIVER_HDK)

View file

@ -24,7 +24,7 @@
#include "target_builder_interface.h"
#include "dummy/dummy_interface.h"
#include "simulated/simulated_interface.h"
#ifdef XRT_HAVE_OPENCV
#include "tracking/t_tracking.h"
@ -330,7 +330,7 @@ rgb_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, st
}
#endif
} else {
head = dummy_hmd_create();
head = simulated_hmd_create();
}

View file

@ -16,8 +16,8 @@
#include "arduino/arduino_interface.h"
#endif
#ifdef XRT_BUILD_DRIVER_DUMMY
#include "dummy/dummy_interface.h"
#ifdef XRT_BUILD_DRIVER_SIMULATED
#include "simulated/simulated_interface.h"
#endif
#ifdef XRT_BUILD_DRIVER_HDK
@ -228,9 +228,9 @@ xrt_auto_prober_create_func_t target_auto_list[] = {
qwerty_create_auto_prober,
#endif
#ifdef XRT_BUILD_DRIVER_DUMMY
// Dummy headset driver last.
dummy_create_auto_prober,
#ifdef XRT_BUILD_DRIVER_SIMULATED
// Simulated headset driver last.
simulated_create_auto_prober,
#endif
#ifdef XRT_BUILD_DRIVER_HANDTRACKING