BiiGOptitrackControl  ..
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
Optitrack::OptitrackTracker Class Reference

#include <OptitrackTracker.h>

Inheritance diagram for Optitrack::OptitrackTracker:

Public Types

enum  OPTITRACK_TRACKER_STATE {
  STATE_TRACKER_NoState = -1, STATE_TRACKER_Idle = 0, STATE_TRACKER_TrackerToolAttached = 1, STATE_TRACKER_CommunicationEstablished = 2,
  STATE_TRACKER_Tracking = 3, STATE_TRACKER_CalibratedState = 4, STATE_TRACKER_AttemptingToEstablishCommunication = 10, STATE_TRACKER_AttemptingToCloseCommunication = 11,
  STATE_TRACKER_AttemptingToTrack = 12, STATE_TRACKER_AttemptingToStopTracking = 13, STATE_TRACKER_AttemptingToUpdate = 14, STATE_TRACKER_AttemptingToLoadCalibration = 15,
  STATE_TRACKER_AttemptingToReset = 16, STATE_TRACKER_AttemptingToAttachTrackerTool = 17, STATE_TRACKER_AttemptingToStartTracking = 18, STATE_TRACKER_AttemptingToSetCameraParams = 19,
  STATE_TRACKER_AttemptingToDetachTrackerTool = 20, STATE_TRACKER_AttemptingToTestCalibration = 21
}
 Definition of the states for the machine behaviour. More...
 
enum  OPTITRACK_TRACKER_EVENT {
  EVENT_TRACKER_NoEvent = -1, EVENT_TRACKER_TrackerEvent = 0, EVENT_TRACKER_TrackerErrorEvent = 1, EVENT_TRACKER_TrackerOpenEvent = 2,
  EVENT_TRACKER_TrackerOpenErrorEvent = 3, EVENT_TRACKER_TrackerCloseEvent = 4, EVENT_TRACKER_TrackerCloseErrorEvent = 5, EVENT_TRACKER_TrackerInitializeEvent = 6,
  EVENT_TRACKER_TrackerInitializeErrorEvent = 7, EVENT_TRACKER_TrackerStartTrackingEvent = 8, EVENT_TRACKER_TrackerStartTrackingErrorEvent = 9, EVENT_TRACKER_TrackerStopTrackingEvent = 10,
  EVENT_TRACKER_TrackerStopTrackingErrorEvent = 11, EVENT_TRACKER_TrackerUpdateStatusEvent = 12, EVENT_TRACKER_TrackerUpdateStatusErrorEvent = 13
}
 Events that the class can launch NOT USED. More...
 

Public Member Functions

 BiiGOptitrackControlClassMacro (Optitrack::OptitrackTracker, itk::Object)
 
 itkNewMacro (Self)
 
ResultType Open (void)
 Open the Connection with the Tracker. Calls LoadCalibration function and set the system up with the calibration file. Remember that you have to set a calibration file first to open a correct connection to the Optical Tracking System. More...
 
ResultType Close (void)
 Close the Connection with the Tracker. Calls StopTracking function, delete the tool containes and shut down the system. More...
 
ResultType Reset (void)
 Set the system into Calibration State. Calls StopTracking function, does not delete the tool container. More...
 
ResultType StartTracking (void)
 Start to Track the tools already defined. If no tools are defined for this tracker, it returns an error. Tools can be added using AddTrackerTool. More...
 
ResultType StopTracking (void)
 Stop the Tracking Thread and tools will not longer be updated. More...
 
void TrackTools ()
 Update each tool location in the container m_LoadedTools. More...
 
void PrintSelf (std::ostream &os) const
 Print the object information in a stream. More...
 
ResultType RemoveTrackerTool (OptitrackTool::Pointer trackerTool)
 Remove tracker tool entry from internal containers. More...
 
ResultType AddTrackerTool (OptitrackTool::Pointer trackerTool)
 Add tracker tool entry to internal containers. More...
 
ResultType LoadCalibration (void)
 Load the Calibration file to the Optitrack System and set the cameras in calibrated locations. More...
 
unsigned int GetNumberOfAttachedTools (void)
 Returns the number of defined tools. More...
 
ResultType CheckNumberOfMarkers (void)
 Study if the number of markers is higher than 1 in the field of view. More...
 
