I am sorry, I do not have much of an experience in working with C++ variables exposed through Python, so I basically wanted to understand how to go about viewing the Controller Pose in Python. After my query, I took the bit of code “vrView=getNode(‘VirtualRealityView’)” on the page https://github.com/KitwareMedical/SlicerVirtualReality/blob/master/DeveloperGuide.md as my starting point and realized that I need to fetch the ‘node’ for one of the controllers (left in my case). I will post the process I followed, in case someone is stuck like I was.
First thing I tried was printing the vrView variable above. It contained a node called
I used the above syntax to get “LCon= getNode(‘vtkMRMLLinearTransformNodeVirtualReality.LeftController’)”
Printing the above LCon variable gave me the first glimpse of the transformation matrix for the Left Controller. Then I was again stuck at extracting that matrix for a very long time when dir(LCon) came to my rescue and I was able to extract the matrix part using:
This TMatrix is again an object whose individual elements have to be accessed by:
Where x,y are the row and column numbers. I am still not able to get the whole 4x4 matrix in a single go.
Phew! Now, my question is, is there a shorter way to go about it?
And, the main reason why I am doing this, is to get 3 points in the horizontal plane of the Controller so that I can pass them as fiducials to the code at https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Set_slice_position_and_orientation_from_3_markup_fiducials so that I can display a slice based on the Pose of the controller.
Any ideas how I can go about getting those fiducial points from the transformation matrix?