VrpnTracker.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00027 
00028 #ifndef __VRPN_TRACKER_H_
00029 #define __VRPN_TRACKER_H_
00030 
00031 #define DEF_TRACK_DEV_NAME "object@192.168.0.100"
00032 
00033 #include <vrpn_Tracker.h>
00034 #include <time.h>
00035 #include <unistd.h>
00036 #include <string>
00037 
00038 using namespace std;
00039 
00040 class VrpnHandler{
00041  public:
00042   virtual void handleVrpnData()=0;
00043 };
00044 
00045 class VrpnTracker {
00046  friend void handleTrackerQuatPos(void *userdata, const vrpn_TRACKERCB t);
00047  
00048 private:
00049 
00050  static VrpnTracker* _instance;
00051  
00052  timespec   _request;
00053  timespec   _receive;
00054  clockid_t  _clockToUse;
00055  int     _requested;
00056  
00057  vrpn_Tracker_Remote _implementation;
00058  VrpnHandler*    _readHandler;
00059 
00060  VrpnTracker(string trackDevName);
00061  
00062  //FILE* _logFile;
00063  
00064 public:
00065  
00066  vrpn_TRACKERCB oldPos;
00067  vrpn_TRACKERCB currPos;
00068 
00069  static VrpnTracker* instance(string trackDevName = string(DEF_TRACK_DEV_NAME));
00070  
00071  virtual ~VrpnTracker();
00072 
00073  void mainloop ();
00074 
00075  void registerHandler(VrpnHandler* inst);
00076 
00077  static void multiplyMat (double matrix1[][3], double matrix2[][3], double matrix3[][3]);
00078  static void quat2Mat (double *in_quat, double matrix[][3]);
00079  static void matToEA(double matrix[][3], double *out_EA);
00080  static void quatToEA (vrpn_float64* in_quat, vrpn_float64* out_EA);
00081 
00082 };
00083 
00084 void handleTrackerQuatPos(void *userdata, const vrpn_TRACKERCB t);
00085 
00086 void* runTracking (void* tracker);
00087 
00088 #endif
00089 
00090 

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6