NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxIgstkTracker.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXIGSTKTRACKER_H_
13 #define CXIGSTKTRACKER_H_
14 
15 #include "org_custusx_core_tracking_system_igstk_Export.h"
16 
17 #include <QObject>
18 
19 #include <map>
20 #include <boost/shared_ptr.hpp>
21 #include <igstkLogger.h>
22 #include <igstkTracker.h>
23 #include <igstkPolarisTracker.h>
24 #include <igstkAuroraTracker.h>
25 #include <itkStdStreamLogOutput.h>
26 #ifdef WIN32
27 #include "igstkSerialCommunicationForWindows.h"
28 #else
29 #include "igstkSerialCommunicationForPosix.h"
30 #endif
31 #include "cxTracker.h"
32 #include "cxTool.h"
33 #include "cxDefinitions.h"
34 #include "cxForwardDeclarations.h"
35 #include "cxToolFileParser.h"
36 
37 namespace cx
38 {
45 class IgstkTool;
46 typedef boost::shared_ptr<IgstkTool> IgstkToolPtr;
47 typedef boost::weak_ptr<IgstkTool> IgstkToolWeakPtr;
48 
56 class org_custusx_core_tracking_system_igstk_EXPORT IgstkTracker: public Tracker
57 {
58 Q_OBJECT
59 public:
60 
61 #ifdef WIN32
62 
63  typedef igstk::SerialCommunicationForWindows CommunicationType;
64 #else
65 
66  typedef igstk::SerialCommunicationForPosix CommunicationType;
67 #endif
68  typedef igstk::Tracker TrackerType;
69  typedef igstk::PolarisTracker PolarisTrackerType;
70  typedef igstk::AuroraTracker AuroraTrackerType;
71 
72  /*only used for documentation purposes
73  enum TRACKING_SYSTEM
74  {
75  tsNONE, ///< Not specified
76  tsPOLARIS, ///< NDIs Polaris tracker
77  tsPOLARIS_SPECTRA, ///< NDIs Polaris Spectra tracker
78  tsPOLARIS_VICRA, ///< NDIs Polaris Vicra tracker
79  tsPOLARIS_CLASSIC, ///< NDIs Polaris Classic tracker
80  tsAURORA, ///< NDIs Aurora tracker
81  tsMICRON, ///< Claron Technologys Micron tracker
82  tsCOUNT
83  };*/
84 
85  /*only used for documentation purposes
86  TRACKER_INVALID_REQUEST, ///< internal state machine didn't accept the request
87  TRACKER_OPEN, ///< hardware accepted the tracker as open
88  TRACKER_INITIALIZED, ///< hardware accepted the tracker as initialized
89  TRACKER_TRACKING, ///< tracker is tracking
90  TRACKER_UPDATE_STATUS, ///< tracker got an update event
91  TRACKER_TOOL_TRANSFORM_UPDATED, ///< a tool attached to the tracker got a new transform
92  TRACKER_COMMUNICATION_COMPLETE, ///< communication port completed a task successfully
93  TRACKER_COMMUNICATION_INPUT_OUTPUT_ERROR, ///< communication port failed at completing a task
94  TRACKER_COMMUNICATION_INPUT_OUTPUT_TIMEOUT, ///< communication port timed out
95  TRACKER_COMMUNICATION_OPEN_PORT_ERROR ///< communication port tried to open or close
96  */
97 
99  ~IgstkTracker();
100 
101  TRACKING_SYSTEM getType() const;
102  QString getName() const;
103  QString getUid() const;
104  TrackerType* getPointer() const;
105  void open();
106  void close();
107  void attachTools(std::map<QString, IgstkToolPtr> tools);
108  void detachTools(std::map<QString, IgstkToolPtr> tools);
109  void startTracking();
110  void stopTracking();
111 
112  bool isValid() const;
113  bool isOpen() const;
114  bool isInitialized() const;
115  bool isTracking() const;
116 
117 signals:
118  void initialized(bool);
119  void open(bool);
120  void tracking(bool);
121  void error();
122 
123 protected:
124  typedef itk::ReceptorMemberCommand<IgstkTracker> ObserverType;
125 
126  void trackerTransformCallback(const itk::EventObject &eventVar);
127  void addLogging();
128 
129  void internalOpen(bool value);
130  void internalInitialized(bool value);
131  void internalTracking(bool value);
132  void internalError(bool value);
133 
134  void shutdown();
135 
137  bool mValid;
138  QString mUid;
139  QString mName;
141 
142  PolarisTrackerType::Pointer mTempPolarisTracker;
143  AuroraTrackerType::Pointer mTempAuroraTracker;
144 
145  CommunicationType::Pointer mCommunication;
146  ObserverType::Pointer mTrackerObserver;
147  igstk::Logger::Pointer mTrackerLogger;
148  itk::StdStreamLogOutput::Pointer mTrackerLogOutput;
149 
150  bool mOpen;
152  bool mTracking;
153 
154 private:
155  IgstkTracker() {}
156 };
157 typedef boost::shared_ptr<IgstkTracker> TrackerPtr;
158 typedef boost::weak_ptr<IgstkTracker> TrackerWeakPtr;
159 
163 } //namespace cx
164 
165 #endif /* CXIGSTKTRACKER_H_ */
cx::Tracker
Definition: cxTracker.h:23
cx::IgstkTracker::mValid
bool mValid
whether this tracker is constructed correctly or not
Definition: cxIgstkTracker.h:137
cx::IgstkTracker::PolarisTrackerType
igstk::PolarisTracker PolarisTrackerType
Definition: cxIgstkTracker.h:69
cx::IgstkToolWeakPtr
boost::weak_ptr< IgstkTool > IgstkToolWeakPtr
Definition: cxIgstkTool.h:42
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::IgstkToolPtr
boost::shared_ptr< class IgstkTool > IgstkToolPtr
Definition: cxOpenIGTLinkTool.h:35
cxForwardDeclarations.h
cx::IgstkTracker::mCommunication
CommunicationType::Pointer mCommunication
pointer to the serial communication used to communicate with the NDI trackers
Definition: cxIgstkTracker.h:145
cxDefinitions.h
cxTracker.h
cx::IgstkTracker::mTempPolarisTracker
PolarisTrackerType::Pointer mTempPolarisTracker
pointer to a temp polaris tracker
Definition: cxIgstkTracker.h:142
cx::IgstkTracker::ObserverType
itk::ReceptorMemberCommand< IgstkTracker > ObserverType
Definition: cxIgstkTracker.h:124
cx::TrackerPtr
boost::shared_ptr< IgstkTracker > TrackerPtr
Definition: cxIgstkTracker.h:157
cx::IgstkTracker::mTrackerLogOutput
itk::StdStreamLogOutput::Pointer mTrackerLogOutput
output to write the log to
Definition: cxIgstkTracker.h:148
cxToolFileParser.h
cxTool.h
cx::IgstkTracker::mName
QString mName
the trackers name
Definition: cxIgstkTracker.h:139
cx::IgstkTracker
Class representing the navigation system.
Definition: cxIgstkTracker.h:56
cx::IgstkTracker::mInitialized
bool mInitialized
whether or not the tracker is initialized
Definition: cxIgstkTracker.h:151
cx::IgstkTracker::mTracker
TrackerType * mTracker
pointer to the base class of the internal igstk tracker
Definition: cxIgstkTracker.h:140
cx::IgstkTracker::mUid
QString mUid
the trackers unique id
Definition: cxIgstkTracker.h:138
cx::ToolFileParser::TrackerInternalStructure
Definition: cxToolFileParser.h:37
cx::IgstkTracker::mInternalStructure
ToolFileParser::TrackerInternalStructure mInternalStructure
the trackers type
Definition: cxIgstkTracker.h:136
cx::IgstkTracker::CommunicationType
igstk::SerialCommunicationForPosix CommunicationType
Definition: cxIgstkTracker.h:66
cx::IgstkTracker::TrackerType
igstk::Tracker TrackerType
Definition: cxIgstkTracker.h:68
cx::IgstkTracker::mTrackerObserver
ObserverType::Pointer mTrackerObserver
observer listening for igstk events
Definition: cxIgstkTracker.h:146
cx::IgstkTracker::mTempAuroraTracker
AuroraTrackerType::Pointer mTempAuroraTracker
pointer to a temp aurora tracker
Definition: cxIgstkTracker.h:143
cx::TrackerWeakPtr
boost::weak_ptr< IgstkTracker > TrackerWeakPtr
Definition: cxIgstkTracker.h:158
cx::IgstkTracker::mOpen
bool mOpen
whether or not the tracker is open
Definition: cxIgstkTracker.h:150
cx::IgstkTracker::mTrackerLogger
igstk::Logger::Pointer mTrackerLogger
logging the internal igstk behavior
Definition: cxIgstkTracker.h:147
cx::IgstkTracker::AuroraTrackerType
igstk::AuroraTracker AuroraTrackerType
Definition: cxIgstkTracker.h:70
cx::IgstkTracker::mTracking
bool mTracking
whether or not the tracker is tracking
Definition: cxIgstkTracker.h:152