Commit 0db9db6c authored by Christoph Haag's avatar Christoph Haag

d/survive: Add libsurvive with positional tracking as submodule

v2: Update external libsurvive and update survive driver to latest prober api
v3: Update external libsurvive and update survive driver to latest prober api
parent 261b9125
Pipeline #57259 failed with stages
in 2 minutes and 21 seconds
[submodule "src/external/libsurvive"]
path = src/external/libsurvive
url = https://github.com/cnlohr/libsurvive.git
......@@ -57,7 +57,8 @@ cmake_dependent_option(BUILD_WITH_OPENCV "Enable OpenCV backend" ON "OpenCV_FOUN
cmake_dependent_option(BUILD_WITH_LIBUVC "Enable libuvc video driver" ON "LIBUVC_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_FFMPEG "Enable ffmpeg testing video driver" ON "FFMPEG_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_HIDAPI "Enable HIDAPI-based driver(s) (OSVR HDK, PSVR)" ON "HIDAPI_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_OPENHMD "Enable OpenHMD driver" ON "OPENHMD_FOUND" OFF)
option(BUILD_WITH_LIBSURVIVE "Enable libsurvive driver" ON)
cmake_dependent_option(BUILD_WITH_OPENHMD "Enable OpenHMD driver" OFF "OPENHMD_FOUND" OFF)
###
......@@ -104,6 +105,11 @@ if(BUILD_WITH_OPENHMD)
set(BUILD_DRIVER_OHMD TRUE)
endif()
if (BUILD_WITH_LIBSURVIVE)
add_definitions(-DXRT_BUILD_SURVIVE)
set(BUILD_DRIVER_SURVIVE TRUE)
endif()
if(BUILD_WITH_HIDAPI)
add_definitions(-DXRT_HAVE_HIDAPI)
......
# Monado - XR Runtime (XRT)
# Monado - XR Runtime (XRT) - experimental libsurvive branch
Monado is an open source XR runtime delivering immersive experiences such as VR
and AR on on mobile, PC/desktop, and any other device
......@@ -11,6 +11,28 @@ The project currently is being developed for GNU/Linux
and aims to support other operating systems in the near future.
"Monado" has no specific meaning and is just a name.
# About the libsurvive Branch
This branch contains libsurvive as a submodule in src/xrt/external/libsurvive.
Libsurvive is compiled as a shared library and the runtime links to libsurvive.
A device prober using the libsurvive simple api is implemented in src/xrt/drivers/survive.
When starting an 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 delete the following files/directories:
rm -r config.json HMD_config.json calinfo
Though working and usable, support for the libsurvive driver is **experimental**.
For example it contains many hardcoded values from OpenHMD's configuration for the Vive 1 and
does not behave well yet when no Vive is connected.
libsurvive may only build when the `-DUSE_OPENCV=OFF` cmake option is used.
## Monado source tree
* `src/xrt/include` - headers that define the internal interfaces of Monado.
......
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
if (BUILD_WITH_LIBSURVIVE)
add_subdirectory(external/libsurvive)
endif()
add_subdirectory(xrt)
Subproject commit 1dd49ea446533cfa77126fe451959a374ace373d
......@@ -92,3 +92,23 @@ if(BUILD_DRIVER_V4L2)
add_library(drv_v4l2 OBJECT ${V4L2_SOURCE_FILES})
set_property(TARGET drv_v4l2 PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
if (BUILD_WITH_LIBSURVIVE)
set(SURVIVE_SOURCE_FILES
survive/survive_device.c
survive/survive_device.h
survive/survive_interface.h
survive/survive_prober.c
)
# Use OBJECT to not create a archive, since it just gets in the way.
add_library(drv_survive OBJECT ${SURVIVE_SOURCE_FILES})
set_property(TARGET drv_survive PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(drv_survive SYSTEM
PRIVATE
${PROJECT_SOURCE_DIR}/src/external/libsurvive/include
${PROJECT_SOURCE_DIR}/src/external/libsurvive/include/libsurvive
${PROJECT_SOURCE_DIR}/src/external/libsurvive/redist
)
endif()
This diff is collapsed.
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: Apache-2.0
/*!
* @file
* @brief Interface to OpenHMD driver code.
* @author Jakob Bornecrantz <jakob@collabora.com>
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <survive_api.h>
struct survive_device
{
struct xrt_device base;
SurviveSimpleContext *ctx;
bool print_spew;
bool print_debug;
};
static inline struct survive_device *
survive_device(struct xrt_device *xdev)
{
return (struct survive_device *)xdev;
}
struct survive_device *
survive_device_create(bool print_spew, bool print_debug);
#define SURVIVE_SPEW(c, ...) \
do { \
if (c->print_spew) { \
fprintf(stderr, "%s - ", __func__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} \
} while (false)
#define SURVIVE_DEBUG(c, ...) \
do { \
if (c->print_debug) { \
fprintf(stderr, "%s - ", __func__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} \
} while (false)
#define SURVIVE_ERROR(c, ...) \
do { \
fprintf(stderr, "%s - ", __func__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while (false)
#ifdef __cplusplus
}
#endif
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: Apache-2.0
/*!
* @file
* @brief Interface to OpenHMD driver code.
* @author Jakob Bornecrantz <jakob@collabora.com>
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
struct xrt_auto_prober*
survive_create_auto_prober();
#ifdef __cplusplus
}
#endif
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: Apache-2.0
/*!
* @file
* @brief OpenHMD prober code.
* @author Jakob Bornecrantz <jakob@collabora.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <survive_api.h>
#include "xrt/xrt_prober.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "survive_device.h"
DEBUG_GET_ONCE_BOOL_OPTION(survive_spew, "SURVIVE_PRINT_SPEW", false)
DEBUG_GET_ONCE_BOOL_OPTION(survive_debug, "SURVIVE_PRINT_DEBUG", false)
struct survive_prober
{
struct xrt_auto_prober base;
SurviveSimpleContext *ctx;
};
static inline struct survive_prober *
survive_prober(struct xrt_auto_prober *p)
{
return (struct survive_prober *)p;
}
static void
survive_prober_destroy(struct xrt_auto_prober *p)
{
struct survive_prober *sp = survive_prober(p);
if (sp->ctx != NULL) {
/// @todo: This segfaults
// survive_simple_close(ohp->ctx);
sp->ctx = NULL;
}
free(sp);
}
static struct xrt_device *
survive_prober_autoprobe(struct xrt_auto_prober *p)
{
struct survive_prober *sp = survive_prober(p);
bool print_spew = debug_get_bool_option_survive_spew();
bool print_debug = debug_get_bool_option_survive_debug();
/// @todo: with libsurvive, whether a context can be created tells us if
/// a supported device is connected and readable.
struct survive_device *sd =
survive_device_create(print_spew, print_debug);
if (sd == NULL || sd->ctx == NULL)
return NULL;
sp->ctx = sd->ctx;
return &sd->base;
}
struct xrt_auto_prober *
survive_create_auto_prober()
{
struct survive_prober *sp = U_TYPED_CALLOC(struct survive_prober);
sp->base.destroy = survive_prober_destroy;
sp->base.lelo_dallas_autoprobe = survive_prober_autoprobe;
return &sp->base;
}
......@@ -102,6 +102,10 @@ oxr_system_fill_in(struct oxr_logger *log,
" failed to probe device");
}
#if 0
TODO: this breaks the rotation when enabling
XRT_SPACE_RELATION_POSITION_VALID_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT
if (head->tracking->type == XRT_TRACKING_TYPE_NONE) {
// "nominal height" 1.6m
head->tracking->offset.position.x = 0.0f;
......@@ -120,6 +124,7 @@ oxr_system_fill_in(struct oxr_logger *log,
right->tracking->offset.position.y = 1.3f;
right->tracking->offset.position.z = -0.5f;
}
#endif
// clang-format off
sys->head = head;
......
......@@ -41,6 +41,11 @@ target_link_libraries(prober PRIVATE
if(DRIVER_OBJECTS)
target_sources(prober PRIVATE ${DRIVER_OBJECTS})
if(BUILD_DRIVER_SURVIVE)
target_sources(prober PRIVATE $<TARGET_OBJECTS:drv_survive>)
target_link_libraries(prober PRIVATE survive)
endif()
endif()
if(DRIVER_LIBRARIES)
......
......@@ -14,6 +14,10 @@
#include "hdk/hdk_interface.h"
#endif
#ifdef XRT_BUILD_SURVIVE
#include "survive/survive_interface.h"
#endif
#ifdef XRT_BUILD_OHMD
#include "ohmd/oh_interface.h"
#endif
......@@ -74,6 +78,10 @@ xrt_auto_prober_creator target_auto_list[] = {
psvr_create_auto_prober,
#endif
#ifdef XRT_BUILD_SURVIVE
survive_create_auto_prober,
#endif
#ifdef XRT_BUILD_OHMD
// OpenHMD last as we want to override it with native drivers.
oh_create_auto_prober,
......
......@@ -53,6 +53,11 @@ if(DRIVER_OBJECTS)
target_sources(${RUNTIME_TARGET} PRIVATE ${DRIVER_OBJECTS})
endif()
if (BUILD_DRIVER_SURVIVE)
target_sources(${RUNTIME_TARGET} PRIVATE $<TARGET_OBJECTS:drv_survive>)
target_link_libraries(${RUNTIME_TARGET} PRIVATE survive)
endif()
if(DRIVER_LIBRARIES)
target_link_libraries(${RUNTIME_TARGET} PRIVATE ${DRIVER_LIBRARIES})
endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment