BuzzteeBear / OpenXR-MotionCompensation

OpenXR API layer for motion compensation
GNU Lesser General Public License v2.1
50 stars 7 forks source link

OpenXR Motion Compensation

DISCLAIMER: This software is distributed as-is, without any warranties or conditions of any kind. Use at your own risks!

Version: CURRENT_DEV_BUILD

This document contains instructions on how to use OpenXR motion compensation API layer. A developers manual can be found here

Purpose of OpenXR Motion Compensation

When using a motion rig in combination with a VR headset (hmd) the movement of the rig causes the in-game camera to change along with your position in the real world. In simulations for example you're basically feel being pushed around inside the cockpit when the motion rig moves.
Motion compensation reduces or ideally removes that effect by locking the in-game world to the pose of the motion rig. This software aims to provide an API layer for motion compensation to be used with applications and hmds supporting the OpenXR standard.
To be able to do that, the software needs to be informed on the motion rig movement / position. This can be achieved using a tracker, which is either a physical object attached to the motion rig and tracked by the VR runtime (e.g. a motion controller or a vive puck) or a virtual tracker using data from the motion software driving the motion rig.

Limitations:

Contact

Feel free to join our Discord community or to send an e-mail to oxrmc@mailbox.org for feedback and assistance.

You can find the source code and the latest release or report issues on github.

If you are (or know someone) willing and able to support the software development (mostly C++, maybe some GUI stuff later on) side of the project, feel free to contact @BuzzteeBear on the Discord server to ask about ways to contribute.

Donations to the project are very welcome and can be made via Paypal.
You can also sponsor the project via GitHub Sponsors

Special Thanks

Code Signing Policy

Installation

Run installer executable

Just double-click the installation executable called Install_OpenXR-MotionCompensation_<current_version>.exe and follow the instructions. A few hints regarding the installation process:

Conflict with other OpenXR API layers

There may be issues with other OpenXR API layers that are installed on your system. For the most part they can be solved by using the correct order of installation (because that implicitly determines the order in which the layers are loaded). You can use the folowing tool to examine (and potentially change) layer order and/or deactivate some layers for debugging: OpenXR-API-Layers-GUI
According to user feedback following constraints seem to be working:

If you encounter any additional layer ordering constraints, please feel free to reach out to the oxrmc developer with that information.

Optional: Confirm correct installation

You can use the application OpenXR Explorer to verify the correct installation:

Update

To get OXRMC updated, download and run the latest installation executable from Github. If you want to change the installation directory you have to uninstall the previous version first.

Uninstall

To remove the OpenXR-MotionCompensation layer just use windows settings/control panel as you would do with any other application. During de-installation you can choose to delete your configuration and log files in the appdata directory or to keep them for later use.

Configuration

Configuration files can be found at ...\Users\*<Your_Username>*\AppData\Local\OpenXR-MotionCompensation\OpenXR-MotionCompensation.log. After initial installation this directory contains the default configuration file OpenXR-MotionCompensation.ini. You can make changes to that file to configure settings you want to be the same for all OpenXR applications. Upon starting an OpenXR application with the API layer active for the first time, a configuration file named after the application is created in the same directory. You can use it to copy (partial) sections from the default configuration file whenever you want to make changes only for that application specifically.

Use of the Configuration file

What you can modify in a configuration file:

Sections in configuration file

Using a virtual tracker

To use a virtual tracker (as opposed to a physical device) set parameter tracker_type according to the motion software that is providing the data for motion compensation on your system:

You can find video tutorials on virtual tracker setup by MotionXP and SimHanger on YouTube.

Calibrating virtual tracker

To enable OXRMC to correlate translation and rotation of the rig to the virtual space correctly when using a virtual tracker, you have to provide the information where the center of rotation (cor) of your motion rig is positioned and which way is forward. This can be done with the following steps:

  1. Calculate, measure or estimate the distance between your headset and the center of rotation of your motion rig in forward/backward, up/down and left/right direction (I was told most 6 dof rigs rotate around the bottom of the seat but your mileage may vary). If you're using a witmotion sensor, please keep in mind that cor position does not (necessarily) coincide with mounting position of the sensor.
  2. Enter the offset values in the config file
  3. Start the OpenXR application of your choice
  4. Bring your motion rig in neutral position
  5. Sit in your rig
  6. put your headset on and face forward (~ direction surge). Potential rotation of the hmd on roll and pitch axis is ignored for the calculation
  7. issue the calibration command by activating the calibrate shortcut. You can also do this implicitly by activating motion compensation if you haven't (re)calibrated since last loading of the configuration.
    • You can use the tracker marker of the graphical overlay and keyboard shortcuts (or the left motion controller, see further below) to adjust the cor position in-game. Make sure to calibrate the tracker first, because the marker tracker just rests at vr play-space origin beforehand. For in-game changes to survive application restart, you have to manually save the configuration.
    • If you're unable to locate the cor of your rig, try out the method described in the according troubleshooting section
    • You may have to invert some of the rotations/translations on output side to get them compensated properly. For new users it's strongly recommended to use some artificial telemetry (joystick input, sine wave generator, etc.) and testing one degree of freedom at at time
    • If you're using YawVR Game Engine you can also use the parameters Head Distance and Height in its Motion Compensation tab to specify the offset of the cor. Head distance is basically equal to offset_forward in the configration file. But note that the height parameter is measured upwards from the bottom of your play-space, so you'll need to have that setup correctly in order to use that feature.

