d/survive: Add survive driver

This commit is contained in:
Christoph Haag 2019-03-12 02:02:06 +01:00 committed by Jakob Bornecrantz
parent 5b2efcbb7a
commit 5908c33439
13 changed files with 1337 additions and 1 deletions

View file

@ -107,6 +107,7 @@ option(BUILD_WITH_HDK "Enable HDK driver" ON)
option(BUILD_WITH_PSMV "Enable Playstation Move driver" ON) option(BUILD_WITH_PSMV "Enable Playstation Move driver" ON)
option(BUILD_WITH_HYDRA "Enable Hydra driver" ON) option(BUILD_WITH_HYDRA "Enable Hydra driver" ON)
option(BUILD_WITH_NS "Enable North Star driver" ON) option(BUILD_WITH_NS "Enable North Star driver" ON)
option(BUILD_WITH_LIBSURVIVE "Enable libsurvive driver" OFF)
# You can set this from a superproject to add a driver # You can set this from a superproject to add a driver
list(APPEND AVAILABLE_DRIVERS ARDUINO DUMMY HDK HYDRA NS OHMD PSMV PSVR RS V4L2 VIVE DAYDREAM) list(APPEND AVAILABLE_DRIVERS ARDUINO DUMMY HDK HYDRA NS OHMD PSMV PSVR RS V4L2 VIVE DAYDREAM)
@ -182,6 +183,13 @@ if(BUILD_WITH_NS)
set(BUILD_DRIVER_NS TRUE) set(BUILD_DRIVER_NS TRUE)
endif() endif()
if (BUILD_WITH_LIBSURVIVE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SURVIVE REQUIRED IMPORTED_TARGET survive)
add_definitions(-DXRT_BUILD_DRIVER_SURVIVE)
set(BUILD_DRIVER_SURVIVE TRUE)
endif()
if(BUILD_WITH_PSVR) if(BUILD_WITH_PSVR)
if (NOT ${HIDAPI_FOUND}) if (NOT ${HIDAPI_FOUND})
message(FATAL_ERROR "PSVR driver requires hidapi") message(FATAL_ERROR "PSVR driver requires hidapi")

View file

@ -178,6 +178,32 @@ You can verify that it stuck with the command.
xrandr --prop xrandr --prop
``` ```
## Using libsurvive
To enable the libsurvive driver, libsurvive has to be installed as a library with a pkgconfig file
(https://github.com/cntools/libsurvive/pull/187).
When starting any libsrvive or OpenXR application, libsurvive will run calibration and save
configuration and calibration data in the current working directory.
Make sure the HMD can see both basestations and is not moved during calibration.
To remove libsurvive's calibration data (e.g. to force recalibration) delete the following
files/directories:
rm -r *config.json calinfo
Though working and somewhat usable, support for the libsurvive driver is **experimental**.
Therefore with both meson and cmake, the survive driver has to be explicitly enabled with
```
#cmake
-DBUILD_WITH_LIBSURVIVE=On
#meson
-Ddrivers=auto,survive
```
## Coding style and formatting ## Coding style and formatting
[clang-format][] is used, [clang-format][] is used,

View file

@ -65,6 +65,7 @@ udev = dependency('libudev', required: false)
libuvc = dependency('libuvc', required: false) libuvc = dependency('libuvc', required: false)
vulkan = dependency('vulkan', required: true) vulkan = dependency('vulkan', required: true)
zlib = dependency('zlib', required: false) zlib = dependency('zlib', required: false)
survive = dependency('survive', required: false)
opencv = dependency('opencv4', required: false) opencv = dependency('opencv4', required: false)
if not opencv.found() if not opencv.found()
@ -183,6 +184,12 @@ if v4l2.found() and ('auto' in drivers or 'v4l2' in drivers)
endif endif
endif endif
if survive.found() and ('survive' in drivers)
if 'survive' not in drivers
drivers += ['survive']
endif
endif
if drivers.length() == 0 or drivers == ['auto'] if drivers.length() == 0 or drivers == ['auto']
error('You must enable at least one driver.') error('You must enable at least one driver.')
endif endif

View file

@ -3,7 +3,7 @@
option('drivers', option('drivers',
type: 'array', type: 'array',
choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'rs', 'v4l2', 'vive'], choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'rs', 'v4l2', 'vive', 'survive'],
value: ['auto'], value: ['auto'],
description: 'Set of drivers to build') description: 'Set of drivers to build')

View file

@ -162,6 +162,19 @@ if(BUILD_DRIVER_V4L2)
list(APPEND ENABLED_DRIVERS v4l2) list(APPEND ENABLED_DRIVERS v4l2)
endif() endif()
if (BUILD_WITH_LIBSURVIVE)
set(SURVIVE_SOURCE_FILES
survive/survive_driver.c
survive/survive_interface.h
survive/survive_wrap.c
survive/survive_wrap.h
)
add_library(drv_survive STATIC ${SURVIVE_SOURCE_FILES})
target_link_libraries(drv_survive PRIVATE xrt-interfaces aux_os aux_util aux_math PkgConfig::SURVIVE)
list(APPEND ENABLED_HEADSET_DRIVERS survive)
endif()
if(ENABLED_HEADSET_DRIVERS) if(ENABLED_HEADSET_DRIVERS)
set(ENABLED_DRIVERS ${ENABLED_HEADSET_DRIVERS} ${ENABLED_DRIVERS}) set(ENABLED_DRIVERS ${ENABLED_HEADSET_DRIVERS} ${ENABLED_DRIVERS})
list(SORT ENABLED_DRIVERS) list(SORT ENABLED_DRIVERS)

