42 static const auto MAX_ROWS = 1000;
 
   43 static std::size_t g_markRows = 0;
 
   44 static const auto MAX_SECONDS = 10;
 
   46 static const auto OUTFILE = 
"osvrdata.csv";
 
   48 using our_clock = std::chrono::system_clock;
 
   52 template <
typename T> 
inline bool shouldStop(T 
const &deadline) {
 
   53     return (g_csvOutput.
numDataRows() - g_markRows) > MAX_ROWS ||
 
   54            our_clock::now() > deadline;
 
   65 static void poseCallback(
void *userdata, 
const OSVR_TimeValue *timestamp,
 
   67     auto path = 
static_cast<char *
>(userdata);
 
   73         << 
cell(path + std::string{
":qx"},
 
   75         << 
cell(path + std::string{
":qy"},
 
   77         << 
cell(path + std::string{
":qz"},
 
   79         << 
cell(path + std::string{
":qw"},
 
   83 int main(
int argc, 
char *argv[]) {
 
   86     for (
int i = 1; i < argc; ++i) {
 
   88         std::cerr << 
"Setting up data output for " << path << std::endl;
 
   90         resource.registerCallback(&poseCallback, path);
 
   95         std::cerr << 
"Client context has not yet started up - waiting. Make " 
   96                      "sure the server is running." 
   99             std::this_thread::sleep_for(std::chrono::milliseconds(1));
 
  102         std::cerr << 
"OK, client context ready. Proceeding." << std::endl;
 
  104     std::cerr << 
"Will exit after " << MAX_ROWS << 
" rows of data or " 
  105               << MAX_SECONDS << 
" seconds of runtime, whichever comes first." 
  108     auto begin = our_clock::now();
 
  109     auto runTimeLimit = begin + std::chrono::seconds(MAX_SECONDS);
 
  112     } 
while (!shouldStop(runTimeLimit));
 
  114     std::cerr << 
"Writing " << g_csvOutput.
numDataRows() << 
" data rows to " 
  115               << OUTFILE << std::endl;
 
  117         std::ofstream outfile(OUTFILE, std::ios::out | std::ios::binary);
 
  118         g_csvOutput.
output(outfile);
 
  121     std::cerr << 
"Done!" << std::endl;
 
OSVR_PoseState pose
The pose structure, containing a position vector and a rotation quaternion. 
Client context object: Create and keep one in your application. Handles lifetime management and provi...
double osvrQuatGetY(OSVR_Quaternion const *q)
Accessor for quaternion component Y. 
bool checkStatus() const 
Checks to see if the client context is properly and fully started up. 
OSVR_Quaternion rotation
Orientation as a unit quaternion. 
double data[3]
Internal array data. 
void output(std::ostream &os) const 
Interface getInterface(const std::string &path)
Get the interface associated with the given path. 
double osvrQuatGetX(OSVR_Quaternion const *q)
Accessor for quaternion component X. 
Header providing a C++ wrapper around TimeValueC.h. 
std::size_t numDataRows() const 
int main(int argc, char *argv[])
void update()
Updates the state of the context - call regularly in your mainloop. 
OSVR_TimeValue_Microseconds microseconds
Microseconds portion of the time value. 
double osvrQuatGetW(OSVR_Quaternion const *q)
Accessor for quaternion component W. 
Header containing the inline implementation of Interface. 
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
double osvrQuatGetZ(OSVR_Quaternion const *q)
Accessor for quaternion component Z. 
OSVR_Vec3 translation
Position vector. 
detail::Cell< T > cell(const char *header, T const &data)
Helper free function to make a CSV cell. 
Report type for a pose (position and orientation) callback on a tracker interface. 
OSVR_TimeValue_Seconds seconds
Seconds portion of the time value.