ResultType TestCalibration (std::string FileName)
 Study if the calibration is correct by camera pairs study. More...
 
OptitrackTool::Pointer GetOptitrackTool (unsigned int toolID)
 Return the tool pointer of the tool number toolNumber. More...
 
OptitrackTool::Pointer GetOptitrackToolByName (std::string toolName)
 Return the tool pointer of the tool named toolNumber. More...
 
ResultType SetCameraParams (int exposure, int threshold, int intensity, int videoType=4)
 Set the Cameras Exposure, Threshold and Intensity of IR LEDs. By Default it set the Video type to 4: Precision Mode for tracking == VideoType: == 0 = Segment Mode == 1 = Grayscale Mode == 2 = Object Mode == 4 = Precision Mode == 6 = MJPEG Mode (V100R2 only) More...
 
 itkSetMacro (Exp, unsigned int)
 Sets the directory where the calibration file of the MicronTracker can be found. More...
 
 itkGetMacro (Exp, unsigned int)
 Gets the current calibration directory. More...
 
 itkSetMacro (Led, unsigned int)
 Sets the directory where the calibration file of the MicronTracker can be found. More...
 
 itkGetMacro (Led, unsigned int)
 Gets the current calibration directory. More...
 
 itkSetMacro (Thr, unsigned int)
 Sets the directory where the calibration file of the MicronTracker can be found. More...
 
 itkGetMacro (Thr, unsigned int)
 Gets the current calibration directory. More...
 
 itkSetMacro (VideoType, unsigned int)
 Sets the Video Type of Cameras. More...
 
 itkGetMacro (VideoType, unsigned int)
 Gets the Video Type of Cameras. More...
 
 itkGetMacro (CalibrationFile, std::string)
 Gets the current calibration file. More...
 
 itkSetMacro (CalibrationFile, std::string)
 Sets current calibration file. More...
 
unsigned int GetCameraNumber (void)
 Gets Current number of Connected Cameras. More...
 
OPTITRACK_TRACKER_EVENT GetEvent (void)
 Gets the tool Event. More...
 
OPTITRACK_TRACKER_STATE GetState (void)
 Gets the tool State. More...
 
ResultType LoadXMLConfigurationFile (std::string configurationFilePath)
 Loading XML configuration file. More...
 

Static Public Member Functions

static ITK_THREAD_RETURN_TYPE ThreadStartTracking (void *pInfoStruct)
 Start the Tracking Thread for the tools. More...
 

Protected Member Functions

 OptitrackTracker ()
 
 ~OptitrackTracker ()
 
 OptitrackTracker (const OptitrackTracker &)
 
const OptitrackTrackeroperator= (const OptitrackTracker &)
 
void SetEvent (OPTITRACK_TRACKER_EVENT event_)
 Sets the tool Event. More...
 
void SetState (OPTITRACK_TRACKER_STATE state_)
 Sets the tool State. More...
 
vnl_vector_fixed< double, 3 > Pivoting (unsigned int optitrackID, unsigned int sampleNumber)
 Tool pivot calibration. More...
 

Friends

class OptitrackTool
 

Member Enumeration Documentation

Events that the class can launch NOT USED.

Enumerator
EVENT_TRACKER_NoEvent 
EVENT_TRACKER_TrackerEvent 
EVENT_TRACKER_TrackerErrorEvent 
EVENT_TRACKER_TrackerOpenEvent 
EVENT_TRACKER_TrackerOpenErrorEvent 
EVENT_TRACKER_TrackerCloseEvent 
EVENT_TRACKER_TrackerCloseErrorEvent 
EVENT_TRACKER_TrackerInitializeEvent 
EVENT_TRACKER_TrackerInitializeErrorEvent 
EVENT_TRACKER_TrackerStartTrackingEvent 
EVENT_TRACKER_TrackerStartTrackingErrorEvent 
EVENT_TRACKER_TrackerStopTrackingEvent 
EVENT_TRACKER_TrackerStopTrackingErrorEvent 
EVENT_TRACKER_TrackerUpdateStatusEvent 
EVENT_TRACKER_TrackerUpdateStatusErrorEvent 

Definition of the states for the machine behaviour.

