| 72 | } |
| 73 | |
| 74 | Eigen::AngleAxisd getRotation(const char name[], ClientMainloopThread &client, |
| 75 | osvr::clientkit::Interface &iface) { |
| 76 | cout << "\n\n--- " << name << "---" << endl; |
| 77 | cout << "Current rotation: " << name << " - please see the image file for " |
| 78 | "desired axis and direction of " |
| 79 | "rotation." << endl; |
| 80 | cout << "Once you're ready, put your device in a level, forward-looking " |
| 81 | "orientation, then press enter." << endl; |
| 82 | std::cin.ignore(); |
| 83 | Eigen::Quaterniond initial; |
| 84 | Eigen::Quaterniond current; |
| 85 | { |
| 86 | ClientMainloopThread::lock_type lock(client.getMutex()); |
| 87 | initial = getOrientationState(iface); |
| 88 | cout << "Initial axes:" << endl; |
| 89 | cout << " - sensor X points " |
| 90 | << (initial * Eigen::Vector3d::UnitX()).transpose() << endl; |
| 91 | cout << " - sensor Y points " |
| 92 | << (initial * Eigen::Vector3d::UnitY()).transpose() << endl; |
| 93 | cout << " - sensor Z points " |
| 94 | << (initial * Eigen::Vector3d::UnitZ()).transpose() << endl; |
| 95 | cout << endl; |
| 96 | cout << "Now, please rotate the device as shown in the image. " << endl; |
| 97 | cout << "Keep rotating"; |
| 98 | double absRads = 0; |
| 99 | int dots = 0; |
| 100 | do { |
| 101 | client.oneLoop(); |
| 102 | current = getOrientationState(iface); |
| 103 | absRads = current.angularDistance(initial); |
| 104 | int currentDots = (absRads / minAbsRadians) * totalDots; |
| 105 | while (dots < currentDots) { |
| 106 | cout << "."; |
| 107 | dots++; |
| 108 | } |
| 109 | } while (absRads < minAbsRadians); |
| 110 | } |
| 111 | cout << " OK!" << endl; |
| 112 | auto relative = initial.conjugate() * current; |
| 113 | auto angleAxis = Eigen::AngleAxisd(relative); |
| 114 | cout << " - " << name << " - Rotated " << angleAxis.angle() |
| 115 | << " radians about " << angleAxis.axis().transpose() << "\n" << endl; |
| 116 | return angleAxis; |
| 117 | } |
| 118 | |
| 119 | int main(int argc, char *argv[]) { |
| 120 | namespace po = boost::program_options; |
no test coverage detected