MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitk::VirtualTrackingDevice Class Reference

Class representing a tracking device which generates random positions / orientations. No hardware is needed for tracking device. More...

#include <mitkVirtualTrackingDevice.h>

Inheritance diagram for mitk::VirtualTrackingDevice:
mitk::TrackingDevice

Public Member Functions

 mitkClassMacro (VirtualTrackingDevice, TrackingDevice)
 
 itkFactorylessNewMacro (Self)
 
 itkCloneMacro (Self)
 
 itkSetMacro (RefreshRate, unsigned int)
 Sets the refresh rate of the virtual tracking device in ms.
 
 itkGetConstMacro (RefreshRate, unsigned int)
 Returns the refresh rate in ms.
 
bool StartTracking () override
 Starts the tracking.
 
bool StopTracking () override
 Stops the tracking.
 
bool OpenConnection () override
 Opens the connection to the device. This have to be done before the tracking is started.
 
bool CloseConnection () override
 Closes the connection and clears all resources.
 
unsigned int GetToolCount () const override
 
TrackingToolGetTool (unsigned int toolNumber) const override
 
TrackingToolAddTool (const char *toolName)
 Adds a tool to the tracking device.
 
 itkSetVectorMacro (Bounds, mitk::ScalarType, 6)
 Set the tracking volume bounds.
 
const mitk::ScalarType * GetBounds () const
 return the tracking volume bounds
 
mitk::ScalarType GetSplineChordLength (unsigned int idx)
 return the approximate length of the spline for tool with index idx in millimeter
 
void SetToolSpeed (unsigned int idx, mitk::ScalarType roundsPerSecond)
 sets the speed of the tool idx in rounds per second
 
void EnableGaussianNoise ()
 enable addition of Gaussian Noise to tracking coordinates
 
void DisableGaussianNoise ()
 disable addition of Gaussian Noise to Trackin coordinates
 
void SetParamsForGaussianNoise (double meanDistribution, double deviationDistribution)
 sets the mean distribution and the standard deviation for the Gaussian Noise
 
double GetMeanDistribution ()
 returns the mean distribution for the Gaussian Noise
 
double GetDeviationDistribution ()
 returns the deviation distribution for the Gaussian Noise
 
- 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.
 
virtual void SetRotationMode (RotationMode r)
 
 itkGetConstMacro (RotationMode, RotationMode)
 
TrackingDeviceState GetState () const
 return current object state (Setup, Ready or Tracking)
 
TrackingDeviceType GetType () const
 Deprecated! Use the more specific getData or GetTrackingDeviceName instead. return device type identifier.
 
void SetType (TrackingDeviceType type)
 Deprecated! Use the more specific setDeviceData instead. set device type.
 
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.
 
TrackingDeviceData GetData () const
 return device data
 
void SetData (TrackingDeviceData data)
 set device type
 
virtual bool IsDeviceInstalled ()
 
virtual bool AutoDetectToolsAvailable ()
 
virtual bool AddSingleToolIsAvailable ()
 
virtual mitk::NavigationToolStorage::Pointer AutoDetectTools ()
 

Protected Types

typedef mitk::VirtualTrackingTool::SplineType::ControlPointType ControlPointType
 
typedef std::vector< VirtualTrackingTool::Pointer > ToolContainer
 container type for tracking tools
 

Protected Member Functions

 VirtualTrackingDevice ()
 
 ~VirtualTrackingDevice () override
 
void TrackTools ()
 This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means generating random numbers for the tool position and orientation.
 
void InitializeSpline (mitk::VirtualTrackingTool *t)
 initializes the spline path of the tool t with random control points inside the current tracking volume
 
void ThreadStartTracking ()
 static start method for tracking thread
 
ControlPointType GetRandomPoint ()
 returns a random position inside the tracking volume (defined by m_Bounds)
 
mitk::VirtualTrackingToolGetInternalTool (unsigned int idx)
 
- Protected Member Functions inherited from mitk::TrackingDevice
void SetState (TrackingDeviceState state)
 change object state
 
 TrackingDevice ()
 
 ~TrackingDevice () override
 

Protected Attributes

ToolContainer m_AllTools
 container for all tracking tools
 
