MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNDITrackingDevice.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13
14#ifndef mitkNDITrackingDevice_h
15#define mitkNDITrackingDevice_h
16
17#include "mitkTrackingDevice.h"
18
19#include <MitkIGTExports.h>
20#include <thread>
21#include <mutex>
22#include <vector>
23
24#include "mitkNDIProtocol.h"
25#include "mitkNDIPassiveTool.h"
27
28
29namespace mitk
30{
31 class NDIProtocol;
32
40 class MITKIGT_EXPORT NDITrackingDevice : public TrackingDevice
41 {
42 friend class NDIProtocol;
43
44 public:
45 typedef std::vector<NDIPassiveTool::Pointer> Tool6DContainerType;
46
55
59
63 //itkSetMacro(Type, TrackingDeviceType);
64
65
78 bool OpenConnection() override;
79
85 bool CloseConnection() override;
86
88 bool InitializeWiredTools();
89
93 void SetRotationMode(RotationMode r) override;
94
102 virtual mitk::TrackingDeviceType TestConnection();
103
113 bool DiscoverWiredTools();
114
123 bool StartTracking() override;
124
128 TrackingTool* GetTool(unsigned int toolNumber) const override;
129
130 mitk::TrackingTool* GetToolByName(std::string name) const override;
134 unsigned int GetToolCount() const override;
135
148 mitk::TrackingTool* AddTool(const char* toolName, const char* fileName, TrackingPriority p = NDIPassiveTool::Dynamic);
149
155 virtual bool RemoveTool(TrackingTool* tool);
156
160 virtual bool UpdateTool(mitk::TrackingTool* tool);
161
162 virtual void SetPortNumber(const PortNumber _arg);
164 virtual void SetDeviceName(std::string _arg);
165 itkGetStringMacro(DeviceName);
166 virtual void SetBaudRate(const BaudRate _arg);
168 virtual void SetDataBits(const DataBits _arg);
170 virtual void SetParity(const Parity _arg);
172 virtual void SetStopBits(const StopBits _arg);
174 virtual void SetHardwareHandshake(const HardwareHandshake _arg);
176 virtual void SetIlluminationActivationRate(const IlluminationActivationRate _arg);
178 virtual void SetDataTransferMode(const DataTransferMode _arg);
180 virtual bool Beep(unsigned char count);
181
182 NDIErrorCode GetErrorCode(const std::string* input);
183
184 virtual bool SetOperationMode(OperationMode mode);
185 virtual OperationMode GetOperationMode();
186
190 virtual bool GetMarkerPositions(MarkerPointContainerType* markerpositions);
191
196 virtual int GetMajorFirmwareRevisionNumber();
197
202 virtual const char* GetFirmwareRevisionNumber();
203
205 bool AutoDetectToolsAvailable() override;
206
208 bool AddSingleToolIsAvailable() override;
209
214 mitk::NavigationToolStorage::Pointer AutoDetectTools() override;
215
216
217
218 protected:
219
220 typedef std::vector<std::string> NDITrackingVolumeContainerType;
221 typedef std::vector<int> TrackingVolumeDimensionType;
222
228 virtual bool GetSupportedVolumes(unsigned int* numberOfVolumes, NDITrackingVolumeContainerType* volumes, TrackingVolumeDimensionType* volumesDimensions);
229
234 virtual bool SetVolume(mitk::TrackingDeviceData volume);
235
241 virtual bool InternalAddTool(NDIPassiveTool* tool);
242
243 /* Methods for NDIProtocol friend class */
244 virtual void InvalidateAll();
245 NDIPassiveTool* GetInternalTool(std::string portHandle);
246
257 NDIErrorCode FreePortHandles();
258
259 NDIErrorCode Send(const std::string* message, bool addCRC = true);
260 NDIErrorCode Receive(std::string* answer, unsigned int numberOfBytes);
261 NDIErrorCode ReceiveByte(char* answer);
262 NDIErrorCode ReceiveLine(std::string* answer);
263 void ClearSendBuffer();
264 void ClearReceiveBuffer();
265 const std::string CalcCRC(const std::string* input);
266
267public:
268
277 virtual void TrackTools();
278
286 virtual void TrackMarkerPositions();
287
295 virtual void TrackToolsAndMarkers();
296
300 void ThreadStartTracking();
301
302 protected:
304 ~NDITrackingDevice() override;
305
306 std::string m_DeviceName;
317
318 mutable std::mutex m_ToolsMutex;
319 mitk::SerialCommunication::Pointer m_SerialCommunication;
321 NDIProtocol::Pointer m_DeviceProtocol;
322
323 std::thread m_Thread;
327 };
328} // namespace mitk
329#endif
Implementation of a passive NDI optical tool.
TrackingPriority
tracking priority for NDI tracking devices
The NDI Protocol class provides building and parsing of command strings and answers to and from a NDI...
superclass for specific NDI tracking Devices that use serial communication.
Tool6DContainerType m_6DTools
list of 6D tools
OperationMode m_OperationMode
tracking mode (6D tool tracking, 3D marker tracking,...)
PortNumber m_PortNumber
COM Port Number.
std::mutex m_MarkerPointsMutex
mutex for marker point data container
itkGetStringMacro(DeviceName)
returns the device name for serial communication
itkGetConstMacro(BaudRate, BaudRate)
returns the baud rate for serial communication
itkGetConstMacro(DataTransferMode, DataTransferMode)
returns the data transfer mode
mitk::TrackingDeviceType NDITrackingDeviceType
This enumeration includes the two types of NDI tracking devices (Polaris, Aurora).
itkGetConstMacro(HardwareHandshake, HardwareHandshake)
returns the hardware handshake setting
std::vector< NDIPassiveTool::Pointer > Tool6DContainerType
List of 6D tools of the correct type for this tracking device.
DataTransferMode m_DataTransferMode
use TX (text) or BX (binary) (
std::vector< int > TrackingVolumeDimensionType
List of the supported tracking volume dimensions.
std::mutex m_SerialCommunicationMutex
mutex for coordinated access of serial communication interface
std::mutex m_ToolsMutex
mutex for coordinated access of tool container
mitkClassMacro(NDITrackingDevice, TrackingDevice)
MarkerPointContainerType m_MarkerPoints
container for markers (3D point tracking mode)
NDIProtocol::Pointer m_DeviceProtocol
create and parse NDI protocol strings
mitk::SerialCommunication::Pointer m_SerialCommunication
serial communication interface
itkGetConstMacro(IlluminationActivationRate, IlluminationActivationRate)
returns the activation rate of IR illumator for polaris
mitk::SerialCommunication::HardwareHandshake HardwareHandshake
Hardware handshake mode of the serial connection.
HardwareHandshake m_HardwareHandshake
which tracking volume is currently used (if device supports multiple volumes) (
std::string m_DeviceName
Device Name.
mitk::NDIPassiveTool::TrackingPriority TrackingPriority
Tracking priority used for tracking a tool.
mitk::SerialCommunication::PortNumber PortNumber
Port number of the serial connection.
DataBits m_DataBits
Number of Data Bits per token.
mitk::SerialCommunication::Parity Parity
Parity mode used in the serial connection.
itkGetConstMacro(PortNumber, PortNumber)
returns the port number for serial communication
BaudRate m_BaudRate
COM Port Baud Rate.
itkGetConstMacro(StopBits, StopBits)
returns the number of stop bits
itkGetConstMacro(DataBits, DataBits)
returns the data bits for serial communication
std::vector< std::string > NDITrackingVolumeContainerType
vector of tracking volumes
std::thread m_Thread
ID of tracking thread.
mitk::SerialCommunication::StopBits StopBits
Number of stop bits used in the serial connection.
IlluminationActivationRate m_IlluminationActivationRate
update rate of IR illuminator for Polaris
Parity m_Parity
Parity mode for communication.
itkGetConstMacro(Parity, Parity)
returns the parity mode
NDIErrorCode GetErrorCode(const std::string *input)
returns the error code for a string that contains an error code in hexadecimal format
mitk::SerialCommunication::BaudRate BaudRate
Baud rate of the serial connection.
mitk::SerialCommunication::DataBits DataBits
Number of data bits used in the serial connection.
StopBits m_StopBits
number of stop bits per token
Interface for all Tracking Devices.
Interface for all Tracking Tools.
IGT Exceptions.
DataTransferMode
Data transfer mode for NDI tracking devices.
IlluminationActivationRate
activation rate of IR illuminator for NDI Polaris tracking device
std::vector< MarkerPointType > MarkerPointContainerType
std::string TrackingDeviceType
OperationMode
Error codes of NDI tracking devices.
NDIErrorCode
Error codes of NDI tracking devices.