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); 
00033 
00034             
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
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