View file

@ -136,3 +136,19 @@ lib_drv_vive = static_library(
dependencies: [aux, zlib], dependencies: [aux, zlib],
build_by_default: 'vive' in drivers, build_by_default: 'vive' in drivers,
) )
lib_drv_survive = static_library(
'drv_survive',
files(
'survive/survive_driver.c',
'survive/survive_interface.h',
'survive/survive_wrap.c',
'survive/survive_wrap.h'
),
include_directories: [
xrt_include,
cjson_include,
],
dependencies: [aux, zlib, survive],
build_by_default: 'survive' in drivers,
)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,36 @@
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: Apache-2.0
/*!
* @file
* @brief Interface to Libsurvive adapter.
* @author Christoph Haag <christoph.haag@collabora.com>
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup drv_survive
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define HTC_VID 0x0bb4
#define VALVE_VID 0x28de
#define VIVE_PID 0x2c87
#define VIVE_LIGHTHOUSE_FPGA_RX 0x2000
#define VIVE_PRO_MAINBOARD_PID 0x0309
#define VIVE_PRO_LHR_PID 0x2300
int
survive_found(struct xrt_prober *xp,
struct xrt_prober_device **devices,
size_t num_devices,
size_t index,
cJSON *attached_data,
struct xrt_device **out_xdevs);
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,30 @@
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief low level libsurvive wrapper
* @author Christoph Haag <christoph.haag@collabora.com>
* @ingroup drv_survive
*/
#define SURVIVE_ENABLE_FULL_API 1
#include "survive_api.h"
#include "survive_wrap.h"
// TODO: expose config values we need through actual survive API
#include "survive.h"
bool
survive_config_ready(const SurviveSimpleObject *sso)
{
SurviveObject *so = survive_simple_get_survive_object(sso);
return so->conf != 0;
}
char *
survive_get_json_config(const SurviveSimpleObject *sso)
{
SurviveObject *so = survive_simple_get_survive_object(sso);
return so->conf;
}

View file

@ -0,0 +1,18 @@
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief low level libsurvive wrapper
* @author Christoph Haag <christoph.haag@collabora.com>
* @ingroup drv_survive
*/
#pragma once
#include "survive_api.h"
bool
survive_config_ready(const SurviveSimpleObject *sso);
char *
survive_get_json_config(const SurviveSimpleObject *sso);

View file

@ -67,6 +67,9 @@ if(BUILD_DRIVER_VIVE)
target_link_libraries(target_lists PRIVATE drv_vive) target_link_libraries(target_lists PRIVATE drv_vive)
endif() endif()
if(BUILD_DRIVER_SURVIVE)
target_link_libraries(target_lists PRIVATE drv_survive)
endif()
#### ####
# Instance # Instance

View file

@ -42,6 +42,10 @@
#include "hydra/hydra_interface.h" #include "hydra/hydra_interface.h"
#endif #endif
#ifdef XRT_BUILD_DRIVER_SURVIVE
#include "survive/survive_interface.h"
#endif
#ifdef XRT_BUILD_DRIVER_VIVE #ifdef XRT_BUILD_DRIVER_VIVE
#include "vive/vive_prober.h" #include "vive/vive_prober.h"
#include "vive/vive_controller_interface.h" #include "vive/vive_controller_interface.h"
@ -82,6 +86,12 @@ struct xrt_prober_entry target_entry_list[] = {
{HDK_VID, HDK_PID, hdk_found, "OSVR HDK"}, {HDK_VID, HDK_PID, hdk_found, "OSVR HDK"},
#endif // XRT_BUILD_DRIVER_HDK #endif // XRT_BUILD_DRIVER_HDK
#ifdef XRT_BUILD_DRIVER_SURVIVE
{HTC_VID, VIVE_PID, survive_found, "HTC Vive"},
{HTC_VID, VIVE_PRO_MAINBOARD_PID, survive_found, "HTC Vive Pro"},
{VALVE_VID, VIVE_PRO_LHR_PID, survive_found, "Valve Index"},
#endif
#ifdef XRT_BUILD_DRIVER_VIVE #ifdef XRT_BUILD_DRIVER_VIVE
{HTC_VID, VIVE_PID, vive_found, "HTC Vive"}, {HTC_VID, VIVE_PID, vive_found, "HTC Vive"},
{HTC_VID, VIVE_PRO_MAINBOARD_PID, vive_found, "HTC Vive Pro"}, {HTC_VID, VIVE_PRO_MAINBOARD_PID, vive_found, "HTC Vive Pro"},

View file

@ -54,6 +54,10 @@ if 'vive' in drivers
driver_libs += [lib_drv_vive] driver_libs += [lib_drv_vive]
endif endif
if 'survive' in drivers
driver_libs += [lib_drv_survive]
endif
subdir('common') subdir('common')
subdir('openxr') subdir('openxr')
subdir('cli') subdir('cli')