Medical Imaging Interaction Toolkit  2018.4.99-18ddd2ed
Medical Imaging Interaction Toolkit
mitk::PolhemusTrackingDevice Class Reference

An object of this class represents Polhemus tracking device. You can add tools to this device, then open the connection and start tracking. The tracking device will then continuously update the tool coordinates. The tools which are used by Polhemus need to be connected to the correct port. The port of the tool is stored as m_ToolPort in PolhemusTool AND as identifier in the NavigationTool (ToolStorage). More...

#include <mitkPolhemusTrackingDevice.h>

Inheritance diagram for mitk::PolhemusTrackingDevice:
Collaboration diagram for mitk::PolhemusTrackingDevice:

Public Member Functions

 mitkClassMacro (PolhemusTrackingDevice, TrackingDevice)
 
Pointer Clone () const
 
virtual bool StartTracking () override
 Starts the tracking. More...
 
virtual bool StopTracking () override
 Stops the tracking. More...
 
virtual bool OpenConnection () override
 Opens the connection to the device. This have to be done before the tracking is started. More...
 
virtual bool CloseConnection () override
 Closes the connection and clears all resources. More...
 
virtual unsigned int GetToolCount () const override
 
TrackingToolGetTool (unsigned int toolNumber) const override
 
mitk::TrackingToolAddTool (const char *toolName, int toolPort)
 Create a new Polhemus tool with toolName and add it to the list of tools. More...
 
bool IsDeviceInstalled ()
 
virtual bool AutoDetectToolsAvailable ()
 
virtual mitk::NavigationToolStorage::Pointer AutoDetectTools ()
 
void SetHemisphereTrackingEnabled (bool _HemisphereTrackingEnabled)
 
bool GetHemisphereTrackingEnabled (int _tool)
 
void ToggleHemisphere (int _tool=-1)
 
void SetHemisphere (int _tool, mitk::Vector3D _hemisphere)
 
mitk::Vector3D GetHemisphere (int _tool)
 
void AdjustHemisphere (int _tool)
 
- Public Member Functions inherited from mitk::TrackingDevice
 mitkClassMacroItkParent (TrackingDevice, itk::Object)
 
virtual mitk::TrackingToolGetToolByName (std::string name) const
 Returns the tool with the given tool name. More...
 
virtual void SetRotationMode (RotationMode r)
 
virtual RotationMode GetRotationMode () const
 
TrackingDeviceState GetState () const
 return current object state (Setup, Ready or Tracking) More...
 
TrackingDeviceType GetType () const
 Deprecated! Use the more specific getData or GetTrackingDeviceName instead. return device type identifier. More...
 
void SetType (TrackingDeviceType type)
 Deprecated! Use the more specific setDeviceData instead. set device type. More...
 
std::string GetTrackingDeviceName ()
 Convenient Method to get the Name of the Tracking Device. This is identical with GetData().Line and can be used to compare with TrackingDeviceTypeInformation::GetTrackingDeviceName() to check if you have a specific device. More...
 
TrackingDeviceData GetData () const
 return device data More...
 
void SetData (TrackingDeviceData data)
 set device type More...
 
virtual bool AddSingleToolIsAvailable ()
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 PolhemusTrackingDevice ()
 
 ~PolhemusTrackingDevice ()
 
bool InternalAddTool (PolhemusTool::Pointer tool)
 Adds a tool to the tracking device. More...
 
void TrackTools ()
 This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means grabbing frames from the camera an updating the tools. More...
 
std::vector< PolhemusTool::Pointer > GetAllTools ()
 
PolhemusInterfaceGetDevice ()
 
- Protected Member Functions inherited from mitk::TrackingDevice
void SetState (TrackingDeviceState state)
 change object state More...
 
 TrackingDevice ()
 
 ~TrackingDevice () override
 

Static Protected Member Functions

static ITK_THREAD_RETURN_TYPE ThreadStartTracking (void *data)
 

Protected Attributes

std::vector< PolhemusTool::Pointer > m_AllTools
 vector holding all tools More...
 
PolhemusInterface::Pointer m_Device
 represents the interface to the tracking hardware More...
 
itk::MultiThreader::Pointer m_MultiThreader
 
int m_ThreadID
 
bool m_HemisphereTrackingEnabled
 
- Protected Attributes inherited from mitk::TrackingDevice
TrackingDeviceData m_Data
 current device Data More...
 
