15 #include "mitkIGTConfig.h" 17 #include "mitkIGTHardwareException.h" 18 #include <itksys/SystemTools.hxx> 20 #include <itkMutexLockHolder.h> 50 if (_tool->GetToolPort() == toolPort)
52 MITK_DEBUG <<
"There is already a tool connected to this port. Returning existing tool";
58 t->SetToolName(toolName);
59 t->SetToolPort(toolPort);
62 return t.GetPointer();
73 bool success =
m_Device->StartTracking();
95 return Superclass::StopTracking();
117 MITK_ERROR <<
"Cannot connect Polhemus device!";
126 std::vector<int> toolPorts =
m_Device->GetToolPorts();
131 MITK_ERROR <<
"Cannot connect device, number of tools in toolstorage doesn't match the number of tools connected to Polhemus device!";
139 if (std::find(toolPorts.begin(), toolPorts.end(), _tool->GetToolPort()) == toolPorts.end())
141 MITK_ERROR <<
"Cannot connect device, tool " << _tool->GetToolPort() <<
" is not connected to its port.";
148 toolPorts.erase(std::find(toolPorts.begin(), toolPorts.end(), _tool->GetToolPort()));
159 bool returnValue =
true;
163 returnValue =
m_Device->Disconnect();
186 bool localStopTracking;
198 MITK_WARN <<
"Tool count is corrupt. Hardware gives " << lastData.size() <<
" tools, MITK expects " <<
m_AllTools.size() <<
" tools. Aborting!";
202 std::vector<mitk::PolhemusTool::Pointer> allTools = this->
GetAllTools();
203 for (
size_t i = 0; i < allTools.size(); i++)
205 mitk::PolhemusTool::Pointer currentTool = allTools.at(i);
207 const int distortionLevel = lastData.at(i).distortionLevel;
209 if (distortionLevel == 0)
211 currentTool->SetDataValid(
true);
215 currentTool->SetDataValid(
false);
218 currentTool->SetDistortionLevel(distortionLevel);
219 currentTool->SetPosition(lastData.at(i).pos);
220 currentTool->SetOrientation(lastData.at(i).rot);
240 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
241 if (pInfo ==
nullptr)
243 return ITK_THREAD_RETURN_VALUE;
245 if (pInfo->UserData ==
nullptr)
247 return ITK_THREAD_RETURN_VALUE;
251 if (trackingDevice !=
nullptr)
254 return ITK_THREAD_RETURN_VALUE;
264 std::vector<mitk::PolhemusInterface::trackingData> singeFrameData = this->
m_Device->AutoDetectTools();
265 MITK_INFO <<
"Found " << singeFrameData.size() <<
" tools.";
271 std::stringstream name;
272 name <<
"Sensor-" << ((int)t.
id);
273 newTool->GetDataNode()->SetName(name.str());
276 std::stringstream identifier;
277 identifier << ((int)t.
id);
278 newTool->SetIdentifier(identifier.str());
281 returnValue->AddTool(newTool);
294 this->
m_Device->SetHemisphereTrackingEnabled(_HemisphereTrackingEnabled);
299 this->
m_Device->ToggleHemisphere(_tool);
306 if (_hemisphere.GetNorm() != 0)
309 this->
m_Device->SetHemisphere(_tool, _hemisphere);
314 return this->
m_Device->GetHemisphere(_tool);
319 return this->
m_Device->GetHemisphereTrackingEnabled(_tool);
324 return this->
m_Device->AdjustHemisphere(_tool);
An object of this class represents the interface to Polhemus trackers. All variables with the name "t...
An object of this class represents an exception of the MITK-IGT module which are releated to the hard...
An object of this class represents Polhemus tracking device. You can add tools to this device...
static ITK_THREAD_RETURN_TYPE ThreadStartTracking(void *data)
itk::FastMutexLock::Pointer m_TrackingFinishedMutex
mutex to manage control flow of StopTracking()
mitk::TrackingTool * AddTool(const char *toolName, int toolPort)
Create a new Polhemus tool with toolName and add it to the list of tools.
void SetHemisphereTrackingEnabled(bool _HemisphereTrackingEnabled)
virtual bool StartTracking() override
Starts the tracking.
virtual bool OpenConnection() override
Opens the connection to the device. This have to be done before the tracking is started.
PolhemusInterface * GetDevice()
DataCollection - Class to facilitate loading/accessing structured data.
PolhemusInterface::Pointer m_Device
represents the interface to the tracking hardware
virtual bool AutoDetectToolsAvailable()
bool InternalAddTool(PolhemusTool::Pointer tool)
Adds a tool to the tracking device.
void TrackTools()
This method tracks tools as long as the variable m_Mode is set to "Tracking". Tracking tools means gr...
mitk::Vector3D GetHemisphere(int _tool)
TrackingDeviceState GetState() const
return current object state (Setup, Ready or Tracking)
itk::MutexLockHolder< itk::FastMutexLock > MutexLockHolder
void AdjustHemisphere(int _tool)
std::vector< PolhemusTool::Pointer > m_AllTools
vector holding all tools
virtual bool CloseConnection() override
Closes the connection and clears all resources.
virtual mitk::NavigationToolStorage::Pointer AutoDetectTools()
itk::MultiThreader::Pointer m_MultiThreader
virtual bool StopTracking() override
Stops the tracking.
bool m_StopTracking
signal stop to tracking thread
Interface for all Tracking Devices.
static IGTTimeStamp * GetInstance()
returns a pointer to the current instance of mitkTimeStamp
void Start(itk::Object::Pointer device)
starts the time-acquisition
TrackingDeviceData m_Data
current device Data
#define mitkThrowException(classname)
itk::FastMutexLock::Pointer m_StopTrackingMutex
mutex to control access to m_StopTracking
void SetHemisphere(int _tool, mitk::Vector3D _hemisphere)
bool m_HemisphereTrackingEnabled
TrackingTool * GetTool(unsigned int toolNumber) const override
std::vector< trackingData > GetLastFrame()
std::vector< PolhemusTool::Pointer > GetAllTools()
void ToggleHemisphere(int _tool=-1)
void SetState(TrackingDeviceState state)
change object state
bool GetHemisphereTrackingEnabled(int _tool)
~PolhemusTrackingDevice()
virtual unsigned int GetToolCount() const override