OSVR/OSVR-Vive

Linux support

rpavlik opened this issue · 16 comments

Most of the driver is cross-platform, however, some code in:

is necessarily platform-specific (paths, details of loading dynamic libraries at runtime) and was only initially implemented for Windows. Valve is shipping SteamVR lighthouse drivers for Linux 64-bit at this time.

I tested this out. Configuration with cmake worked fine, but compiling did not work (as expected). I thought you might be interested in the error received:

[ 11%] Building CXX object CMakeFiles/ViveLoaderLib.dir/DriverLoader.cpp.o
In file included from /home/her0/src/osvr-vive/OSVR-Vive/InterfaceTraits.h:33:0,
                 from /home/her0/src/osvr-vive/OSVR-Vive/DriverLoader.h:29,
                 from /home/her0/src/osvr-vive/OSVR-Vive/DriverLoader.cpp:26:
/home/her0/src/osvr-vive/OSVR-Vive/vendor/openvr/headers/openvr_driver.h:879:2: error: #error "Unsupported Platform."
 #error "Unsupported Platform."
  ^~~~~
CMakeFiles/ViveLoaderLib.dir/build.make:86: recipe for target 'CMakeFiles/ViveLoaderLib.dir/DriverLoader.cpp.o' failed
make[2]: *** [CMakeFiles/ViveLoaderLib.dir/DriverLoader.cpp.o] Error 1
CMakeFiles/Makefile2:141: recipe for target 'CMakeFiles/ViveLoaderLib.dir/all' failed
make[1]: *** [CMakeFiles/ViveLoaderLib.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

For convenience, the error comes from here.

I am interested in getting this to work, but I am not experienced with C++. If there is anything I can help with (or if someone wants to point me in the right direction to implement it myself), let me know.

I got this to compile by commenting out some stuff in the openvr header. If I can figure out why that if block isn't working, I will submit a pull request to them. My changes can be found in this github gist.

In addition, the install target should probably be adjusted on Linux. osvr_server_config.vive.sample.json, README.md, and LICENSE are installed in install_prefix/.. I'm guessing the sample config should be in share/osvrcore/sample-configs, but I'm not sure that the readme and license should be in the install target, and they certainly shouldn't be in that location.

Unfortunately, it does not yet run, though I have not looked into it further. Here is the output:

her0@archdesk ~ % osvr_server /usr/share/osvrcore/sample-configs/osvr_server_config.vive.sample.json
[OSVR Server] Using config file '/usr/share/osvrcore/sample-configs/osvr_server_config.vive.sample.json'
[OSVR Server] Constructing server as configured...
[OSVR Server] Loading auto-loadable plugins...
[OSVR Server] Loading plugins...
[OSVR Server] 
[OSVR Server] Instantiating configured drivers...
[OSVR Server] 
[OSVR] ERROR: Could not load an object or display descriptor file specified by: "displays/HTC_Vive.json"

[OSVR] Tried loading displays/HTC_Vive.json: Could not open file
[OSVR Server] Using OSVR HDK for display configuration. Did not find an alternate valid 'display' object in config file.
[OSVR] ERROR: Could not load an object or RenderManager config file specified by: "sample-configs/renderManager.direct.landscape.json"

[OSVR] Tried loading sample-configs/renderManager.direct.landscape.json: Could not open file
[OSVR Server] Triggering automatic hardware detection...
[OSVR Server] Registering shutdown handler...
[OSVR Server] Starting server mainloop: OSVR Server is ready to go!
[OSVR] Performing hardware auto-detection.
terminate called after throwing an instance of 'osvr::vive::CouldNotLoadDriverModule'
  what():  Could not load driver module: libaitcamlib.so: cannot open shared object file: No such file or directory
[1]    26409 abort (core dumped)  osvr_server

Edit: libaitcamlib.so is from SteamVR. Adding it to the LD_LIBRARY_PATH fixes this error. The new error appears to be a mismatch between the SteamVR header and the SteamVR driver. May be my fault, will try to work this out.

So I fixed my own library issues as mentioned in my previous comment. The problem after that is definitely a version mismatch, as right now OpenVR is at version 0.9.21 and the submodule in this project is at 0.9.19. The following is the output from running it:

her0@archdesk ~/src/osvr-vive/OSVR-Vive (git)-[master] % LD_LIBRARY_PATH=LD_LIBRARY_PATH:/opt/SteamApps/common/SteamVR/drivers/lighthouse/bin/linux64 osvr_server /usr/share/osvrcore/sample-configs/osvr_server_config.vive.sample.json
[OSVR Server] Using config file '/usr/share/osvrcore/sample-configs/osvr_server_config.vive.sample.json'
[OSVR Server] Constructing server as configured...
[OSVR Server] Loading auto-loadable plugins...
[OSVR Server] Loading plugins...
[OSVR Server] 
[OSVR Server] Instantiating configured drivers...
[OSVR Server] 
[OSVR Server] Display descriptor found and parsed from config file.
[OSVR] ERROR: Could not load an object or RenderManager config file specified by: "sample-configs/renderManager.direct.landscape.json"

[OSVR] Tried loading sample-configs/renderManager.direct.landscape.json: Could not open file
[OSVR Server] Triggering automatic hardware detection...
[OSVR Server] Registering shutdown handler...
[OSVR Server] Starting server mainloop: OSVR Server is ready to go!
[OSVR] Performing hardware auto-detection.
[OSVR-Vive] Found the Vive driver at /opt/SteamApps/common/SteamVR/drivers/lighthouse/bin/linux64/driver_lighthouse.so
[OSVR-Vive] Driver config dir is: /home/her0/.local/share/Steam/config/lighthouse
[OSVR-Vive] Vive is connected.
[OSVR-Vive] Caught exception trying to start Vive server device provider: Could not get interface from native SteamVR driver - likely version mismatch. SteamVR error code: 105
SteamVR interface version may have changed, may need to be rebuilt against an updated header or use an older SteamVR version. Exiting.
[OSVR-Vive] Vive driver startup failed somewhere, unloading to perhaps try again later.
[OSVR] Path tree updated or connection detected
[OSVR] Sending path tree to clients.

After updating the submodule with my workaround patch, compiling fails. Looks like some changes need to be made for compatibility with the new version:

Scanning dependencies of target ViveLoaderLib
[  5%] Building CXX object CMakeFiles/ViveLoaderLib.dir/DriverLoader.cpp.o
[ 11%] Building CXX object CMakeFiles/ViveLoaderLib.dir/ServerDriverHost.cpp.o
[ 17%] Building CXX object CMakeFiles/ViveLoaderLib.dir/VRSettings.cpp.o
[ 23%] Linking CXX static library libViveLoaderLib.a
[ 35%] Built target ViveLoaderLib
Scanning dependencies of target ViveDisplayExtractor
[ 41%] Building CXX object CMakeFiles/ViveDisplayExtractor.dir/DisplayExtractor.cpp.o
/home/her0/src/osvr-vive/OSVR-Vive/DisplayExtractor.cpp: In function ‘int main()’:
/home/her0/src/osvr-vive/OSVR-Vive/DisplayExtractor.cpp:297:62: error: no matching function for call to ‘vr::IServerTrackedDeviceProvider::GetTrackedDeviceDriver(unsigned int&, const char*&)’
                     i, vr::ITrackedDeviceServerDriver_Version);
                                                              ^