Adjusting cor location using a motion controller

You can use (only) the left motion controller to move the cor position in virtual space. The virtual tracker has to be calibrated first. It is recommended to activate the graphical overlay (ctrl + d by default) to see the cor marker in game.

Running your application

  1. make sure your using OpenXR as runtime in the application you wish to use motion compensation with
  2. start application
  3. center the in-app view
  4. activate the motion controller you configured and mount it on your motion rig
  5. bring your motion rig to neutral position
  6. Reset the in-game view if necessary
  7. press the activate shortcut (CTRL + INSERT by default). This implicitly sets the neutral reference pose for the tracker
    • if necessary you can re-calibrate the tracker by pressing the calibrate shortcut (CTRL + DEL by default) while the motion rig is in neutral position
    • you can increase or decrease the filter strength of translational and rotational filters
    • you can modify the cor offset when currently using a virtual tracker
    • after modifying filter strength or cor offset for virtual tracker you can save your changes to the default configuration file
    • after modifying the config file(s) manually you can use the reload_config shortcut (CTRL + SHIFT + L by default) to restart the OXRMC software with the new values.

Graphical overlay

You can enable/disable the overlay using the toggle_overlay shortcut. It displays a marker in your headset view for:

Chroma Keyed Passthrough

You can use the toggle_overlay_passthrough shortcut to activate chroma keyed passthrough mode for the overlay. In this mode the marker(s) are displayed on a magenta colored canvas as background instead of the rendered game content. This allows you see the markers' positioning in the real world if your vr hmd (and runtime) support chroma keyed passthrough. This may be helpful when setting up/dialing in the cor position, or to compare tracking data coming from a motion controller or vive tracker with it's actual movement. Note that while th overlay is in passthrough mode, the magenta colored arrow is displayed in grey instead, to keep it from becoming (partially) transparent.

Connection Loss

OXRMC can detect whether a reference tracker isn't available anymore if:

After detecting a loss of connection a configurable timeout period is used (connection_timeout), allowing two possible outcomes:

Advanced Features

The following features are purely optional and only recommended for users already familiar with the basic funtionality of oxrmc.

Saving and reloading the cor location

This feature is relevant for using a virtual tracker only!
Once you're satisfied with the current setting, the current position and orientation of the cor can be saved to the (global = ctrl + shift + s or app-specific = ctrl + shift + a) config file. You can subsequently set the config key load_ref_pose_from_file to 1. This causes the cor position and orientation to be loaded from the config file when calibrating instead of being determined using the hmd position and the offset values.
Applications using OpenComposite usually operate in a different VR play-space than titles supporting native OpenXR. That's why cor position needs to be saved once for all native games and once for all games using OpenComposite.
Note that this functionality may not work with all HMD vendors. Setting up the play-space in the VR runtime of your hmd (before first use) might help to get this working correctly. Rumor has it that some HMDs need to be started/initialized at the exact same location for the play-space coordinates to be consistent in between uses.

Input stabilizer

This feature is considered experimental and may cause undefined behaviour!
In 'normal' operation mode the reference tracker pose is requested only once per frame. Enabling the input stabilizer feature increases the temporal resolution to approximately 600 samplesa per second, optimizing the ability to filter out noise from the input signal.

Pose modifier

This feature is considered experimental and may conflict with other oxrmc functionality!
If you don't want the motion compensation effect to reflect the movement of the reference tracker exactly one to one, you can use this feature to increase or decrease it on one or more degrees of freedom. This is done under following constraints:

Note that using compensation factors will mess up the tracker marker in the graphical overlay. Instead of the 'real' tracker position the 'effective' tracker position (the one that corresponds to the actual compensation effect) will be displayed.

Troubleshooting

