PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusPhidgetSpatialTracker.h
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #ifndef __vtkPlusPhidgetSpatialTracker_h
8 #define __vtkPlusPhidgetSpatialTracker_h
9 
10 #include "vtkPlusDataCollectionExport.h"
11 
12 #include "vtkPlusDevice.h"
13 
14 class AhrsAlgo;
15 
55 // Number of parameters required by CPhidgetSpatial_setCompassCorrectionParameters
56 #define PHIDGET_NUMBER_OF_COMPASS_CORRECTION_PARAMETERS 13
57 
58 class vtkPlusDataCollectionExport vtkPlusPhidgetSpatialTracker : public vtkPlusDevice
59 {
60 public:
61 
64  void PrintSelf( ostream& os, vtkIndent indent );
65 
66  virtual bool IsTracker() const { return true; }
67 
70 
73 
77  PlusStatus Probe();
78 
80  virtual PlusStatus ReadConfiguration(vtkXMLDataElement* config);
81 
83  virtual PlusStatus WriteConfiguration(vtkXMLDataElement* config);
84 
85  /*
86  * Override the default resettable behavior of the device
87  * because Phidget trackers can be reset
88  */
89  virtual bool IsResettable();
90 
94  virtual PlusStatus Reset();
95 
96  vtkSetMacro(ZeroGyroscopeOnConnect, bool);
97 
101  vtkSetMacro(SerialNumber, int);
102  vtkGetMacro(SerialNumber, int);
103 
104  friend class PhidgetSpatialCallbackClass;
105 
106 protected:
107 
110 
116 
119 
124  void ZeroGyroscope();
125 
126  vtkSetVector2Macro(AhrsAlgorithmGain, double);
127  vtkSetVector2Macro(FilteredTiltSensorAhrsAlgorithmGain, double);
128 
129  vtkSetVectorMacro(CompassCorrectionParameters, double, PHIDGET_NUMBER_OF_COMPASS_CORRECTION_PARAMETERS);
130 
132  bool IsCompassCorrectionParametersDefined();
133 
134 private: // Functions.
135 
137  void operator=( const vtkPlusPhidgetSpatialTracker& );
138 
139  //void Get3x3RotMatrixFromIMUQuat(double rotMatrix[3][3], AhrsAlgo* AhrsAlgo);
140 
141 private: // Variables.
142 
143  void* SpatialDeviceHandle;
144 
145  // Device-specific identifier that can be used to choose a particular device when multiple devices are connected
146  // If the default value (-1) is kept then it connects to the first available device.
147  int SerialNumber;
148 
149  unsigned int FrameNumber;
150  double TrackerTimeToSystemTimeSec; // time_System = time_Tracker + TrackerTimeToSystemTimeSec
151  bool TrackerTimeToSystemTimeComputed; // the time offset is always computed when the first frame is received after start tracking
152 
153  vtkMatrix4x4* LastAccelerometerToTrackerTransform;
154  vtkMatrix4x4* LastGyroscopeToTrackerTransform;
155  vtkMatrix4x4* LastMagnetometerToTrackerTransform;
156  vtkMatrix4x4* LastTiltSensorToTrackerTransform;
157  vtkMatrix4x4* LastFilteredTiltSensorToTrackerTransform;
158  vtkMatrix4x4* LastOrientationSensorToTrackerTransform;
159 
160  vtkPlusDataSource* AccelerometerTool;
161  vtkPlusDataSource* GyroscopeTool;
162  vtkPlusDataSource* MagnetometerTool;
163  vtkPlusDataSource* TiltSensorTool;
164  vtkPlusDataSource* FilteredTiltSensorTool;
165  vtkPlusDataSource* OrientationSensorTool;
166 
167  enum AHRS_METHOD
168  {
169  AHRS_MADGWICK,
170  AHRS_MAHONY
171  };
172 
173  AhrsAlgo* FilteredTiltSensorAhrsAlgo;
174 
175  AhrsAlgo* AhrsAlgo;
176 
182  bool AhrsUseMagnetometer;
183 
188  double AhrsAlgorithmGain[2];
189  double FilteredTiltSensorAhrsAlgorithmGain[2];
190 
192  double AhrsLastUpdateTime;
193  double FilteredTiltSensorAhrsLastUpdateTime;
194 
203  int TiltSensorWestAxisIndex;
204  int FilteredTiltSensorWestAxisIndex;
205 
207  bool ZeroGyroscopeOnConnect;
208 
210  double CompassCorrectionParameters[PHIDGET_NUMBER_OF_COMPASS_CORRECTION_PARAMETERS];
211 };
212 
213 #endif
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual PlusStatus InternalStopRecording()
Abstract interface for tracker and video devices.
Definition: vtkPlusDevice.h:60
virtual PlusStatus InternalConnect()
igsioStatus PlusStatus
Definition: PlusCommon.h:40
#define PHIDGET_NUMBER_OF_COMPASS_CORRECTION_PARAMETERS
virtual PlusStatus Probe()
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *)
virtual PlusStatus Reset()
unsigned long FrameNumber
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *)
virtual PlusStatus InternalStartRecording()
Interface for the Phidget 3/3/3 tracker.
virtual PlusStatus InternalDisconnect()
virtual bool IsResettable()
static vtkPlusDevice * New()
Interface to a 3D positioning tool, video source, or generalized data stream.