bool m_StopTracking
 signal stop to tracking thread More...
 
itk::FastMutexLock::Pointer m_StopTrackingMutex
 mutex to control access to m_StopTracking More...
 
itk::FastMutexLock::Pointer m_TrackingFinishedMutex
 mutex to manage control flow of StopTracking() More...
 
itk::FastMutexLock::Pointer m_StateMutex
 mutex to control access to m_State More...
 
RotationMode m_RotationMode
 defines the rotation mode Standard or Transposed, Standard is default More...
 

Additional Inherited Members

- Public Types inherited from mitk::TrackingDevice
enum  RotationMode { RotationStandard, RotationTransposed }
 
enum  TrackingDeviceState { Setup, Ready, Tracking }
 

Detailed Description

An object of this class represents Polhemus tracking device. You can add tools to this device, then open the connection and start tracking. The tracking device will then continuously update the tool coordinates. The tools which are used by Polhemus need to be connected to the correct port. The port of the tool is stored as m_ToolPort in PolhemusTool AND as identifier in the NavigationTool (ToolStorage).

Documentation:

Definition at line 33 of file mitkPolhemusTrackingDevice.h.

Constructor & Destructor Documentation

◆ PolhemusTrackingDevice()

◆ ~PolhemusTrackingDevice()

mitk::PolhemusTrackingDevice::~PolhemusTrackingDevice ( )
protected

Definition at line 36 of file mitkPolhemusTrackingDevice.cpp.

Member Function Documentation

◆ AddTool()

mitk::TrackingTool * mitk::PolhemusTrackingDevice::AddTool ( const char *  toolName,
int  toolPort 
)

Create a new Polhemus tool with toolName and add it to the list of tools.

This method will create a new PolhemusTool object, set the tool name toolName and then add it to the list of tools. It returns a pointer of type mitk::TrackingTool to the tool that can be used to read tracking data from it. This is the only way to add tools to PolhemusTrackingDevice.

Warning
adding tools is not possible in tracking mode, only in setup and ready.

Definition at line 45 of file mitkPolhemusTrackingDevice.cpp.

References InternalAddTool(), m_AllTools, MITK_DEBUG, and mitk::PolhemusTool::New().

◆ AdjustHemisphere()

void mitk::PolhemusTrackingDevice::AdjustHemisphere ( int  _tool)

Adjust the Hemisphere for this tool. User needs to make sure, that the tool is located in hemisphere (1|0|0) when calling this function. In contrast to SetHemisphere(1,0,0), this method restores the original HemisphereTracking settings at the end.

Definition at line 322 of file mitkPolhemusTrackingDevice.cpp.

References m_Device.

◆ AutoDetectTools()

mitk::NavigationToolStorage::Pointer mitk::PolhemusTrackingDevice::AutoDetectTools ( )
virtual

Autodetects tools from this device and returns them as a navigation tool storage.

Returns
Returns the detected tools. Returns an empty storage if no tools are present or if detection is not possible

Reimplemented from mitk::TrackingDevice.

Definition at line 262 of file mitkPolhemusTrackingDevice.cpp.

References mitk::PolhemusTrackerTypeInformation::GetDeviceDataPolhemusTrackerLiberty(), mitk::PolhemusInterface::trackingData::id, m_Device, MITK_INFO, mitk::NavigationTool::New(), and mitk::NavigationToolStorage::New().

◆ AutoDetectToolsAvailable()

bool mitk::PolhemusTrackingDevice::AutoDetectToolsAvailable ( )
virtual
Returns
Returns true if this device can autodetects its tools.

Reimplemented from mitk::TrackingDevice.

Definition at line 257 of file mitkPolhemusTrackingDevice.cpp.

◆ Clone()

Pointer mitk::PolhemusTrackingDevice::Clone ( ) const

◆ CloseConnection()

bool mitk::PolhemusTrackingDevice::CloseConnection ( )
overridevirtual

Closes the connection and clears all resources.

Implements mitk::TrackingDevice.

Definition at line 157 of file mitkPolhemusTrackingDevice.cpp.

References mitk::TrackingDevice::GetState(), m_Device, mitk::TrackingDevice::SetState(), and mitk::TrackingDevice::Setup.

Referenced by OpenConnection().

◆ GetAllTools()

std::vector< mitk::PolhemusTool::Pointer > mitk::PolhemusTrackingDevice::GetAllTools ( )
protected
Returns
Returns all tools of the tracking device.