In file included from /home/her0/src/osvr-vive/OSVR-Vive/DeviceHolder.h:32:0,
                 from /home/her0/src/osvr-vive/OSVR-Vive/DriverWrapper.h:30,
                 from /home/her0/src/osvr-vive/OSVR-Vive/DisplayExtractor.cpp:30:
/home/her0/src/osvr-vive/OSVR-Vive/vendor/openvr/headers/openvr_driver.h:1647:38: note: candidate: virtual vr::ITrackedDeviceServerDriver* vr::IServerTrackedDeviceProvider::GetTrackedDeviceDriver(uint32_t)
  virtual ITrackedDeviceServerDriver *GetTrackedDeviceDriver( uint32_t unWhich ) = 0;
                                      ^~~~~~~~~~~~~~~~~~~~~~
/home/her0/src/osvr-vive/OSVR-Vive/vendor/openvr/headers/openvr_driver.h:1647:38: note:   candidate expects 1 argument, 2 provided
CMakeFiles/ViveDisplayExtractor.dir/build.make:66: recipe for target 'CMakeFiles/ViveDisplayExtractor.dir/DisplayExtractor.cpp.o' failed
make[2]: *** [CMakeFiles/ViveDisplayExtractor.dir/DisplayExtractor.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ViveDisplayExtractor.dir/all' failed
make[1]: *** [CMakeFiles/ViveDisplayExtractor.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

As before, I will look into this further when I get the chance.

Edit: Just noticed that some of the stuff I reported was already known. Maybe, once it is working, the readme should be updated to include this information. In any case, OpenVR needs to be updated (probably on Windows also).

To update to the latest version, what is minimally needed is to have all calls to GetTrackedDeviceDriver and FindTrackedDeviceDriver to have only one argument. Basically, delete the version from all those calls and it compiles against the latest OpenVR. See details on the 0.9.21 commit message.

After doing this, I was able to compile this and run the server with it without any fatal errors, but I do not understand how to use ViveDisplayExtractor (is there documentation?) and it appears to not track.

Edit: I created a pull request (#12) that updates to the latest OpenVR and should restore functionality on Windows.

See the OSVR docs repo for documentation for the overall system that
includes info on running the display extractor. Note that the openvr
headers haven't always matched the steamvr headers presumably used to build
their binaries, and they don't necessarily match across platforms: for a
while one interface was at version 3 (private, not published or documented)
on Windows and 2 (public) on Linux. Updating the submodule will take some
thinking, as to whether it's valuable to fork the headers to support older
driver (interface) versions. The easy way to check compatibility is with
strings and grep for the interface version strings in the driver shared
object files.

On Fri, Jun 3, 2016, 1:21 PM Andrew Conrad notifications@github.com wrote:

To update to the latest version, what is minimally needed is to have all
calls to GetTrackedDeviceDriver and FindTrackedDeviceDriver to have only
one argument. Basically, delete the version from all those calls and it
compiles against the latest OpenVR. See details on the 0.9.21 commit
message
ValveSoftware/openvr@35e6fd3
.

After doing this, I was able to compile this and run the server with it
without any fatal errors, but I do not understand how to use
ViveDisplayExtractor (is there documentation?) and it appears to not track.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#4 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AADuydanW5-mPOFJk2_NhxKucSYQcMHgks5qIHC-gaJpZM4H3i2D
.

Ryan A. Pavlik, Ph.D.
CTO - OSVR Platform
Sensics, Inc.
www.sensics.com

Latest news and blog posts (subscribe here
http://sensics.com/subscribe-to-our-mailing-list/ go get weekly updates):

June 2: Sensics and Oasis VR create a unique network of VR facilities
http://sensics.com/sensics-and-oasis-vr-create-a-unique-network-of-vr-facilities/

June 1: VRguy podcast: CSO of Ergoneers on why eye trackers are expensive
http://sensics.com/vrguy-podcast-episode-13-dr-christian-lange-cso-of-ergoneers-on-eye-tracking/

May 27: How binocular overlap impacts horizontal field of view
http://sensics.com/how-binocular-overlap-impacts-horizontal-field-of-view/

luehm commented

@her001 I've been fiddling around with your openvr-0.9.21 branch the last few days and have been successful in compiling/running/detecting the HTC Vive. I've also been able to run the ViveDisplayExtractor and generate (what I believe to be) usable .json files. However, I'm having issues having the server properly read/open said files. I have checked permissions, absolute paths, etc with no dice. Have you been having any luck?

EDIT: Ok, so I was able to fix the previous issues by adding absolute paths to the config file. I'm now faced with vrpn errors when trying to run a client program (or even osvr_print_tree). Anybody seen errors like this? I'd love to investigate further, but haven't been able to locate helpful log files yet...

Further edit: I've been able to get OSVRTrackerViewer to run with osvr_server and can successfully track to two controllers. Still not able to track the HMD. Ideas?

@luehm hi! did you finally get the HMD tracking to work? I'm experiencing the same problem... Got the OSVRTrackerViewer to run and track the two controllers but still not getting anything from the HMD... When running the osvr_server it detects the HMD and assigns it the ID 0, but then I get a lot of ioctl(GFEATURE): Broken pipe messages (I'm guessing you got something similar when you mentioned "vrpn errors"?)

I've had a number of people get this to work (see #10 for some details on getting it to work) and was going to close this issue when I saw there was a comment from just an hour ago... note that the latest steamvr does break it again (see #21).

VRPN errors wouldn't be ioctl errors - when connecting and disconnecting apps (like print tree) there are things that look like errors then subsequently say "this is usually an app disconnecting". Nothing to worry about there.

ioctl errors suggest that it might not like your USB controller. The hardware is a bit picky - on Windows, it actually mattered whether I had the MS or Fresco Logic XHCI driver installed for the controller I installed dedicated to the Vive, and if I had the MS driver installed, the failure mode was "usually won't pair with one or both wireless controllers and would report back the unix epoch as the firmware date for the wireless receiver". (And, I needed a dedicated controller to deal with all the USB endpoints in the HMD itself: putting it on the on-board Intel controller caused lots of "out of USB resources" errors and failures to enumerate, which also might be your issue) In any case, doesn't sound OSVR-related, so there's probably not too much more I can do to help, sorry to say.

@rpavlik thanks for your quick response! What seems weird to me is that I am getting the tracking data from the controllers... and I'm assuming it comes from Vive's link box, same as the headset data...? I will check my steamvr version but I think it's the latest, so I hope changing that might fix something. If not, I'm pretty sure it's something about the usb, I will look it up. Thanks again!

I use driver_lighthouse.so directly (no OSVR-Vive), on several motherboards and USB cards, with several good USB chipsets. And I always get the ioctl(GFEATURE): Broken pipe messages. But HMD and controller (wired and wireless) tracking and input work, so they've been only a visual annoyance, but not a problem.

The developer of vrui wrote this article explaining how he was able to get the htc vive's input system working under linux! Hopefully, this might be useful to the devs?

I was the one who told the developer of VRUI that stuff... :D

This bug has trailed fairly far off course - OSVR-Vive has been confirmed to work on Linux, it's just not well documented. Perhaps it's best to open a new bug for documentation?

He mentioned he worked with you to produce the doc and eventually implement the solution. Sorry for the redundancy.

I used this script: https://bitbucket.org/monkygames/osvr-core-ubuntu-build-script because it is a huge time saver, thank you.

synapse@darkside:~/Desktop/osvr-core-ubuntu-build-script$ ./run.bash 
~/Desktop/osvr-core-ubuntu-build-script ~/Desktop/osvr-core-ubuntu-build-script
Feb 27 11:10:32.550 info [OSVR]: Logging for /home/synapse/Desktop/osvr-core-ubuntu-build-script/dist/bin/osvr_server
Feb 27 11:10:32.550 info [OSVR Server]: Using config file ../osvr_server_config.json from command line argument.
Feb 27 11:10:32.551 error [OSVR Server]: Could not find a valid config file!
~/Desktop/osvr-core-ubuntu-build-script

Took the config from here: https://raw.githubusercontent.com/OSVR/OSVR-Core/master/apps/osvr_server_config.json

synapse@darkside:~/Desktop/osvr-core-ubuntu-build-script$ vi ../osvr_server_config.json
synapse@darkside:~/Desktop/osvr-core-ubuntu-build-script$ cp ../osvr_server_config.json .
synapse@darkside:~/Desktop/osvr-core-ubuntu-build-script$ ./run.bash 
~/Desktop/osvr-core-ubuntu-build-script ~/Desktop/osvr-core-ubuntu-build-script
Feb 27 11:24:41.766 info [OSVR]: Logging for /home/synapse/Desktop/osvr-core-ubuntu-build-script/dist/bin/osvr_server
Feb 27 11:24:41.766 info [OSVR Server]: Using config file ../osvr_server_config.json from command line argument.
Feb 27 11:24:41.766 error [OSVR Server]: Could not find a valid config file!
~/Desktop/osvr-core-ubuntu-build-script

More logs:

synapse@darkside:~/Desktop/osvr-core-ubuntu-build-script$ ./OSVR-Core/build/bin/osvr_server
Feb 27 11:30:36.423 info [OSVR]: Logging for /home/synapse/Desktop/osvr-core-ubuntu-build-script/OSVR-Core/build/bin/osvr_server
Feb 27 11:30:36.423 info [OSVR Server]: Using default config file - pass a filename on the command line to use a different one.
Feb 27 11:30:36.423 info [OSVR Server]: Attempting to load config file 'osvr_server_config.json'.
Feb 27 11:30:36.423 info [OSVR Server]: Constructing server as configured...
Feb 27 11:30:36.423 info [OSVR Server]: Loading auto-loadable plugins...
Feb 27 11:30:36.551 info [OSVR Server]: Loading plugins...
Feb 27 11:30:36.551 info [OSVR Server]: Instantiating configured drivers...
Feb 27 11:30:36.551 info [OSVR Server]: Aliases found and parsed from config file.
Feb 27 11:30:36.551 info [OSVR Server]: Display descriptor found and parsed from config file.
Feb 27 11:30:36.551 info [OSVR Server]: RenderManager config found and parsed from the config file.
Feb 27 11:30:36.551 info [OSVR Server]: Triggering automatic hardware detection...
Feb 27 11:30:36.551 info [OSVR Server]: Registering shutdown handler...
Feb 27 11:30:36.551 info [OSVR Server]: Starting server mainloop: OSVR Server is ready to go!
Feb 27 11:30:36.551 info [OSVR Server]: Performing hardware auto-detection.
Feb 27 11:30:36.555 info [OSVR Server]: Sent path tree to clients.