Page MenuHomePhabricator

Tracking device outputs are not connected
Closed, ResolvedPublic

Description

In the newer versions of MITK (2013-06, 2013-09) and maybe earlier, the input/output mechanism of a mitk::TrackingDeviceSource changed to a cached primary output. Here 2 error occure in
mitk::TrackingDeviceSource->SetTrackingDevice() or mitk::TrackingDeviceSource->Connect() which both call mitk::TrackingDeviceSource::CreateOutputs().

mitkTrackingDeviceSource.cpp

  1. Line 114 "for (unsigned int numOP = this->GetNumberOfOutputs(); numOP>0; numOP--)" will try to fetch the non existing "last" output, because ->GetNumberOfOutputs() is always one larger than the actual amount of outputs, which starts from "0...i"
  1. Lines 123 and 124.

this->SetNumberOfIndexedOutputs(m_TrackingDevice->GetToolCount());
unsigned int numberOfOutputs = this->GetNumberOfIndexedOutputs();

Line 123 determines how many tools have to be additionally added to the primary output. In an example case with 1 tools, the SetNumberOfIndexedOutputs() will utilize the primary output, which still is NULL. Therefore we don't have an IndexedOutput. As a result, the next line 124 will return numberOfOutputs = 0, which leads to no connected outputs in the following lines 127-136. The data pipeline of NavigationDataSource will never hold any SensorData.

Event Timeline

An easy and quick fix should be:

replacing line 114:
for (unsigned int numOP = this->GetNumberOfOutputs(); numOP>0; numOP--)
with:
for (unsigned int numOP = this->GetNumberOfOutputs()-1; numOP>0; numOP--)

and

line 127:
for (unsigned int idx = 0; idx < numberOfOutputs; ++idx)
with:
for (unsigned int idx = 0; idx < m_TrackingDevice->GetToolCount(); ++idx)

I'm not quite sure it the second fix will screw up the primary output in some way, because I did not find any other class that would init the primary output automatically.

New remote branch pushed: bug-16445-TrackingDeviceOutputsAreNotConnected

I agree that this is a bug (which makes me wonder how that worked until now...)

There are several calls to this function commented out in the class, mostly without comments unfortunatley. We definitley need to rework this in the long run, but this should do for now.

[185648]: Merge branch 'bug-16445-TrackingDeviceOutputsAreNotConnected'

Merged commits:

2013-11-26 14:10:22 Keno Maerz [7d0b1c]
Extended Documentation for CreateOutputs


2013-11-26 14:09:13 Keno Maerz [83cf93]
Fixed wrong indexes in CreateOutputs()

[a84c3e]: COMP: Merge branch 'bug-16445-TrackingDeviceOutputsAreNotConnected'

Merged commits:

2013-12-04 14:27:45 Keno Maerz [52d65e]
COMP: Changed unsigned int to int, now avoiding endless for loop


2013-11-26 16:11:31 Keno Maerz [b448a1]
Merge remote-tracking branch 'remotes/origin/bug-16510-EmptyToolStorageExceptionIsNotCaughtOnToolStorageDeserialisation' into bug-16445-TrackingDeviceOutputsAreNotConnected