26 #include <FPExceptionEnabler.h>
36 #include <json/value.h>
37 #include <json/reader.h>
46 static const auto IMU_PATH =
47 "/com_osvr_Multiserver/OSVRHackerDevKit0/semantic/hmd";
48 static const auto VIDEO_PATH =
49 "/com_osvr_VideoBasedHMDTracker/TrackedCamera0_0/semantic/hmd/front";
50 void processReports(Json::Value
const &log) {
52 auto reportNumber = std::size_t{0};
53 bool gotRunning =
false;
54 auto firstRunningReport = std::size_t{0};
57 for (
auto &report : log) {
58 std::cout <<
"\n***********************\nReport #" << reportNumber;
60 std::cout <<
" (report #" << (reportNumber - firstRunningReport)
61 <<
" in running state)";
63 auto timestamp = osvr::common::timevalueFromJson(report[
"timestamp"]);
64 Eigen::Quaterniond quat =
65 osvr::common::quatFromJson(report[
"rotation"]);
66 auto &path = report[
"path"];
67 if (path == IMU_PATH) {
68 std::cout <<
" - IMU" << std::endl;
72 }
else if (path == VIDEO_PATH) {
73 std::cout <<
" - Video-based tracker" << std::endl;
76 osvr::common::vec3FromJson(report[
"translation"]);
78 if (fusion.running()) {
83 <<
"Video data before IMU data, skipping this one."
91 std::cerr <<
"Unrecognized path: " << path.toStyledString()
93 throw std::runtime_error(
"Unrecognized path: " +
94 path.toStyledString());
96 if (fusion.running()) {
99 firstRunningReport = reportNumber;
100 std::cout <<
"---- Fusion just switched to running state!"
103 std::cout <<
"Error Covariance:\n"
106 std::cout << std::flush;
107 std::cerr << std::flush
108 <<
"Got a negative variance (diagonal of state "
109 "covariance matrix) - bailing out!"
111 throw std::runtime_error(
"Negative variance!");
117 int main(
int argc,
char *argv[]) {
119 std::cerr <<
"Must pass the path to the input file!" << std::endl;
124 auto fn = std::string{argv[1]};
125 std::ifstream dataFile(fn);
127 std::cerr <<
"Couldn't open data file '" << fn <<
"''" << std::endl;
131 if (!reader.parse(dataFile, log)) {
132 std::cerr <<
"Couldn't parse data file '" << fn
133 <<
"' as JSON! Error(s): "
134 << reader.getFormattedErrorMessages() << std::endl;
140 }
catch (std::exception
const &e) {
141 std::cerr <<
"Exception: " << e.what() << std::endl;
144 std::cout <<
"Reached end of log!" << std::endl;
OSVR_PoseState pose
The pose structure, containing a position vector and a rotation quaternion.
void handleVideoTrackerDataWhileRunning(const OSVR_TimeValue ×tamp, const OSVR_PoseReport &report)
Eigen::Matrix< double, 12, 12 > const & getErrorCovariance() const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW void handleIMUData(const OSVR_TimeValue ×tamp, const OSVR_OrientationReport &report)
Eigen::Map< Eigen::Vector3d > translation() const
void handleVideoTrackerDataDuringStartup(const OSVR_TimeValue ×tamp, const OSVR_PoseReport &report, const OSVR_OrientationState &orientation)
Report type for an orientation callback on a tracker interface.
Header for interoperation between the Eigen math library, the internal mini math library, and VRPN's quatlib.
OSVR_OrientationState rotation
The rotation unit quaternion.
Report type for a pose (position and orientation) callback on a tracker interface.