I’m coding a scripted module that handles an OpenIGTLink connection to a tracker and I experience some delay between the call to start the connection and when the incoming data is actually streamed.
I have tried using the solution proposed here by @lassoan but it seems the ConnectedEvent is still sent prior to the actual streaming. With the code below, I still get 0 incoming MRML node at run time, but shortly after I can definitely see the incoming node in the Data tree of Slicer.
self.cnode = slicer.vtkMRMLIGTLConnectorNode() self.cnode.SetName('PointerConnector') slicer.mrmlScene.AddNode(self.cnode) self.addObserver(self.cnode, slicer.vtkMRMLIGTLConnectorNode.ConnectedEvent, self.onConnected) if self.cnode.Start() != 1: slicer.util.errorDisplay("Cannot connect to openIGTLink") def onConnected(self, caller, event): if self.cnode.GetNumberOfIncomingMRMLNodes() == 0: slicer.util.errorDisplay("No data streamed") elif cnode.GetIncomingMRMLNode(0).GetClassName() != 'vtkMRMLLinearTransformNode': slicer.util.errorDisplay("Streamed data not a linear transform") else: self.pointerTransform = cnode.GetIncomingMRMLNode(0)
Thank you for any help,