Definition at line 174 of file mitkPolhemusTrackingDevice.cpp.

References m_AllTools.

Referenced by TrackTools().

◆ GetDevice()

mitk::PolhemusInterface * mitk::PolhemusTrackingDevice::GetDevice ( )
protected
Returns
Gives back the device which is represented by an object of the class PolhemusInterface.

Definition at line 169 of file mitkPolhemusTrackingDevice.cpp.

References m_Device.

Referenced by TrackTools().

◆ GetHemisphere()

mitk::Vector3D mitk::PolhemusTrackingDevice::GetHemisphere ( int  _tool)

Get the Hemisphere for _tool as mitk vector

Definition at line 312 of file mitkPolhemusTrackingDevice.cpp.

References m_Device.

◆ GetHemisphereTrackingEnabled()

bool mitk::PolhemusTrackingDevice::GetHemisphereTrackingEnabled ( int  _tool)

Is Hemisphere Tracking Enabled for this tool?

Definition at line 317 of file mitkPolhemusTrackingDevice.cpp.

References m_Device.

◆ GetTool()

mitk::TrackingTool * mitk::PolhemusTrackingDevice::GetTool ( unsigned int  toolNumber) const
overridevirtual
Parameters
toolNumberThe number of the tool which should be given back.
Returns
Returns the tool which the number "toolNumber". Returns NULL, if there is no tool with this number.

Implements mitk::TrackingDevice.

Definition at line 103 of file mitkPolhemusTrackingDevice.cpp.

References GetToolCount(), and m_AllTools.

◆ GetToolCount()

unsigned int mitk::PolhemusTrackingDevice::GetToolCount ( ) const
overridevirtual
Returns
Returns the number of tools which have been added to the device.

Implements mitk::TrackingDevice.

Definition at line 98 of file mitkPolhemusTrackingDevice.cpp.

References m_AllTools.

Referenced by GetTool(), and OpenConnection().

◆ InternalAddTool()

bool mitk::PolhemusTrackingDevice::InternalAddTool ( PolhemusTool::Pointer  tool)
protected

Adds a tool to the tracking device.

Parameters
toolThe tool which will be added.
Returns
Returns true if the tool has been added, false otherwise.

Definition at line 65 of file mitkPolhemusTrackingDevice.cpp.

References m_AllTools.

Referenced by AddTool().

◆ IsDeviceInstalled()

bool mitk::PolhemusTrackingDevice::IsDeviceInstalled ( )
virtual
Returns
Returns true if the device is installed on this system an can be used. Installed means activated in MITK, in some cases this means the MITK installation / build has to know the installation path of the device libraries on this system. This path is usually given as cmake variable during the build configuration in devellopers mode. If the device should be available for end users with an installer the libraries can be included into the installer or the installer has to be adapted such that it asks for the path. Returns fals if the device is not installed. It cannot be used on this build in this case.

Note that some tracking systems communicate via a standard interface (e.g., serial port) and don't need any library or installation. These devices are always "installed".

Reimplemented from mitk::TrackingDevice.

Definition at line 40 of file mitkPolhemusTrackingDevice.cpp.

◆ mitkClassMacro()

mitk::PolhemusTrackingDevice::mitkClassMacro ( PolhemusTrackingDevice  ,
TrackingDevice   
)

◆ New()

static Pointer mitk::PolhemusTrackingDevice::New ( )
static

◆ OpenConnection()

bool mitk::PolhemusTrackingDevice::OpenConnection ( )
overridevirtual

Opens the connection to the device. This have to be done before the tracking is started.

Exceptions
mitk::IGTHardwareExceptionThrows an exception if there is an error during open connection.

Implements mitk::TrackingDevice.

Definition at line 111 of file mitkPolhemusTrackingDevice.cpp.

References CloseConnection(), GetToolCount(), m_AllTools, m_Device, m_HemisphereTrackingEnabled, MITK_ERROR, mitk::PolhemusInterface::New(), mitk::TrackingDevice::Ready, and mitk::TrackingDevice::SetState().

◆ SetHemisphere()

void mitk::PolhemusTrackingDevice::SetHemisphere ( int  _tool,
mitk::Vector3D  _hemisphere 
)

Sets the Hemisphere of tool _tool to the vector _hemisphere

Definition at line 302 of file mitkPolhemusTrackingDevice.cpp.

