Setting up Virtual Reality on Ubuntu 18.04

  1. Installed Ubuntu 18.04.1.
  2. Installed Nvidia graphics drives using Ubuntu Software Update graphical interface, the Additional Drivers tab.
  3. Installed Stream using "sudo add-apt-repository multiverse" and "sudo apt install steam" and "sudo apt install steam-devices".
  4. Ran steam, logged into steam account, installed steamvr.
  5. Switched to SteamVR beta by right clicking SteamVR within Steam, choosing Properties, then Betas tab.
  6. Plugged HTC Vive headset into computer display port and usb.
  7. Started SteamVR from within Steam. It said headset not detected. Quit SteamVR and started again and it came up correctly, headset and hand-controllers tracking.
  8. Ran SteamVR room setup. No problems.
  9. Installed ChimeraX, ran it, opened molecule (command "open 2gbp") and started VR (command "vr on") which failed with message "VRInitError_Init_VRClientDLLNotFound' (error number 102)".
  10. Started ChimeraX using Steam to set library paths "~/.steam/ubuntu12_32/steam-runtime/run.sh chimerax-daily". Then "open 2gbp", "vr on" and ChimeraX crashed in openvr/__init__.py, line 3491 waitGetPoses().
  11. Quit SteamVR and restarted SteamVR. SteamVR window came up saying "SteamVR is in Extended Mode. Extended Mode is not recommended. For best results please switch to Direct Mode. Buttons: Dismiss. Enable Direct Mode.". Pressed Enable Direct Mode. SteamVR did not restart. Restarted from Srteam and got same Extended Mode warning. Pressed Dismiss.
  12. Moved around SteamVR lobby in VR, all worked fine.
  13. Tried ChimeraX again as before and it displayed correctly in the VR headset.
  14. Molecule had sporadic flicker. Used "vr on display blank" to turn off mirroring to flatpanel display which made VR flicker free. Apparently ChimeraX request to turn of syncing graphics draw to 60 Hz display does not work.
  15. Hand controller buttons do nothing. Patched openvr/__init__.py adding _pack_ = 4 to VREvent_t class and restarted ChimeraX.
  16. Quitting ChimeraX with vr enabled did not kill process. Had to type ctrl-c in shell where ChimeraX was started. If ChimeraX VR off then ChimeraX does exit.
  17. Now ChimeraX VR works correctly including hand-controller buttons.
  18. Tested opioids, ribosome, tif2b, neutrophil demos. All worked as smoothly as on Windows. Needed to manually do "vr display blank" for each and needed to ctrl-c ChimeraX or quit VR before quitting ChimeraX.
  19. Fixed ChimeraX to shutdown openvr when quitting.
  20. After shutdown fix it sometimes took 30 seconds for StreamVR home to startup. During that time, starting ChimeraX VR again often caused ChimeraX to freeze for 30 seconds before starting, or in one case produced an error about another app launching in VR.
  21. Fixed "vr on" to not mirror and to warn if wait for vsync cannot be disabled. Was not able to get Linux wait for vsync (glXSwapIntervalExt) to work because PyOpenGL cannot find any glx extensions likely due to some bug (querying glx version fails).
  22. Instead of starting chimerax with the Steam run.sh script it is possible to add to the SteamVR vrclient.so library a path that it needs to find libvulkan.so.1. I found (using ldd) that vrclient.so depends only on libvulkan.so.1 from Steam and specifying the location of libvulkan is sufficient for ChimeraX to run VR, starting Chimera with LD_LIBRARY_PATH=~/.steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu chimerax-daily. This path can instead be added to the SteamVR vrclient.so library that the Python OpenVR library used by ChimeraX imports.
    	sudo apt-get install patchelf
    	cd ~/.steam/steam/steamapps/common/SteamVR/bin/linux64
    	cp -p vrclient.so  vrclient.so.orig
    	patchelf --set-rpath '$ORIGIN/../../../../../../ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu' vrclient.so
    	
    This will break when SteamVR updates its vrclient.so library.
  23. A much better way to allow ChimeraX VR to run without Steam run.sh is to install libvulkan "sudo apt-get install libvulkan1".