Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
How To Implement A Tracking Device

If you want to implement your own Tracking device, you need to do the following (see e.g. mitk::VirtualTrackerTypeInformation):

  1. Derive a class MyAwesomeTrackingDeviceInformation from the abstract class mitk::TrackingDeviceTypeInformation
  2. In the constructor of your class
    1. give your device a unique name ("my awesome device")
    2. push back at least one mitk::TrackingDeviceData corresponding to your device to m_TrackingDeviceData (mitk::TrackingDeviceType member 'Line' needs to be identical to your chosen device name "my awesome device")
  3. Implement the method mitk::TrackingDeviceTypeInformation::CreateTrackingDeviceSource.

Recommended steps (but not necessary):

  1. Provide a static method to get your tracking device name.

    static std::string MyAwesomeTrackingDeviceInformation::GetTrackingDeviceName()
    return "my awesome device";

    Use this method in your constructor for step 2a) and 2b).

    This method will make it easier to implement options for your device in any other Module/Plugin. If you want to check if the device in use is your device, you need to compare the names - and this can now be done in any Plugin just by calling this static method. And if you later on decide to change the name of your device into "my One And Only Device" - there is only one line of code you'll have to adapt.
    Attention: If you change the name, you must edit all tool storages which were saved, e.g. using The MITK-IGT Navigation Tool Manager .
    Attention: You should use a static method instead of static variables due to the initialization order of static variables and the autoload module.

  2. Provide static methods for all your mitk::TrackingDeviceData.
    TrackingDeviceData MyAwesomeTrackingDeviceInformation::GetDeviceDataForMyFirstDevice()
    return{ MyAwesomeTrackingDeviceInformation::GetTrackingDeviceName(), "my Model", "my model volume location", "my hardware code" };
  3. Register your Tracking Device to the collection:

    #include <usModule.h>
    mitk::TrackingDeviceTypeCollection* m_DeviceTypeCollection;
    us::ModuleContext* context = us::GetModuleContext();
    std::vector<us::ServiceReference<mitk::TrackingDeviceTypeCollection> > refs = context->GetServiceReferences<mitk::TrackingDeviceTypeCollection>();
    if (refs.empty())
    MITK_ERROR << "No tracking device service found!";
    m_DeviceTypeCollection = context->GetService<mitk::TrackingDeviceTypeCollection>(refs.front());
    m_DeviceTypeCollection->RegisterTrackingDeviceType(new mitk::MyAwesomeTrackingDeviceInformation());

    You can do the registration anywhere in your code, also from external projects. We recommend doing the registration of your tracking device in the autoload function of your module. Devices, which should be always available (e.g. Polaris, Aurora, Virtual, ...) are registered in mitk::IGTActivator.

  4. Implement a widget to configure your device and register it to the collection
    1. Derive a Widget class QmitkMyAwesomeTrackingDeviceWidget from QmitkAbstractTrackingDeviceWidget. Please follow the steps as explained in QmitkAbstractTrackingDeviceWidget.h
    2. Create a .ui file
    3. Register it to mitk::TrackingDeviceWidgetCollection
      m_DeviceWidgetCollection.RegisterTrackingDeviceWidget(mitk::MyAwesomeTrackingDeviceInformation::GetTrackingDeviceName(), new QmitkMyAwesomeTrackingDeviceWidget);
      You can get the Widget collection analogous to step 3, replacing mitk::TrackingDeviceTypeCollection with mitk::TrackingDeviceWidgetCollection.

Your tracking device should now be available in other Plugins, e.g. The MITK-IGT Tracking Toolbox .

#define MITK_ERROR
Definition: mitkLogMacros.h:20
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Definition: usGetModuleContext.h:50
This class is a collection for information of all Tracking Device Types (derived from abstract Tracki...
Definition: mitkTrackingDeviceTypeCollection.h:35
void RegisterTrackingDeviceType(TrackingDeviceTypeInformation *typeInformation)