robotology / yarp-device-ovrheadset

LibOVR device for YARP (https://www.yarp.it/)
Other
3 stars 2 forks source link

Run YARP device directly on Android on Oculus Quest using OpenXR #9

Open traversaro opened 3 years ago

traversaro commented 3 years ago

The Oculus Quest is an Android 8.0 (https://developer.oculus.com/documentation/native/android/mobile-studio-setup-android/) device that is able to work even without any connection to any laptop, differently from the Oculus Rift that needs to be connected to a laptop. Unfortunately, the use on Android requires the use of an API different from the one of the Rift on a laptop (libVr for Oculus Quest on Android, libovr for Oculus Rift on Laptop). At the moment, the Oculus Quest has been always used as if it was a "Rift" using Oculus Link cable.

However, if the device in this repo is ported to use OpenXR (improvement tracked https://github.com/robotology/yarp-device-ovrheadset/issues/8), that would mean that we the same API we can target both laptop use of the visor (Rift) and standalone use (Oculus Quest). However, this would mean running the code in this repo directly on board on the Android 8.0. This should be doable, here are some notes:

  1. Compile YARP for Android: Compiling and using CMake-based C++ library like YARP on Android is a fully supported feature by both CMake and Android, see https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android . Probably we just need to disable the ACE usage and just rely on POSIX interface by using the SKIP_ACE option. Running YARP-based software on Android system has been already done in the past, and documented by @alecive (❤️) in https://alessandro.ronc.one/research/2015/08/01/yarpdroid/ and https://alessandro.ronc.one/blog/2015/08/31/YARP-Cross-Compilation/ . Clearly as time has passed and compiler, SDK and tools changed, and some changes may be necessary (check https://github.com/robotology/yarp/issues/738 and https://github.com/alecive/alecive.github.io/issues/4 for the changes that were necessary just in 2017). However, the basic logic behind running C++-based YARP code Android is the same.

  2. Compile any other library need for Android using vcpkg: For any other C++ library that could be necessary (by both YARP or by this device) it should be possible to use vcpkg to compile them, see https://vcpkg.readthedocs.io/en/latest/users/android/ .

  3. Avoid to use dlopen and dynamic linking loading even when using plugins: dynamic library except for the one provided in NDK (see https://developer.android.com/about/versions/nougat/android-7.0-changes.html#ndk) I guess we need to ensure that the plugin can be linked as a static library. I think back in time YARP plugin system had this capability (see comment in https://www.reddit.com/r/cpp/comments/9c9kqz/do_cpp_users_wantneed_a_cross_platform_framework/e5ag74p?utm_source=share&utm_medium=web2x&context=3), but if that capability is not there anymore it should be sufficient to modify a bit the CMake to compile the plugin as a standalone static library, and then adding the class to the YARP dev factory via yarp::dev::Drivers::factory().add (as we do in https://github.com/robotology/gazebo-yarp-plugins/blob/master/plugins/controlboard/src/ControlBoard.cc#L82).

  4. Custom android device launcher. Instead of launching the device via yarpdev or yarprobotinterface we may need a custom launched for the device, but once the device is running fine preparing one should be trivial. Again the yarpdroid application could provide a nice example.

traversaro commented 3 years ago

fyi @S-Dafarra