Enumerator
STATE_TRACKER_NoState 
STATE_TRACKER_Idle 
STATE_TRACKER_TrackerToolAttached 
STATE_TRACKER_CommunicationEstablished 
STATE_TRACKER_Tracking 
STATE_TRACKER_CalibratedState 
STATE_TRACKER_AttemptingToEstablishCommunication 
STATE_TRACKER_AttemptingToCloseCommunication 
STATE_TRACKER_AttemptingToTrack 
STATE_TRACKER_AttemptingToStopTracking 
STATE_TRACKER_AttemptingToUpdate 
STATE_TRACKER_AttemptingToLoadCalibration 
STATE_TRACKER_AttemptingToReset 
STATE_TRACKER_AttemptingToAttachTrackerTool 
STATE_TRACKER_AttemptingToStartTracking 
STATE_TRACKER_AttemptingToSetCameraParams 
STATE_TRACKER_AttemptingToDetachTrackerTool 
STATE_TRACKER_AttemptingToTestCalibration 

Constructor & Destructor Documentation

Optitrack::OptitrackTracker::OptitrackTracker ( )
protected
Optitrack::OptitrackTracker::~OptitrackTracker ( )
protected
Optitrack::OptitrackTracker::OptitrackTracker ( const OptitrackTracker )
protected

Member Function Documentation

ResultType Optitrack::OptitrackTracker::AddTrackerTool ( OptitrackTool::Pointer  trackerTool)

Add tracker tool entry to internal containers.

Addition of tool to the system.

Returns
Returns SUCCESS if the tool was uploaded correctly, FAILURE otherwise.

This function allows to add a tool to the system. The tool is attached and enabled.

Parameters
OptiTrackToolobject corresponding to the tool which wants to be added.
Returns
Result of the tool addition: SUCCESS or FAILURE.
Optitrack::OptitrackTracker::BiiGOptitrackControlClassMacro ( Optitrack::OptitrackTracker  ,
itk::Object   
)
ResultType Optitrack::OptitrackTracker::CheckNumberOfMarkers ( void  )

Study if the number of markers is higher than 1 in the field of view.

Checking single optical marker in FOV.

Returns
Returns SUCCESS if the test is passed (only one marker is visible).

This function checks if every camera in the system is visualizing a single marker. If every camera is visualizing one marker it returns SUCCESS. Otherwise, it returns FAILURE, and cameras visualizing more than one marker are identified.

Returns
Result of single marker visualization: SUCCESS or FAILURE.
ResultType Optitrack::OptitrackTracker::Close ( void  )

Close the Connection with the Tracker. Calls StopTracking function, delete the tool containes and shut down the system.

Shutdown of the system.

Returns
Returns SUCCESS if the disconnection was well performed. , FAILURE otherwise.

This function closes the system. First, it stops the tracking. Then, the system is shutdown. Finally, the function shuts down the camera device driver and ensures all the driver threads are terminated properly.

Returns
Result of the system shutdown: SUCCESS or FAILURE.
unsigned int Optitrack::OptitrackTracker::GetCameraNumber ( void  )

Gets Current number of Connected Cameras.

Getting the number of connected cameras.

This function provides the number of connected cameras.

Returns
Number of connected cameras [unsigned int].
OPTITRACK_TRACKER_EVENT Optitrack::OptitrackTracker::GetEvent ( void  )

Gets the tool Event.

unsigned int Optitrack::OptitrackTracker::GetNumberOfAttachedTools ( void  )

Returns the number of defined tools.

Obtaining the number of tools attached to the system.

Returns
Returns the number of defined tools in the Optitrack device.

This function provides the number of tools which are attached to the system.

Returns
Number of tools attached [unsigned int].
OptitrackTool::Pointer Optitrack::OptitrackTracker::GetOptitrackTool ( unsigned int  toolID)

Return the tool pointer of the tool number toolNumber.

Getting an OptiTrack tool by ID.

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.

This function provides an OptiTrack tool pointer given an specific tool ID.

Parameters
toolIDidentification number of the tool [unsigned int].
Returns
OptiTrack tool pointer.
OptitrackTool::Pointer Optitrack::OptitrackTracker::GetOptitrackToolByName ( std::string  toolName)

Return the tool pointer of the tool named toolNumber.

Getting an OptiTrack tool by name.

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.

This function provides an OptiTrack tool pointer given an specific tool name.

