Compare commits

..
5 Commits
Author SHA1 Message Date
Justin Li 958136a12c Create LICENSE 2018-06-23 17:44:52 -04:00
Justin Li 92c0e1a0af Remove X axis flip, not required by a standard configuration 2018-06-23 17:41:01 -04:00
Justin Li 963cd26e90 Add SteamVR setup instructions 2018-06-23 16:15:58 -04:00
Justin Li 91e0cd15e1 Fix typo 2018-06-23 14:45:19 -04:00
Justin Li e9f9c63768 Update video link 2018-06-23 14:03:52 -04:00
3 changed files with 70 additions and 28 deletions

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Justin Li
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+19 -20
View File
@@ -104,6 +104,22 @@ struct DSample
Eigen::Vector3d ref, target;
};
bool StartsWith(const std::string &str, const std::string &prefix)
{
if (str.length() < prefix.length())
return false;
return str.compare(0, prefix.length(), prefix) == 0;
}
bool EndsWith(const std::string &str, const std::string &suffix)
{
if (str.length() < suffix.length())
return false;
return str.compare(str.length() - suffix.length(), suffix.length(), suffix) == 0;
}
Eigen::Vector3d AxisFromRotationMatrix3(Eigen::Matrix3d rot)
{
return Eigen::Vector3d(rot(2,1) - rot(1,2), rot(0,2) - rot(2,0), rot(1,0) - rot(0,1));
@@ -136,22 +152,6 @@ DSample DeltaRotationSamples(Sample s1, Sample s2)
return ds;
}
bool StartsWith(const std::string &str, const std::string &prefix)
{
if (str.length() < prefix.length())
return false;
return str.compare(0, prefix.length(), prefix) == 0;
}
bool EndsWith(const std::string &str, const std::string &suffix)
{
if (str.length() < suffix.length())
return false;
return str.compare(str.length() - suffix.length(), suffix.length(), suffix) == 0;
}
Eigen::Vector3d CalibrateRotation(const std::vector<Sample> &samples)
{
std::vector<DSample> deltas;
@@ -165,7 +165,7 @@ Eigen::Vector3d CalibrateRotation(const std::vector<Sample> &samples)
deltas.push_back(delta);
}
}
printf("\ngot %zd samples with %zd delta samples\n", samples.size(), deltas.size());
printf("got %zd samples with %zd delta samples\n", samples.size(), deltas.size());
// Kabsch algorithm
@@ -205,7 +205,6 @@ Eigen::Vector3d CalibrateRotation(const std::vector<Sample> &samples)
rot.transposeInPlace();
Eigen::Vector3d euler = rot.eulerAngles(2, 1, 0) * 180.0 / EIGEN_PI;
euler[2] *= -1;
printf("rotation yaw=%.2f pitch=%.2f roll=%.2f\n", euler[1], euler[2], euler[0]);
return euler;
@@ -246,10 +245,9 @@ Eigen::Vector3d CalibrateTranslation(const std::vector<Sample> &samples)
}
Eigen::Vector3d trans = coefficients.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(constants);
trans(0) *= -1.0;
auto transcm = trans * 100.0;
printf("\ntranslation x=%.2f y=%.2f z=%.2f\n", transcm[0], transcm[1], transcm[2]);
printf("translation x=%.2f y=%.2f z=%.2f\n", transcm[0], transcm[1], transcm[2]);
return transcm;
}
@@ -498,6 +496,7 @@ void CalibrationTick()
if (samples.size() == totalSamples)
{
printf("\n");
if (ctx.state == Rotation)
{
ctx.calibratedRotation = CalibrateRotation(samples);
+30 -8
View File
@@ -2,10 +2,14 @@
Use VR devices from one company with any other.
This is **beta software** and may not work for you. A quick video demo is available at https://www.youtube.com/watch?v=Khzta0hgvrA
This is **beta software** and may not work for you. A quick video demo is available at https://www.youtube.com/watch?v=W3TnQd9JMl4
## Usage
### Calibration
If you don't already run a setup with multiple device types, see [Setting up SteamVR](#setting-up-steamvr).
0. Install [OpenVR-InputEmulator](https://github.com/matzman666/OpenVR-InputEmulator).
1. Download and unzip the [latest release](https://github.com/pushrax/OpenVR-SpaceCalibrator/releases) of OpenVR-SpaceCalibrator.
2. Run SteamVR, and turn on your Touch controllers and only one Vive device to use for calibration.
@@ -18,17 +22,35 @@ This is **beta software** and may not work for you. A quick video demo is availa
Next time you run SteamVR and OpenVR-InputEmulator it will load the calibration automatically and apply it to any Vive devices you turn on.
## Manually editing the calibration
### Setting up SteamVR
Every hardware designer with their own tracking system needs to make a "driver"
so SteamVR can see their tracking data. SteamVR by default will load only one driver at a time,
but we can tell it to load all of them by editing the vrsettings config file.
Open `steam\steamapps\common\SteamVR\resources\settings\default.vrsettings` in a text editor,
look for the line that has `"activateMultipleDrivers": false` and change the `false` to `true`.
In some guides online you may also see references to `requireHmd`, this does _not_ need to be changed
unless you truly want to be able to run without any kind of HMD.
Sometimes when SteamVR updates this file seems to get wiped, if your setup stops working you might
have to edit the config again.
Make sure to run room setup in your HMD's software (e.g. Oculus) and also in SteamVR.
An inaccurate room setup will make the automatic calibration inaccurate too.
### Manually editing the calibration
If you'd like to make a manual change to the calibration, the values are in `openvr_space_calibration.txt` in the same folder as the exe.
The first 4 numbers are the rotation (yaw, pitch, roll) in degrees, and the next 3 numbers are the translation (x, y, z) in centimeters.
The first 3 numbers are the rotation (yaw, pitch, roll) in degrees, and the next 3 numbers are the translation (x, y, z) in centimeters.
### Compiling your own build
1. Install boost 1.63 to `lib/boost_1_63_0` (required for IPC to OpenVR-InputEmulator). https://sourceforge.net/projects/boost/files/boost-binaries/1.63.0/
2. Open `OpenVR-SpaceCalibrator.sln` in Visual Studio 2015 and build.
## The math
See [math.pdf](https://github.com/pushrax/OpenVR-SpaceCalibrator/blob/master/math.pdf) for details.
If you have some ideas for how to improve the calibration process, let me know!
## Compiling your own build
1. Install boost 1.63 to `lib/boost_1_63_0` (required for IPC to OpenVR-InputEmulator). https://sourceforge.net/projects/boost/files/boost-binaries/1.63.0/
2. Open `OpenVR-SpaceCalibrator.sln` in Visual Studio 2015 and build.