References m_Device, and m_HemisphereTrackingEnabled.

◆ SetHemisphereTrackingEnabled()

void mitk::PolhemusTrackingDevice::SetHemisphereTrackingEnabled ( bool  _HemisphereTrackingEnabled)

Enables/disables hemisphere tracking for all sensors.

Definition at line 286 of file mitkPolhemusTrackingDevice.cpp.

References m_Device, and m_HemisphereTrackingEnabled.

◆ StartTracking()

bool mitk::PolhemusTrackingDevice::StartTracking ( )
overridevirtual

Starts the tracking.

Returns
Returns true if the tracking is started. Throws an exception if an error occures.
Exceptions
mitk::IGTHardwareExceptionThrows an exception if there is an error during start tracking.

Implements mitk::TrackingDevice.

Definition at line 71 of file mitkPolhemusTrackingDevice.cpp.

References mitk::IGTTimeStamp::GetInstance(), m_Device, m_MultiThreader, mitk::TrackingDevice::m_StopTracking, mitk::TrackingDevice::m_StopTrackingMutex, m_ThreadID, mitkThrowException, mitk::TrackingDevice::Ready, mitk::TrackingDevice::SetState(), mitk::IGTTimeStamp::Start(), ThreadStartTracking(), and mitk::TrackingDevice::Tracking.

◆ StopTracking()

bool mitk::PolhemusTrackingDevice::StopTracking ( )
overridevirtual

Stops the tracking.

Returns
Returns true if the tracking is stopped.

Reimplemented from mitk::TrackingDevice.

Definition at line 92 of file mitkPolhemusTrackingDevice.cpp.

References m_Device.

Referenced by TrackTools().

◆ ThreadStartTracking()

ITK_THREAD_RETURN_TYPE mitk::PolhemusTrackingDevice::ThreadStartTracking ( void *  data)
staticprotected

Definition at line 237 of file mitkPolhemusTrackingDevice.cpp.

References TrackTools().

Referenced by StartTracking().

◆ ToggleHemisphere()

void mitk::PolhemusTrackingDevice::ToggleHemisphere ( int  _tool = -1)

Toggles the current hemisphere. Parameter _tool describes, for which tool the hemisphere should change. Default -1 toggles all tools.

Definition at line 297 of file mitkPolhemusTrackingDevice.cpp.

References m_Device.

◆ TrackTools()

void mitk::PolhemusTrackingDevice::TrackTools ( )
protected

This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means grabbing frames from the camera an updating the tools.

Exceptions
mitk::IGTHardwareExceptionThrows an exception if there is an error during tracking of tools.

Definition at line 179 of file mitkPolhemusTrackingDevice.cpp.

References GetAllTools(), GetDevice(), mitk::IGTTimeStamp::GetInstance(), mitk::PolhemusInterface::GetLastFrame(), mitk::TrackingDevice::GetState(), m_AllTools, mitk::TrackingDevice::m_StopTracking, mitk::TrackingDevice::m_StopTrackingMutex, mitk::TrackingDevice::m_TrackingFinishedMutex, MITK_WARN, mitkThrowException, StopTracking(), and mitk::TrackingDevice::Tracking.

Referenced by ThreadStartTracking().

Member Data Documentation

◆ m_AllTools

std::vector<PolhemusTool::Pointer> mitk::PolhemusTrackingDevice::m_AllTools
protected

vector holding all tools

Definition at line 154 of file mitkPolhemusTrackingDevice.h.

Referenced by AddTool(), GetAllTools(), GetTool(), GetToolCount(), InternalAddTool(), OpenConnection(), and TrackTools().

◆ m_Device

PolhemusInterface::Pointer mitk::PolhemusTrackingDevice::m_Device
protected

◆ m_HemisphereTrackingEnabled

bool mitk::PolhemusTrackingDevice::m_HemisphereTrackingEnabled
protected

◆ m_MultiThreader

itk::MultiThreader::Pointer mitk::PolhemusTrackingDevice::m_MultiThreader
protected

Definition at line 156 of file mitkPolhemusTrackingDevice.h.

Referenced by PolhemusTrackingDevice(), and StartTracking().

◆ m_ThreadID

int mitk::PolhemusTrackingDevice::m_ThreadID
protected

Definition at line 157 of file mitkPolhemusTrackingDevice.h.

Referenced by PolhemusTrackingDevice(), and StartTracking().


The documentation for this class was generated from the following files: