13 #include "mitkMicrobirdTrackingDevice.h" 15 #include <itksys/SystemTools.hxx> 16 #include <itkMutexLockHolder.h> 26 m_measurementRate(68.3),
27 m_TransmitterConfig(nullptr),
28 m_SensorConfig(nullptr)
34 this->
m_Data = mitk::DeviceDataMicroBird;
76 this->
SetErrorMessage(
"Can only try to open the connection if in setup mode");
83 errorCode = InitializeBIRDSystem();
123 errorCode = SetSystemParameter(POWER_LINE_FREQUENCY, &
m_pl,
sizeof(
m_pl));
133 errorCode = SetSystemParameter(AGC_MODE, &
m_agc,
sizeof(
m_agc));
159 QUALITY_PARAMETERS qualityParameters;
160 GetSensorParameter(i, QUALITY, &qualityParameters,
sizeof(qualityParameters));
165 DATA_FORMAT_TYPE tempBuffer = DOUBLE_POSITION_QUATERNION_TIME_Q;
168 DATA_FORMAT_TYPE *pTempBuffer = &tempBuffer;
169 errorCode = SetSensorParameter(i, DATA_FORMAT, pTempBuffer,
sizeof(tempBuffer));
223 int errorCode = SetSystemParameter(SELECT_TRANSMITTER, &
id,
sizeof(
id));
237 short TRANSMITTER_OFF = -1;
238 int errorCode = SetSystemParameter(SELECT_TRANSMITTER, &TRANSMITTER_OFF,
sizeof(TRANSMITTER_OFF));
256 int errorCode = CloseBIRDSystem();
286 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (
struct itk::MultiThreader::ThreadInfoStruct*)pInfoStruct;
287 if ((pInfo ==
nullptr) || (pInfo->UserData ==
nullptr))
288 return ITK_THREAD_RETURN_VALUE;
291 if (trackingDevice !=
nullptr)
294 return ITK_THREAD_RETURN_VALUE;
325 mitk::TimeStamp::GetInstance()->Start(
this);
337 double measurementDuration = 0.0;
346 bool localStopTracking;
357 unsigned int nOfAttachedSensors = 0;
358 double timeStamp = 0.0;
361 for (
int sensorID = 0; sensorID <
m_SystemConfig.numberSensors; sensorID++)
367 errorCode = GetAsynchronousRecord(sensorID,
pRecord,
sizeof(
record));
370 nOfAttachedSensors++;
397 double sleepTime = updateRate - measurementDuration;
399 if (sleepTime > 0.0 && sleepTime < 500.0)
403 itksys::SystemTools::Delay(sleepTime)
432 if (toolNumber <
m_Tools.size())
449 return ((errorCode & 0xffff) == errorConstant);
456 char* pBuffer = &buffer[0];
463 errorCode = GetErrorText(errorCode, pBuffer,
sizeof(buffer), SIMPLE_MESSAGE);
473 for (ToolContainerType::iterator iterator =
m_Tools.begin(); iterator !=
m_Tools.end(); ++iterator)
474 (*iterator)->SetDataValid(
false);
virtual void SetErrorMessage(const char *_arg)
itk::FastMutexLock::Pointer m_TrackingFinishedMutex
mutex to manage control flow of StopTracking()
virtual bool CloseConnection()
Closes the connection.
superclass for specific MIRCOBIRD tracking Devices
virtual void InvalidateAll()
invalidates all tools (on stoptracking, closeconnection)
void HandleError(int errorCode)
bool CompareError(int errorCode, int errorConstant)
itk::FastMutexLock::Pointer m_ToolsMutex
virtual bool OpenConnection()
Builds up the connection (loads tools, initializes and enables them)
TrackingDeviceState GetState() const
return current object state (Setup, Ready or Tracking)
bool m_agcModeBoth
AGC (automatic gain control) mode flag.
itk::MultiThreader::Pointer m_MultiThreader
itk::MutexLockHolder< itk::FastMutexLock > MutexLockHolder
virtual bool StartTracking()
Start the tracking.
static ITK_THREAD_RETURN_TYPE ThreadStartTracking(void *data)
Helper function, because the itk::MultiThreader can only start a new thread with a static member func...
virtual TrackingTool * GetTool(unsigned int toolNumber)
returns a tracking tool that contains positional information about one of the sensors ...
virtual bool StopTracking()
stop retrieving tracking data from the device. stop retrieving tracking data from the device...
MicroBirdTrackingDevice()
DOUBLE_POSITION_QUATERNION_TIME_Q_RECORD * pRecord
One tracking data record (quaternion orientation format)
bool SwitchTransmitter(bool switchOn)
Switches the transmitter on resp. off.
BOOL m_metric
Specifies whether metric measurement is used.
SENSOR_CONFIGURATION * m_SensorConfig
The sensor configuration - used to get and set the sensor properties.
bool m_StopTracking
signal stop to tracking thread
Interface for all Tracking Devices.
SYSTEM_CONFIGURATION m_SystemConfig
The system configuration - used to specify its use.
virtual ~MicroBirdTrackingDevice()
vnl_quaternion< ScalarType > Quaternion
ToolContainerType m_Tools
double m_measurementRate
Specifies the measurement rate - default set to maximum.
double m_pl
Specifies the power line frequency (Europe 50Hz, USA 60Hz)
virtual bool StopTracking()
here we use the superclass method.
TrackingDeviceData m_Data
current device Data
itk::FastMutexLock::Pointer m_StopTrackingMutex
mutex to control access to m_StopTracking
virtual void TrackTools()
tracks the position and orientation of all tools until StopTracking() is called.
virtual unsigned int GetToolCount() const
returns a the number of attached sensors
TRANSMITTER_CONFIGURATION * m_TransmitterConfig
The transmitter configuration - used to get and set the transmitter properties.
void SetState(TrackingDeviceState state)
change object state
DOUBLE_POSITION_QUATERNION_TIME_Q_RECORD record
ToolType * GetMicroBirdTool(unsigned int toolNumber)
returns a tracking tool that contains positional information about one of the sensors ...