Parameters
toolIDname of the tool [string].
Returns
OptiTrack tool pointer.
OptitrackTracker::OPTITRACK_TRACKER_STATE Optitrack::OptitrackTracker::GetState ( void  )

Gets the tool State.

Get tracker state.

This function gets the tracker state.

Returns
Tracker state.
Optitrack::OptitrackTracker::itkGetMacro ( Exp  ,
unsigned  int 
)

Gets the current calibration directory.

Optitrack::OptitrackTracker::itkGetMacro ( Led  ,
unsigned  int 
)

Gets the current calibration directory.

Optitrack::OptitrackTracker::itkGetMacro ( Thr  ,
unsigned  int 
)

Gets the current calibration directory.

Optitrack::OptitrackTracker::itkGetMacro ( VideoType  ,
unsigned  int 
)

Gets the Video Type of Cameras.

Optitrack::OptitrackTracker::itkGetMacro ( CalibrationFile  ,
std::string   
)

Gets the current calibration file.

Optitrack::OptitrackTracker::itkNewMacro ( Self  )
Optitrack::OptitrackTracker::itkSetMacro ( Exp  ,
unsigned  int 
)

Sets the directory where the calibration file of the MicronTracker can be found.

Optitrack::OptitrackTracker::itkSetMacro ( Led  ,
unsigned  int 
)

Sets the directory where the calibration file of the MicronTracker can be found.

Optitrack::OptitrackTracker::itkSetMacro ( Thr  ,
unsigned  int 
)

Sets the directory where the calibration file of the MicronTracker can be found.

Optitrack::OptitrackTracker::itkSetMacro ( VideoType  ,
unsigned  int 
)

Sets the Video Type of Cameras.

Optitrack::OptitrackTracker::itkSetMacro ( CalibrationFile  ,
std::string   
)

Sets current calibration file.

ResultType Optitrack::OptitrackTracker::LoadCalibration ( void  )

Load the Calibration file to the Optitrack System and set the cameras in calibrated locations.

Load the calibration file.

Returns
Returns SUCCESS if the calibration was uploaded correctly, FAILURE otherwise.

This function allows the system to load the calibration file of the OptiTrack system. For a correct loading of the file the system must have been initialized and the file must be optimum (.cal extension).

Returns
Result of calibration file loading: SUCCESS or FAILURE.
ResultType Optitrack::OptitrackTracker::LoadXMLConfigurationFile ( std::string  nameFile)

Loading XML configuration file.

This function loads the configuration file of the system containing: the calibration file path, the camera settings (exposure, threshold, and intensity), and the list of used tools.

Parameters
nameFilepath of the ".xml" configuration file.
Returns
Result of the file loading: SUCESS (1) or FAILURE (0).
ResultType Optitrack::OptitrackTracker::Open ( void  )

Open the Connection with the Tracker. Calls LoadCalibration function and set the system up with the calibration file. Remember that you have to set a calibration file first to open a correct connection to the Optical Tracking System.

Initialization of the system.

Returns
Returns SUCCESS if the connection is well done. , FAILURE otherwise.

This function allows the system to be initialized.

Returns
Result of the system initialization: SUCCESS or FAILURE.
const OptitrackTracker& Optitrack::OptitrackTracker::operator= ( const OptitrackTracker )
protected
vnl_vector_fixed< double, 3 > Optitrack::OptitrackTracker::Pivoting ( unsigned int  optitrackID,
unsigned int  sampleNumber 
)
protected

Tool pivot calibration.

This function acquires a number of samples of the pivoting procedure and computes the resultant pivot offset.

Parameters
optitrackIDOptiTrack identification number of the tool used for pivoting.
sampleNumbernumber of samples acquired during the pivoting.
Returns
Pivot offset [vnl_vector_fixed].
void Optitrack::OptitrackTracker::PrintSelf ( std::ostream &  os) const

Print the object information in a stream.

ResultType Optitrack::OptitrackTracker::RemoveTrackerTool ( OptitrackTool::Pointer  trackerTool)

Remove tracker tool entry from internal containers.

Removal of tool from the system.

Returns
Returns SUCCESS if the tool was removed correctly, FAILURE otherwise.

This function allows to remove a tool from the system. The tool is disabled and dettached.

Parameters
OptiTrackToolobject corresponding to the tool which wants to be removed.
Returns
Result of the tool removal: SUCCESS or FAILURE.
ResultType Optitrack::OptitrackTracker::Reset ( void  )