Upon activating any shortcut you get audible feedback, corresponding to the performed action (or an error, if something went wrong). If you're getting 'error' or no feedback at all, check for error entries (search for keyword 'error') in the log file at ...\Users\\AppData\Local\OpenXR-MotionCompensation\OpenXR-MotionCompensation.log.

Re-centering in-game view

If you recenter the in-app view during a session the reference pose is reset by default. Therefore you should only do that while your motion rig is in neutral position. It is possible (depending on the application) that this automatic recalibration is not triggered, causing the view and reference pose to be out of sync and leading to erroneous motion compensation. You should do the following steps to get this corrected again:

  1. deactivate motion compensation by pressing the activate shortcut
  2. bring your motion rig to neutral position. Face forward if you using a virtual tracker
  3. re-calibrate by pressing the calibrate shortcut
  4. reactivate motion compensation by pressing the activate shortcut

Virtual tracker

When using a virtual tracker and the audible feedback says 'motion compensation activated' but you don't get motion compensation as you would expect Use the MmfReader App to make sure oxrmc is actually receiving data from the motion software.

Physical tracker

You can always request help on the Discord server

Additional Notes

MMF Reader

The software package includes a small app called MMF Reader which allows you to display the content of the memory mapped file used for virtual trackers. Just execute it from windows start menu or use the executable in the installation directory and select the kind of tracker you're using from the dropdown menu.

Logging

The motion compensation layers logs rudimentary information and errors in a text file located at ...\Users\\AppData\Local\OpenXR-MotionCompensation\OpenXR-MotionCompensation.log. After unexpected behavior or a crash you can check that file for abnormalities or error reports.

If you encounter repeatable bugs or crashes you can use the Windows Performance Recorder Profile (WPRP) trace-logging in combination with the configuration contained within scripts\Trace_OpenXR-MotionCompensation.wprp to create a more detailed protocol.

Trace-logging can become very useful to investigate user issues.

To capture a trace for the API layer:

You can send the trace file to the developer or use an application such as Tabnalysis to inspect the content yourself.

Recording

Starting a recording session (via keyboard shortcut toggle_recording) results in the internal tracker values to be written into a comma separated file named recording_XXX_.csv file where XXX is a timestamp relating to the start time of recording. The content of this file can easily be loaded into excel (or similar software) to generate plots and search for erroneous data. Note that values are only recorded after the reference tracker is calibrated. The first line of the file contains the labels for the corresponding columns with:

If the maximum size of the recording file is exceesed before the recording is stopped, a new file is created and used for recording subsequent values. This is accompanied by the same audible feedback that signals a regular start of recording.

List of keyboard bindings

To combine multiple keys for a single shortcut they need to be separated by '+' with no spaces in between the key descriptors.

List of supported shortcut key names:

Name Key
NONE don't assign any keys (cannot be combined with other keys)
SHIFT shift key
CTRL control key
ALT alt key
LSHIFT left shift key
RSHIFT right shift key
LCTRL left control key
RCTRL right control key
LALT left alt key
RALT right alt key
0- 9 numerical key
A- Z alphabetical key
BACKQUOTE `~ key (US)
TAB tabulator key
CAPS caps lock key
PLUS + key (any country)
MINUS - key (any country)
OPENBRACKET [{ key (US)
CLOSEBRACKET ]} key (US)
SEMICOLON ;: key (US)
QUOTE '" key (US)
BACKSLASH \| key (US)
COMMA , key (any country)
PERIOD . key (any country)
SLASH /? key (US)
BACK backspace key
CLR clear key
RETURN return key
ESC escape key
SPACE space key
LEFT cursor left key
UP cursor up key
RIGHT cursor right key
DOWN cursor down key
INS insert key
DEL delete key
HOME home key
END end key
PGUP page up key
PGDN page down key
NUM0 0 key on NUM
NUM1 1 key on NUM
NUM2 2 key on NUM
NUM3 3 key on NUM
NUM4 4 key on NUM
NUM5 5 key on NUM
NUM6 6 key on NUM
NUM7 7 key on NUM
NUM8 8 key on NUM
NUM9 9 key on NUM
NUMLOCK numlock key
NUMDIVIDE / key on NUM
NUMMULTIPLY * key on NUM
NUMSUBTRACT - key on NUM
NUMADD + key on NUM
NUMDECIMAL . key on NUM
NUMSEPARATOR separator key on NUM
F1 F1 key
F2 F2 key
F3 F3 key
F4 F4 key
F5 F5 key
F6 F6 key
F7 F7 key
F8 F8 key
F9 F9 key
F10 F10 key
F11 F11 key
F12 F12 key
PRTSC print screen key
SCROLL scroll lock key
PAUSE pause key
SELECT select key
PRINT print key
HELP help key
EXEC execute key