Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/corelibs/tracking/test_isense.cc

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <unistd.h>
00003 #include <stdexcept>
00004 #include "intersenseorientation.hh"
00005 
00006 using namespace std;
00007 
00008 int main(int argc, char** argv) {
00009     long t = 1000000;
00010     for(int i = 1; i < argc; i++) {
00011         if(!strcmp(argv[i], "--flood") )
00012             t = 0;
00013         if(!strcmp(argv[i], "-t"))
00014             t = atoi(argv[++i]);
00015     }
00016 
00017     printf("Waiting %d microseconds between queries.\n", t);
00018 
00019     double p = 0, y = 0, r = 0;
00020     IntersenseOrientation* ori;
00021     try {
00022         ori = new IntersenseOrientation("/dev/isense", 115200);
00023     } catch(exception& e) {
00024         printf("Error connecting to tracker on /dev/isense at 115200 baud: %s\n", e.what());
00025     }
00026 
00027     while(1) {
00028         try {
00029             ori->getEulerAngles(&y, &p, &r);
00030         } catch(exception& e) {
00031             printf("Error: %s\n", e.what());
00032             usleep(250000); // sleep 1/4 second
00033 
00034             /*
00035             delete ori;
00036             ori = 0;
00037             while(!ori) {
00038                 usleep(t*2);
00039                 try {
00040                     printf("Reconnecting...\n");
00041                     ori = new IntersenseOrientation("/dev/isense", 115200);
00042                 } catch(exception& e) {
00043                     printf("Error connecting to tracker on /dev/isense at 115200 baud: %s\n", e.what());
00044                     ori = 0;
00045                 }
00046             }
00047             */
00048         }
00049         printf("Yaw=%.10f, Pitch=%.10f, Roll=%.10f\n", y, p, r);
00050         usleep(t);
00051     }
00052 
00053 }
00054 
00055 
00056 

Generated on Tue Aug 12 03:55:38 2003 for Interreality Project - VOS by doxygen 1.3.2