Set the system into Calibration State. Calls StopTracking function, does not delete the tool container.

Reset of the system.

Returns
Returns SUCCESS if the reset was well performed. , FAILURE otherwise.

This function resets the system. The tracking is stopped and all currently loaded rigid body definitions are removed. This reset enables the system to load a new calibration file.

Returns
Result of the system reset: SUCCESS or FAILURE.
ResultType Optitrack::OptitrackTracker::SetCameraParams ( int  exposure,
int  threshold,
int  intensity,
int  videoType = 4 
)

Set the Cameras Exposure, Threshold and Intensity of IR LEDs. By Default it set the Video type to 4: Precision Mode for tracking == VideoType: == 0 = Segment Mode == 1 = Grayscale Mode == 2 = Object Mode == 4 = Precision Mode == 6 = MJPEG Mode (V100R2 only)

Setting of camera parameters.

Returns
Returns ResultType SUCCESS if all cameras were set up correctly

This function allows to set some of the camera settings to the whole set of cameras, such as exposure, threshold, illumination, and video mode.

Parameters
exposureValid values are 1-480.
thresholdPixels with intensities darker than this value will be filtered out when using processed video modes. Valid values are 0-255.
intensityThis should be set to 15 for almost all situations. The recommended method for reducing IR LED brightness is to lower the camera exposure setting, this has the effect of shortening the IR strobe duration. Valid values are 0-15.
videoTypeThe desired in-camera video processing mode. Valid values are: Segment Mode (0), Grayscale Mode (1), Object Mode (2), Precision Mode (4), and MJPEG Mode (V100R2 only) (6).
Returns
Result of the camera parameters setting: SUCCESS or FAILURE.
void Optitrack::OptitrackTracker::SetEvent ( OPTITRACK_TRACKER_EVENT  event_)
protected

Sets the tool Event.

void Optitrack::OptitrackTracker::SetState ( OptitrackTracker::OPTITRACK_TRACKER_STATE  state_)
protected

Sets the tool State.

Set tracker state.

This function sets the tracker state.

ResultType Optitrack::OptitrackTracker::StartTracking ( void  )

Start to Track the tools already defined. If no tools are defined for this tracker, it returns an error. Tools can be added using AddTrackerTool.

Starting the tracking of tools.

Returns
Returns SUCCESS at least one tool was defined and the tracking is correct, FAILURE otherwise.

This function starts the tracking of all tools attached by launching a thread.

Returns
Result of the tracking initialization: SUCCESS or FAILURE.
ResultType Optitrack::OptitrackTracker::StopTracking ( void  )

Stop the Tracking Thread and tools will not longer be updated.

Stopping the tracking of tools.

Returns
Returns SUCCESS if Tracking thread could be stopped, FAILURE otherwise.

This function stops the tracking of tools.

Returns
Result of the tracking stoppage: SUCCESS or FAILURE.
ResultType Optitrack::OptitrackTracker::TestCalibration ( std::string  FileName)

Study if the calibration is correct by camera pairs study.

Creating a data file to check calibration state of the system.

Returns
Returns SUCCESS if test was performed

This function acquires 1000 samples of the 3D position of the markers using all cameras in the system. Also, it acquires 1000 samples of the 3D position and the 2D position of the markers using all possible combinations of camera pairs . All data (cameras involved, 2D positions, and 3D positions) is saved into a ".csv" file. Calibration state can be inferred placing a single and static reflective marker in the FOV of the cameras, and comparing the 3D position of the marker acquired using the complete system and all differente camera pairs.

Parameters
FileNamename of the ".csv" file to save tracking information.
Returns
Result of data updating: 0 if success, 11 if TrackingTools license is invalid, and 14 if there is no available frame.

< the output stream

ITK_THREAD_RETURN_TYPE Optitrack::OptitrackTracker::ThreadStartTracking ( void *  pInfoStruct)
static

Start the Tracking Thread for the tools.

Tracking thread.

This function handles the ITK thread for the tracking.

Returns
Return 0.
void Optitrack::OptitrackTracker::TrackTools ( )

Update each tool location in the container m_LoadedTools.

Tracking of attached tools.

This function tracks all tools attached to the system.

Friends And Related Function Documentation

friend class OptitrackTool
friend

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