std::mutex m_ToolsMutex
 mutex for coordinated access of tool container
 
std::thread m_Thread
 
unsigned int m_RefreshRate
 refresh rate of the internal tracking thread in milliseconds (NOT refreshs per second!)
 
unsigned int m_NumberOfControlPoints
 number of control points for the random path generation
 
mitk::ScalarType m_Bounds [6]
 bounding box of the tracking volume stored as {xMin, xMax, yMin, yMax, zMin, zMax}
 
bool m_GaussianNoiseEnabled
 adding Gaussian Noise to tracking coordinates or not, false by default
 
double m_MeanDistributionParam
 
double m_DeviationDistributionParam
 mean distribution for Gaussion Noise, 0.0 by default
 
- Protected Attributes inherited from mitk::TrackingDevice
TrackingDeviceData m_Data
 current device Data
 
bool m_StopTracking
 signal stop to tracking thread
 
std::mutex m_StopTrackingMutex
 mutex to control access to m_StopTracking
 
std::mutex m_TrackingFinishedMutex
 mutex to manage control flow of StopTracking()
 
std::mutex m_StateMutex
 mutex to control access to m_State
 
RotationMode m_RotationMode
 defines the rotation mode Standard or Transposed, Standard is default
 

Additional Inherited Members

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

Detailed Description

Class representing a tracking device which generates random positions / orientations. No hardware is needed for tracking device.

Documentation

This TrackingDevice class does not interface with a physical tracking device. It simulates a tracking device by moving the tools on a randomly generated spline path.

Definition at line 35 of file mitkVirtualTrackingDevice.h.

Member Typedef Documentation

◆ ControlPointType

mitk::VirtualTrackingTool::SplineType::ControlPointType mitk::VirtualTrackingDevice::ControlPointType
protected

Definition at line 193 of file mitkVirtualTrackingDevice.h.

◆ ToolContainer

std::vector<VirtualTrackingTool::Pointer> mitk::VirtualTrackingDevice::ToolContainer
protected

container type for tracking tools

Definition at line 198 of file mitkVirtualTrackingDevice.h.

Constructor & Destructor Documentation

◆ VirtualTrackingDevice()

mitk::VirtualTrackingDevice::VirtualTrackingDevice ( )
protected

Definition at line 25 of file mitkVirtualTrackingDevice.cpp.

◆ ~VirtualTrackingDevice()

mitk::VirtualTrackingDevice::~VirtualTrackingDevice ( )
overrideprotected

Definition at line 34 of file mitkVirtualTrackingDevice.cpp.

Member Function Documentation

◆ AddTool()

mitk::TrackingTool * mitk::VirtualTrackingDevice::AddTool ( const char * toolName)

Adds a tool to the tracking device.

The tool will have a random path on which it will move around. The path is created with a spline function and random control points inside the tracking volume.

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

Definition at line 51 of file mitkVirtualTrackingDevice.cpp.

◆ CloseConnection()

bool mitk::VirtualTrackingDevice::CloseConnection ( )
overridevirtual

Closes the connection and clears all resources.

Implements mitk::TrackingDevice.

Definition at line 163 of file mitkVirtualTrackingDevice.cpp.

◆ DisableGaussianNoise()

void mitk::VirtualTrackingDevice::DisableGaussianNoise ( )

disable addition of Gaussian Noise to Trackin coordinates

Definition at line 288 of file mitkVirtualTrackingDevice.cpp.

◆ EnableGaussianNoise()

void mitk::VirtualTrackingDevice::EnableGaussianNoise ( )

enable addition of Gaussian Noise to tracking coordinates

Definition at line 283 of file mitkVirtualTrackingDevice.cpp.

◆ GetBounds()

const mitk::ScalarType * mitk::VirtualTrackingDevice::GetBounds ( ) const
inline

return the tracking volume bounds

This will return the tracking volume as an axis aligned bounding box defined by the six bounds values xMin, xMax, yMin, yMax, zMin, zMax

Definition at line 125 of file mitkVirtualTrackingDevice.h.

◆ GetDeviationDistribution()

double mitk::VirtualTrackingDevice::GetDeviationDistribution ( )

returns the deviation distribution for the Gaussian Noise

