15#include "mitkIGTHardwareException.h"
18#include <itksys/SystemTools.hxx>
26#include <vtkSphereSource.h>
28const unsigned char CR = 0xD;
29const unsigned char LF = 0xA;
35m_IlluminationActivationRate(
Hz20), m_DataTransferMode(
TX), m_6DTools(),
36m_SerialCommunication(nullptr), m_DeviceProtocol(nullptr),
49 if (this->GetState() != Setup)
52 if (ndiTool ==
nullptr)
55 std::string portHandle = ndiTool->GetPortHandle();
65 returnvalue = m_DeviceProtocol->PINIT(&portHandle);
68 returnvalue = m_DeviceProtocol->PENA(&portHandle, ndiTool->GetTrackingPriority());
88 if (GetState() == Tracking)
92 if (GetState() == Ready)
94 this->CloseConnection();
97 if (m_Thread.joinable())
101 if (m_SerialCommunication.IsNotNull())
103 m_SerialCommunication->ClearReceiveBuffer();
104 m_SerialCommunication->ClearSendBuffer();
105 m_SerialCommunication->CloseConnection();
106 m_SerialCommunication =
nullptr;
112 if (this->GetState() != Setup)
114 itkDebugMacro(
"setting PortNumber to " << _arg);
115 if (this->m_PortNumber != _arg)
117 this->m_PortNumber = _arg;
124 if (this->GetState() != Setup)
126 itkDebugMacro(
"setting eviceName to " << _arg);
127 if (this->m_DeviceName != _arg)
129 this->m_DeviceName = _arg;
136 if (this->GetState() != Setup)
138 itkDebugMacro(
"setting BaudRate to " << _arg);
139 if (this->m_BaudRate != _arg)
141 this->m_BaudRate = _arg;
148 if (this->GetState() != Setup)
150 itkDebugMacro(
"setting DataBits to " << _arg);
151 if (this->m_DataBits != _arg)
153 this->m_DataBits = _arg;
160 if (this->GetState() != Setup)
162 itkDebugMacro(
"setting Parity to " << _arg);
163 if (this->m_Parity != _arg)
165 this->m_Parity = _arg;
172 if (this->GetState() != Setup)
174 itkDebugMacro(
"setting StopBits to " << _arg);
175 if (this->m_StopBits != _arg)
177 this->m_StopBits = _arg;
184 if (this->GetState() != Setup)
186 itkDebugMacro(
"setting HardwareHandshake to " << _arg);
187 if (this->m_HardwareHandshake != _arg)
189 this->m_HardwareHandshake = _arg;
196 if (this->GetState() == Tracking)
198 itkDebugMacro(
"setting IlluminationActivationRate to " << _arg);
199 if (this->m_IlluminationActivationRate != _arg)
201 this->m_IlluminationActivationRate = _arg;
203 if (this->GetState() == Ready)
204 m_DeviceProtocol->IRATE(this->m_IlluminationActivationRate);
210 itkDebugMacro(
"setting DataTransferMode to " << _arg);
211 if (this->m_DataTransferMode != _arg)
213 this->m_DataTransferMode = _arg;
220 if (input ==
nullptr)
226 message = *input + CalcCRC(input) + std::string(1,
CR);
228 message = *input + std::string(1,
CR);
233 this->ClearSendBuffer();
235 std::lock_guard<std::mutex> lock(m_SerialCommunicationMutex);
236 long returnvalue = m_SerialCommunication->Send(message);
238 if (returnvalue == 0)
246 if (answer ==
nullptr)
249 std::lock_guard<std::mutex> lock(m_SerialCommunicationMutex);
250 long returnvalue = m_SerialCommunication->Receive(*answer, numberOfBytes);
252 if (returnvalue == 0)
260 if (answer ==
nullptr)
265 std::lock_guard<std::mutex> lock(m_SerialCommunicationMutex);
267 long returnvalue = m_SerialCommunication->Receive(m, 1);
269 if ((returnvalue == 0) || (m.size() != 1))
278 if (answer ==
nullptr)
283 std::lock_guard<std::mutex> lock(m_SerialCommunicationMutex);
287 long returnvalue = m_SerialCommunication->Receive(m, 1);
288 if ((returnvalue == 0) || (m.size() != 1))
291 }
while (m.at(0) !=
LF);
297 std::lock_guard<std::mutex> lock(m_SerialCommunicationMutex);
298 m_SerialCommunication->ClearSendBuffer();
303 std::lock_guard<std::mutex> lock(m_SerialCommunicationMutex);
304 m_SerialCommunication->ClearReceiveBuffer();
309 if (input ==
nullptr)
312 static int oddparity[16] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
314 unsigned int crcValue = 0;
315 unsigned int* puCRC16 = &crcValue;
316 for (
unsigned int i = 0; i < input->length(); i++)
319 data = (data ^ (*(puCRC16)& 0xff)) & 0xff;
321 if (oddparity[data & 0x0f] ^ oddparity[data >> 4])
323 *(puCRC16) ^= 0xc001;
331 char returnvalue[13];
332 sprintf(returnvalue,
"%04X", crcValue);
333 return std::string(returnvalue);
339 if (this->GetState() != Setup)
341 mitkThrowException(
mitk::IGTException) <<
"Can only try to open the connection if in setup mode";
344 m_SerialCommunication = mitk::SerialCommunication::New();
348 if (m_DeviceName.empty())
349 m_SerialCommunication->SetPortNumber(m_PortNumber);
351 m_SerialCommunication->SetDeviceName(m_DeviceName);
356 m_SerialCommunication->SetSendTimeout(5000);
357 m_SerialCommunication->SetReceiveTimeout(5000);
358 if (m_SerialCommunication->OpenConnection() == 0)
360 m_SerialCommunication->CloseConnection();
361 m_SerialCommunication =
nullptr;
366 m_SerialCommunication->SendBreak(400);
369 static const std::string reset(
"RESETBE6F\r");
370 std::string answer =
"";
371 this->Receive(&answer, reset.length());
372 this->ClearReceiveBuffer();
373 if (reset.compare(answer) != 0)
375 if (m_SerialCommunication.IsNotNull())
377 m_SerialCommunication->CloseConnection();
378 m_SerialCommunication =
nullptr;
387 returnvalue = m_DeviceProtocol->COMM(m_BaudRate, m_DataBits, m_Parity, m_StopBits, m_HardwareHandshake);
395 itksys::SystemTools::Delay(500);
398 m_SerialCommunication->CloseConnection();
399 m_SerialCommunication->SetBaudRate(m_BaudRate);
400 m_SerialCommunication->SetDataBits(m_DataBits);
401 m_SerialCommunication->SetParity(m_Parity);
402 m_SerialCommunication->SetStopBits(m_StopBits);
403 m_SerialCommunication->SetHardwareHandshake(m_HardwareHandshake);
404 m_SerialCommunication->SetSendTimeout(5000);
405 m_SerialCommunication->SetReceiveTimeout(5000);
406 m_SerialCommunication->OpenConnection();
409 returnvalue = m_DeviceProtocol->INIT();
418 returnvalue = m_DeviceProtocol->VER(deviceType);
421 mitkThrowException(
mitk::IGTHardwareException) <<
"Could not determine tracking device type. Please set manually and try again.";
423 this->SetType(deviceType);
469 returnvalue = FreePortHandles();
476 std::lock_guard<std::mutex> lock(m_ToolsMutex);
477 std::string portHandle;
478 auto endIt = m_6DTools.end();
479 for (
auto it = m_6DTools.begin(); it != endIt; ++it)
482 returnvalue = m_DeviceProtocol->PHRQ(&portHandle);
485 (*it)->SetPortHandle(portHandle.c_str());
489 returnvalue = m_DeviceProtocol->PVWR(&portHandle, (*it)->GetSROMData(), (*it)->GetSROMDataLength());
492 mitkThrowException(
mitk::IGTHardwareException) << (std::string(
"Could not write SROM file for tool '") + (*it)->GetToolName() + std::string(
"' to tracking device")).c_str();
495 returnvalue = m_DeviceProtocol->PINIT(&portHandle);
498 mitkThrowException(
mitk::IGTHardwareException) << (std::string(
"Could not initialize tool '") + (*it)->GetToolName()).c_str();
501 if ((*it)->IsEnabled() ==
true)
503 returnvalue = m_DeviceProtocol->PENA(&portHandle, (*it)->GetTrackingPriority());
507 std::string(
"' for tool '") + (*it)->GetToolName() + std::string(
"'")).c_str();
516 if (this->DiscoverWiredTools() ==
false)
522 returnvalue = m_DeviceProtocol->IRATE(this->m_IlluminationActivationRate);
529 this->SetState(Ready);
532 SetVolume(this->m_Data);
536 MITK_WARN << e.GetDescription();
545 std::string portHandle;
546 returnvalue = m_DeviceProtocol->PHSR(
OCCUPIED, &portHandle);
556 for (
unsigned int i = 0; i < portHandle.size(); i += 2)
558 ph = portHandle.substr(i, 2);
572 returnvalue = m_DeviceProtocol->PINIT(&ph);
580 returnvalue = m_DeviceProtocol->PENA(&ph, pt->GetTrackingPriority());
584 std::string(
"' for tool '") + pt->
GetToolName() + std::string(
"'")).c_str();
593 if (this->GetState() != Setup)
598 m_SerialCommunication = mitk::SerialCommunication::New();
605 if (m_DeviceName.empty())
606 m_SerialCommunication->SetPortNumber(m_PortNumber);
608 m_SerialCommunication->SetDeviceName(m_DeviceName);
614 m_SerialCommunication->SetSendTimeout(5000);
615 m_SerialCommunication->SetReceiveTimeout(5000);
616 if (m_SerialCommunication->OpenConnection() == 0)
618 m_SerialCommunication =
nullptr;
623 m_SerialCommunication->SendBreak(400);
626 static const std::string reset(
"RESETBE6F\r");
627 std::string answer =
"";
628 this->Receive(&answer, reset.length());
629 this->ClearReceiveBuffer();
630 if (reset.compare(answer) != 0)
632 m_SerialCommunication->CloseConnection();
633 m_SerialCommunication =
nullptr;
649 returnvalue = m_DeviceProtocol->VER(deviceType);
652 m_SerialCommunication =
nullptr;
655 m_SerialCommunication =
nullptr;
661 if (this->GetState() != Setup)
664 m_DeviceProtocol->INIT();
666 m_SerialCommunication->CloseConnection();
668 this->InvalidateAll();
670 this->SetState(Setup);
671 m_SerialCommunication =
nullptr;
681 this->TrackMarkerPositions();
683 this->TrackMarkerPositions();
686 this->TrackToolsAndMarkers();
692 if (this->GetState() != Ready)
695 this->SetState(Tracking);
696 this->m_StopTrackingMutex.lock();
697 this->m_StopTracking =
false;
698 this->m_StopTrackingMutex.unlock();
708 std::lock_guard<std::mutex> lock(m_TrackingFinishedMutex);
710 if (this->GetState() != Tracking)
714 returnvalue = m_DeviceProtocol->TSTART();
718 bool localStopTracking;
719 this->m_StopTrackingMutex.lock();
720 localStopTracking = this->m_StopTracking;
721 this->m_StopTrackingMutex.unlock();
722 while ((this->GetState() == Tracking) && (localStopTracking ==
false))
724 if (this->m_DataTransferMode ==
TX)
726 returnvalue = this->m_DeviceProtocol->TX();
732 returnvalue = this->m_DeviceProtocol->BX();
737 this->m_StopTrackingMutex.lock();
738 localStopTracking = m_StopTracking;
739 this->m_StopTrackingMutex.unlock();
743 returnvalue = m_DeviceProtocol->TSTOP();
754 std::lock_guard<std::mutex> lock(m_TrackingFinishedMutex);
759 if (this->GetState() != Tracking)
764 returnvalue = m_DeviceProtocol->DSTART();
768 bool localStopTracking;
769 this->m_StopTrackingMutex.lock();
770 localStopTracking = this->m_StopTracking;
771 this->m_StopTrackingMutex.unlock();
772 while ((this->GetState() == Tracking) && (localStopTracking ==
false))
774 m_MarkerPointsMutex.lock();
775 returnvalue = this->m_DeviceProtocol->POS3D(&m_MarkerPoints);
776 m_MarkerPointsMutex.unlock();
779 std::cout <<
"Error in POS3D: could not read data. Possibly no markers present." << std::endl;
782 this->m_StopTrackingMutex.lock();
783 localStopTracking = m_StopTracking;
784 this->m_StopTrackingMutex.unlock();
786 itksys::SystemTools::Delay(1);
789 returnvalue = m_DeviceProtocol->DSTOP();
793 this->SetState(Ready);
799 std::lock_guard<std::mutex> lock(m_TrackingFinishedMutex);
805 returnvalue = m_DeviceProtocol->TSTART();
809 bool localStopTracking;
810 this->m_StopTrackingMutex.lock();
811 localStopTracking = this->m_StopTracking;
812 this->m_StopTrackingMutex.unlock();
813 while ((this->GetState() == Tracking) && (localStopTracking ==
false))
815 m_MarkerPointsMutex.lock();
816 returnvalue = this->m_DeviceProtocol->TX(
true, &m_MarkerPoints);
817 m_MarkerPointsMutex.unlock();
820 std::cout <<
"Error in TX: could not read data. Possibly no markers present." << std::endl;
823 this->m_StopTrackingMutex.lock();
824 localStopTracking = m_StopTracking;
825 this->m_StopTrackingMutex.unlock();
829 returnvalue = m_DeviceProtocol->TSTOP();
833 this->SetState(Ready);
839 std::lock_guard<std::mutex> lock(m_ToolsMutex);
840 if (toolNumber < m_6DTools.size())
841 return m_6DTools.at(toolNumber);
847 std::lock_guard<std::mutex> lock(m_ToolsMutex);
848 auto end = m_6DTools.end();
849 for (
auto iterator = m_6DTools.begin(); iterator != end; ++iterator)
850 if (name.compare((*iterator)->GetToolName()) == 0)
857 std::lock_guard<std::mutex> lock(m_ToolsMutex);
858 auto end = m_6DTools.end();
859 for (
auto iterator = m_6DTools.begin(); iterator != end; ++iterator)
860 if (portHandle.compare((*iterator)->GetPortHandle()) == 0)
867 std::lock_guard<std::mutex> lock(m_ToolsMutex);
868 return m_6DTools.size();
873 if (this->GetState() != Setup)
875 return (m_DeviceProtocol->BEEP(count) ==
NDIOKAY);
885 mitk::NDIPassiveTool::Pointer t = mitk::NDIPassiveTool::New();
886 if (t->LoadSROMFile(fileName) ==
false)
888 t->SetToolName(toolName);
889 t->SetTrackingPriority(p);
890 if (this->InternalAddTool(t) ==
false)
892 return t.GetPointer();
899 NDIPassiveTool::Pointer p = tool;
901 if (this->GetState() == Ready)
904 std::string newPortHandle;
906 returnvalue = m_DeviceProtocol->PHRQ(&newPortHandle);
909 p->SetPortHandle(newPortHandle.c_str());
911 returnvalue = m_DeviceProtocol->PVWR(&newPortHandle, p->GetSROMData(), p->GetSROMDataLength());
914 mitkThrowException(
mitk::IGTHardwareException) << (std::string(
"Could not write SROM file for tool '") + p->GetToolName() + std::string(
"' to tracking device")).c_str();
917 returnvalue = m_DeviceProtocol->PINIT(&newPortHandle);
921 std::string(
"' for tool '") + p->GetToolName() + std::string(
"'")).c_str();
924 if (p->IsEnabled() ==
true)
926 returnvalue = m_DeviceProtocol->PENA(&newPortHandle, p->GetTrackingPriority());
930 std::string(
"' for tool '") + p->GetToolName() + std::string(
"'")).c_str();
936 this->m_6DTools.push_back(p);
937 m_ToolsMutex.unlock();
941 else if (this->GetState() == Setup)
945 this->m_6DTools.push_back(p);
946 m_ToolsMutex.unlock();
957 if (ndiTool ==
nullptr)
960 std::string portHandle = ndiTool->GetPortHandle();
964 if ((portHandle.length() == 2) && (this->GetState() == Ready))
967 returnvalue = m_DeviceProtocol->PHF(&portHandle);
971 std::lock_guard<std::mutex> lock(m_ToolsMutex);
972 auto end = m_6DTools.end();
973 for (
auto iterator = m_6DTools.begin(); iterator != end; ++iterator)
975 if (iterator->GetPointer() == ndiTool)
977 m_6DTools.erase(iterator);
984 else if (this->GetState() == Setup)
986 std::lock_guard<std::mutex> lock(m_ToolsMutex);
987 auto end = m_6DTools.end();
988 for (
auto iterator = m_6DTools.begin(); iterator != end; ++iterator)
990 if ((*iterator).GetPointer() == ndiTool)
992 m_6DTools.erase(iterator);
1004 std::lock_guard<std::mutex> lock(m_ToolsMutex);
1005 auto end = m_6DTools.end();
1006 for (
auto iterator = m_6DTools.begin(); iterator != end; ++iterator)
1007 (*iterator)->SetDataValid(
false);
1012 if (GetState() == Tracking)
1015 m_OperationMode = mode;
1021 return m_OperationMode;
1026 m_MarkerPointsMutex.lock();
1027 *markerpositions = m_MarkerPoints;
1028 m_MarkerPointsMutex.unlock();
1029 return (markerpositions->size() != 0);
1035 this->FreePortHandles();
1047 std::string portHandle;
1052 mitkThrowException(
mitk::IGTHardwareException) <<
"Could not obtain a list of port handles that are connected on channel 0.";
1056 for (
unsigned int i = 0; i < portHandle.size(); i += 2)
1058 std::string ph = portHandle.substr(i, 2);
1059 returnvalue = m_DeviceProtocol->PINIT(&ph);
1071 returnvalue = m_DeviceProtocol->PHSR(
OCCUPIED, &portHandle);
1075 mitkThrowException(
mitk::IGTHardwareException) <<
"Could not obtain a list of port handles that are connected on channel 1.";
1079 returnvalue = m_DeviceProtocol->PHSR(
ALL, &portHandle);
1083 mitkThrowException(
mitk::IGTHardwareException) <<
"Could not obtain a list of port handles that are connected on all channels.";
1091 for (
unsigned int i = 0; i < portHandle.size(); i += 2)
1093 std::string ph = portHandle.substr(i, 2);
1094 if (this->GetInternalTool(ph) !=
nullptr)
1101 mitk::NDIPassiveTool::Pointer newTool = mitk::NDIPassiveTool::New();
1102 newTool->SetPortHandle(ph.c_str());
1103 newTool->SetTrackingPriority(trackingPriority);
1106 newTool->SetToolName((std::string(
"Port ") + ph).c_str());
1109 returnvalue = m_DeviceProtocol->PENA(&ph, trackingPriority);
1114 std::string(
"' for tool '") + newTool->GetToolName() + std::string(
"'")).c_str();
1118 if (this->InternalAddTool(newTool) ==
false)
1129 for (
unsigned int i = 0; i < portHandle.size(); i += 2)
1131 std::string ph = portHandle.substr(i, 2);
1133 std::string portInfo;
1134 NDIErrorCode returnvaluePort = m_DeviceProtocol->PHINF(ph, &portInfo);
1135 if ((returnvaluePort ==
NDIOKAY) && (portInfo.size() > 31))
1136 dynamic_cast<mitk::NDIPassiveTool*
>(this->GetInternalTool(ph))->SetSerialNumber(portInfo.substr(23, 8));
1137 MITK_INFO <<
"portInfo: " << portInfo;
1138 itksys::SystemTools::Delay(10);
1148 std::string portHandle;
1149 returnvalue = m_DeviceProtocol->PHSR(
FREED, &portHandle);
1156 if (portHandle.empty() ==
true)
1160 for (
unsigned int i = 0; i < portHandle.size(); i += 2)
1162 ph = portHandle.substr(i, 2);
1167 if (this->RemoveTool(t) ==
false)
1172 returnvalue = m_DeviceProtocol->PHF(&ph);
1185 std::string revision;
1186 if (m_DeviceProtocol->APIREV(&revision) !=
mitk::NDIOKAY || revision.empty() || (revision.size() != 9))
1188 MITK_ERROR <<
"Could not receive firmware revision number!";
1192 const std::string majrevno = revision.substr(2, 3);
1194 return std::atoi(majrevno.c_str());
1199 static std::string revision;
1200 if (m_DeviceProtocol->APIREV(&revision) !=
mitk::NDIOKAY || revision.empty() || (revision.size() != 9))
1202 MITK_ERROR <<
"Could not receive firmware revision number!";
1204 return revision.c_str();
1206 return revision.c_str();
1212 else {
return false; }
1220 else {
return true; }
1225 mitk::NavigationToolStorage::Pointer autoDetectedStorage = mitk::NavigationToolStorage::New();
1230 this->OpenConnection();
1231 this->StartTracking();
1233 catch (mitk::Exception& e)
1235 MITK_WARN <<
"Warning, can not auto-detect tools! (" << e.GetDescription() <<
")";
1236 return autoDetectedStorage;
1239 for (
unsigned int i = 0; i < this->GetToolCount(); i++)
1242 std::stringstream toolname;
1243 toolname <<
"AutoDetectedTool" << i;
1244 mitk::NavigationTool::Pointer newTool = mitk::NavigationTool::New();
1245 newTool->SetSerialNumber(
dynamic_cast<mitk::NDIPassiveTool*
>(this->GetTool(i))->GetSerialNumber());
1246 newTool->SetIdentifier(toolname.str());
1248 newTool->GetDataNode()->SetName(toolname.str());
1249 autoDetectedStorage->AddTool(newTool);
1251 this->StopTracking();
1252 this->CloseConnection();
1254 return autoDetectedStorage;
1259 if (numberOfVolumes ==
nullptr || volumes ==
nullptr || volumesDimensions ==
nullptr)
1262 static std::string info;
1263 if (m_DeviceProtocol->SFLIST(&info) !=
mitk::NDIOKAY || info.empty())
1265 MITK_ERROR <<
"Could not receive tracking volume information of tracking system!";
1272 (*numberOfVolumes) = (
unsigned int)std::atoi(info.substr(0, 1).c_str());
1274 for (
unsigned int i = 0; i < (*numberOfVolumes); i++)
1279 std::string::size_type offset, end;
1280 offset = (i * 73) + 1;
1281 end = 73 + (i * 73);
1282 std::string currentVolume = info.substr(offset, end);
1285 currentVolume = currentVolume.substr(1, currentVolume.size());
1292 currentVolume = currentVolume.substr(1, currentVolume.size());
1303 for (
unsigned int index = 0; index < 10; index++)
1305 std::string::size_type offD, endD;
1306 offD = 1 + (index * 7);
1308 int dimension = std::atoi(currentVolume.substr(offD, endD).c_str());
1310 volumesDimensions->push_back(dimension);
An object of this class represents an exception of the MITK-IGT module.
An object of this class represents an exception of the MITK-IGT module which are releated to the hard...
static IGTTimeStamp * GetInstance()
returns a pointer to the current instance of mitkTimeStamp
void Start(itk::Object::Pointer device)
starts the time-acquisition
Tool6DContainerType m_6DTools
list of 6D tools
virtual void InvalidateAll()
invalidate all tools
virtual void SetDataBits(const DataBits _arg)
set number of data bits
NDIPassiveTool * GetInternalTool(std::string portHandle)
returns the tool object that has been assigned the port handle or nullptr if no tool can be found
virtual void SetHardwareHandshake(const HardwareHandshake _arg)
set use hardware handshake for serial communication
virtual int GetMajorFirmwareRevisionNumber()
Get major revision number from tracking device should not be called directly after starting to track.
virtual void SetParity(const Parity _arg)
set parity mode
NDIErrorCode Send(const std::string *message, bool addCRC=true)
Send message to tracking device.
virtual void SetDataTransferMode(const DataTransferMode _arg)
set data transfer mode to text (TX) or binary (BX).
NDIErrorCode ReceiveLine(std::string *answer)
receive characters until the first LF (The LF is included in the answer string)
bool AutoDetectToolsAvailable() override
virtual bool SetVolume(mitk::TrackingDeviceData volume)
Sets the desired tracking volume. Returns true if the volume type could be set. It is set in the Open...
virtual bool Beep(unsigned char count)
Beep the tracking device 1 to 9 times.
unsigned int GetToolCount() const override
return current number of tools
virtual void TrackToolsAndMarkers()
continuously polls serial interface for new 3D marker positions and 6D tool positions until StopTrack...
NDITrackingDevice()
Constructor.
TrackingTool * GetTool(unsigned int toolNumber) const override
return the tool with index toolNumber
virtual const char * GetFirmwareRevisionNumber()
Get revision number from tracking device as string should not be called directly after starting to tr...
virtual bool SetOperationMode(OperationMode mode)
set operation mode to 6D tool tracking, 3D marker tracking or 6D&3D hybrid tracking (see OperationMod...
virtual bool UpdateTool(mitk::TrackingTool *tool)
reloads the srom file and reinitializes the tool
std::vector< int > TrackingVolumeDimensionType
List of the supported tracking volume dimensions.
bool OpenConnection() override
Set the type of the NDI Tracking Device because it can not jet handle this itself.
virtual void SetStopBits(const StopBits _arg)
set number of stop bits
NDIErrorCode Receive(std::string *answer, unsigned int numberOfBytes)
receive numberOfBytes bytes from tracking device
MarkerPointContainerType m_MarkerPoints
container for markers (3D point tracking mode)
NDIProtocol::Pointer m_DeviceProtocol
create and parse NDI protocol strings
virtual void SetDeviceName(std::string _arg)
set device name (e.g. COM1, /dev/ttyUSB0). If this is set, PortNumber will be ignored
virtual bool GetMarkerPositions(MarkerPointContainerType *markerpositions)
Get 3D marker positions (operation mode must be set to MarkerTracking3D or HybridTracking)
void ClearSendBuffer()
empty send buffer of serial communication interface
virtual bool InternalAddTool(NDIPassiveTool *tool)
Add a passive 6D tool to the list of tracked tools. This method is used by AddTool.
mitk::NavigationToolStorage::Pointer AutoDetectTools() override
virtual void SetPortNumber(const PortNumber _arg)
set port number for serial communication
NDIErrorCode FreePortHandles()
free all port handles that need to be freed
virtual void SetIlluminationActivationRate(const IlluminationActivationRate _arg)
set activation rate of IR illumator for polaris
virtual mitk::TrackingDeviceType TestConnection()
TestConnection() tries to connect to a NDI tracking device on the current port/device and returns whi...
virtual bool GetSupportedVolumes(unsigned int *numberOfVolumes, NDITrackingVolumeContainerType *volumes, TrackingVolumeDimensionType *volumesDimensions)
Get number of supported tracking volumes, a vector containing the supported volumes and a vector cont...
virtual void SetBaudRate(const BaudRate _arg)
set baud rate for serial communication
NDIErrorCode ReceiveByte(char *answer)
lightweight receive function, that reads just one byte
void ClearReceiveBuffer()
empty receive buffer of serial communication interface
void SetRotationMode(RotationMode r) override
const std::string CalcCRC(const std::string *input)
returns the CRC16 for input as a std::string
bool StartTracking() override
Start the tracking.
void ThreadStartTracking()
start method for the tracking thread.
bool InitializeWiredTools()
bool AddSingleToolIsAvailable() override
std::vector< std::string > NDITrackingVolumeContainerType
vector of tracking volumes
~NDITrackingDevice() override
Destructor.
virtual OperationMode GetOperationMode()
get current operation mode
bool CloseConnection() override
Closes the connection.
virtual bool RemoveTool(TrackingTool *tool)
Remove a passive 6D tool from the list of tracked tools.
bool DiscoverWiredTools()
retrieves all wired tools from the tracking device
virtual void TrackTools()
TrackTools() continuously polls serial interface for new 6d tool positions until StopTracking is call...
virtual void TrackMarkerPositions()
continuously polls serial interface for new 3D marker positions until StopTracking is called.
mitk::TrackingTool * GetToolByName(std::string name) const override
Returns the tool with the given tool name.
mitk::TrackingTool * AddTool(const char *toolName, const char *fileName, TrackingPriority p=NDIPassiveTool::Dynamic)
Create a passive 6D tool with toolName and fileName and add it to the list of tools.
serial communication interface
Interface for all Tracking Devices.
TrackingDeviceData m_Data
current device Data
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.