[vtkusers] SynchroGrab4D, vtk Polaris tracking

luta sharmaatul11 at gmail.com
Mon Jul 20 00:14:40 EDT 2015


Dear David,

Thanks a lot for your kind help. I am able to find the co-ordinates and
orientation of the tool. I am posting my complete code in this thread in
case anyone need it. Thanks again for your help
Regards,
Atul

#include "vtkNDITracker.h"
#include <string>
#include "vtkTrackerTool.h"
#include "vtkTransform.h"
using namespace std;

class Starttracker_aks 
{
vtkNDITracker* newtracker;
int tool;
const char *filename;
public:
void asignvalues()
		{ // setting up the tracker 
			newtracker
		=  vtkNDITracker::New(); // instantiate a new tracker
		tool=3; // 0,1,2 if active tools.. // 3,4,5.. are for passive tools
		newtracker->SetSerialDevice("COM5:"); // COM port identified at the device
manager
		// load tools
		filename=
"C:\\ATUL_WORKS\\SOFTWARES\\vtkptog\\Cone\\Cone_Aks\\ToolKit\\8700340Probe.rom";
// srom file for the probe tool
		newtracker->LoadVirtualSROM(tool,filename);
		// check status of the tracker
		int statust= newtracker->IsTracking() ; // tracker is not running now.
		// beep once 
		newtracker->Command("BEEP:1");
		// start tracking and activate the tool handles
		newtracker->StartTracking(); // tracker starts .
		newtracker->Update(); // tool activation .
		
		vtkTrackerTool* gettool;
	   gettool=newtracker->GetTool(tool); // get the tool with it's tool number
		for (int k = 0; k <20; k++)
			{    
				  vtkTransform *toolTransform = gettool->GetTransform(); // get the
transform of the tool with respect to the tracker reference frame
				  // output the transform value (3D position and orientation)
				  double position[3] = { 0.0, 0.0, 0.0 }; 
				  toolTransform->TransformPoint(position, position); // Get position
				  double position1[3];
				  toolTransform->GetPosition(position1);// Get position
				  double orientation[3];
				  toolTransform->GetOrientation(orientation);// Get orientation
				  if (gettool->IsOutOfView())//(gettool->IsMissing()) // check if the
tool is out of view
					  {
					  cout << "MISSING" << endl;
					  }
				  else
					  {
						cout << "Position:\t"<< position[0] << "\t" << position[1] << "\t" <<
position[2] << endl; // position output
						 cout << "Position:\t" << position1[0]	<< "\t" << position1[1]	<< "\t"
<< position1[2]	<<"\n"; // position output
						cout << "Orientation:\t" << orientation[0]	<< "\t" << orientation[1]
<< "\t" << orientation[2]	<<"\n"; // orientation output
				  }
					::Sleep(200); // wait for 200 milliseconds before trying again
					newtracker->Update();// find the new location
			}
		statust= newtracker->IsTracking() ;// check if the tracker still running
		cout <<"current running Status:\t "<< statust << "\n"; 
		}
};

int main(int, char *[])
{  
Starttracker_aks statr;
statr.asignvalues();
return EXIT_SUCCESS; 
}




--
View this message in context: http://vtk.1045678.n5.nabble.com/SynchroGrab4D-vtk-Polaris-tracking-tp4600704p5732975.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list