Definition at line 299 of file mitkVirtualTrackingDevice.cpp.

◆ GetInternalTool()

mitk::VirtualTrackingTool * mitk::VirtualTrackingDevice::GetInternalTool ( unsigned int idx)
protected

Definition at line 194 of file mitkVirtualTrackingDevice.cpp.

◆ GetMeanDistribution()

double mitk::VirtualTrackingDevice::GetMeanDistribution ( )

returns the mean distribution for the Gaussian Noise

Definition at line 304 of file mitkVirtualTrackingDevice.cpp.

◆ GetRandomPoint()

mitk::VirtualTrackingDevice::ControlPointType mitk::VirtualTrackingDevice::GetRandomPoint ( )
protected

returns a random position inside the tracking volume (defined by m_Bounds)

Definition at line 273 of file mitkVirtualTrackingDevice.cpp.

◆ GetSplineChordLength()

mitk::ScalarType mitk::VirtualTrackingDevice::GetSplineChordLength ( unsigned int idx)

return the approximate length of the spline for tool with index idx in millimeter

if the index idx is not a valid tool index, a std::invalid_argument exception is thrown. GetSplineChordLength() returns the distance between all control points of the spline in millimeter. This can be used as an approximation for the length of the spline path.

Definition at line 173 of file mitkVirtualTrackingDevice.cpp.

◆ GetTool()

mitk::TrackingTool * mitk::VirtualTrackingDevice::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 nullptr, if there is no tool with this number.

Implements mitk::TrackingDevice.

Definition at line 109 of file mitkVirtualTrackingDevice.cpp.

◆ GetToolCount()

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

Implements mitk::TrackingDevice.

Definition at line 103 of file mitkVirtualTrackingDevice.cpp.

◆ InitializeSpline()

void mitk::VirtualTrackingDevice::InitializeSpline ( mitk::VirtualTrackingTool * t)
protected

initializes the spline path of the tool t with random control points inside the current tracking volume

Definition at line 129 of file mitkVirtualTrackingDevice.cpp.

◆ itkCloneMacro()

mitk::VirtualTrackingDevice::itkCloneMacro ( Self )

◆ itkFactorylessNewMacro()

mitk::VirtualTrackingDevice::itkFactorylessNewMacro ( Self )

◆ itkGetConstMacro()

mitk::VirtualTrackingDevice::itkGetConstMacro ( RefreshRate ,
unsigned int  )

Returns the refresh rate in ms.

Returns
Returns the refresh rate in ms.

◆ itkSetMacro()

mitk::VirtualTrackingDevice::itkSetMacro ( RefreshRate ,
unsigned int  )

Sets the refresh rate of the virtual tracking device in ms.

Warning
This refresh rate is not guaranteed. A thread is used to refresh the positions of the virtual tools. However, this thread may not run at all during this refresh time period.

◆ itkSetVectorMacro()

mitk::VirtualTrackingDevice::itkSetVectorMacro ( Bounds ,
mitk::ScalarType ,
6  )

Set the tracking volume bounds.

This will set the tracking volume as an axis aligned bounding box defined by the six bounds values xMin, xMax, yMin, yMax, zMin, zMax. Note that the random path of existing tools will not be updated with the new tracking volume. Tools that are created after calling SetBounds() will use the new tracking volume

◆ mitkClassMacro()

mitk::VirtualTrackingDevice::mitkClassMacro ( VirtualTrackingDevice ,
TrackingDevice  )

◆ OpenConnection()

bool mitk::VirtualTrackingDevice::OpenConnection ( )
overridevirtual

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

Exceptions
mitk::IGTExceptionThrows an exception if there are two less control points to start the the virtual device.

Implements mitk::TrackingDevice.

Definition at line 117 of file mitkVirtualTrackingDevice.cpp.

◆ SetParamsForGaussianNoise()

void mitk::VirtualTrackingDevice::SetParamsForGaussianNoise ( double meanDistribution,
double deviationDistribution )

sets the mean distribution and the standard deviation for the Gaussian Noise

Definition at line 293 of file mitkVirtualTrackingDevice.cpp.

◆ SetToolSpeed()

void mitk::VirtualTrackingDevice::SetToolSpeed ( unsigned int idx,
mitk::ScalarType roundsPerSecond )

sets the speed of the tool idx in rounds per second

The virtual tools will travel along a closed spline path. This method sets the speed of a tool as a factor of how many rounds per second the tool should move. A setting of 1.0 will indicate one complete round per second. Together with GetSplineChordLength(), the speed in millimeter per second can be estimated. roundsPerSecond must be positive and larger than 0.0001.

Warning
Tool speed is currently not used.
Todo
use tool speed

Definition at line 182 of file mitkVirtualTrackingDevice.cpp.

◆ StartTracking()

bool mitk::VirtualTrackingDevice::StartTracking ( )
overridevirtual

Starts the tracking.

After StartTracking() is called, the tools will move on their spline paths with a constant velocity that can be set with SetToolSpeed(). The standard velocity is 10 seconds for one complete cycle along the spline path.

Warning
tool speed is not yet used in the current version
Returns
Returns true if the tracking is started. Returns false if there was an error.

Implements mitk::TrackingDevice.

Definition at line 67 of file mitkVirtualTrackingDevice.cpp.

◆ StopTracking()

bool mitk::VirtualTrackingDevice::StopTracking ( )
overridevirtual

Stops the tracking.

Returns
Returns true if the tracking is stopped. Returns false if there was an error.

Reimplemented from mitk::TrackingDevice.

Definition at line 85 of file mitkVirtualTrackingDevice.cpp.

◆ ThreadStartTracking()

void mitk::VirtualTrackingDevice::ThreadStartTracking ( )
protected

static start method for tracking thread

Definition at line 268 of file mitkVirtualTrackingDevice.cpp.

◆ TrackTools()

void mitk::VirtualTrackingDevice::TrackTools ( )
protected

This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means generating random numbers for the tool position and orientation.

Exceptions
mitk::IGTExceptionThrows an mitk::IGTException if there is an error during virtual tool tracking.

Definition at line 203 of file mitkVirtualTrackingDevice.cpp.

Member Data Documentation

◆ m_AllTools

ToolContainer mitk::VirtualTrackingDevice::m_AllTools
protected

container for all tracking tools

Definition at line 199 of file mitkVirtualTrackingDevice.h.

◆ m_Bounds

mitk::ScalarType mitk::VirtualTrackingDevice::m_Bounds[6]
protected

bounding box of the tracking volume stored as {xMin, xMax, yMin, yMax, zMin, zMax}

Definition at line 207 of file mitkVirtualTrackingDevice.h.

◆ m_DeviationDistributionParam

double mitk::VirtualTrackingDevice::m_DeviationDistributionParam
protected

mean distribution for Gaussion Noise, 0.0 by default

deviation distribution for Gaussian Noise, 1.0 by default

Definition at line 210 of file mitkVirtualTrackingDevice.h.

◆ m_GaussianNoiseEnabled

bool mitk::VirtualTrackingDevice::m_GaussianNoiseEnabled
protected

adding Gaussian Noise to tracking coordinates or not, false by default

Definition at line 208 of file mitkVirtualTrackingDevice.h.

◆ m_MeanDistributionParam

double mitk::VirtualTrackingDevice::m_MeanDistributionParam
protected

Definition at line 209 of file mitkVirtualTrackingDevice.h.

◆ m_NumberOfControlPoints

unsigned int mitk::VirtualTrackingDevice::m_NumberOfControlPoints
protected

number of control points for the random path generation

Definition at line 205 of file mitkVirtualTrackingDevice.h.

◆ m_RefreshRate

unsigned int mitk::VirtualTrackingDevice::m_RefreshRate
protected

refresh rate of the internal tracking thread in milliseconds (NOT refreshs per second!)

Definition at line 204 of file mitkVirtualTrackingDevice.h.

◆ m_Thread

std::thread mitk::VirtualTrackingDevice::m_Thread
protected

Definition at line 202 of file mitkVirtualTrackingDevice.h.

◆ m_ToolsMutex

std::mutex mitk::VirtualTrackingDevice::m_ToolsMutex
mutableprotected

mutex for coordinated access of tool container

Definition at line 200 of file mitkVirtualTrackingDevice.h.


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