[vtkusers] SynchroGrab4D, vtk Polaris tracking
David Gobbi
david.gobbi at gmail.com
Sat Jul 18 08:57:45 EDT 2015
Hi Atul,
Get the tool positions from the vtkTrackerTool objects. For example:
for (int k = 0; k < 10000; k++)
{
vtkTransform *toolTransform = gettool->GetTransform();
double position[3] = { 0.0, 0.0, 0.0 };
toolTransform->TransformPoint(position, position);
if (gettool->IsMissing())
{
cout << "MISSING" << endl;
}
else
{
cout << position[0] << " " << position[1] << " " << position[2] <<
endl;
}
::Sleep(200); // wait for 200 milliseconds before trying again
}
On Fri, Jul 17, 2015 at 10:56 PM, luta <sharmaatul11 at gmail.com> wrote:
> Dear David,
> Thank you so much for your help. I followed your instructions and got some
> success in moving ahead. However, I am NOT able to get the 3D position of
> the markers. I get the values +00 or some random values when I apply the
> command "Command("3D:011")" . I was expecting it to be x,y,z coordinate
> value with the error value. Following is the current status of the code and
> the results. Our team and I really appreciate your kind help.
>
> #include <vtkConeSource.h>
> #include <vtkPolyData.h>
> #include <vtkSmartPointer.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkActor.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindowInteractor.h>
> #include "vtkNDITracker.h"
> #include <string>
> #include "ndicapi.h"
> #include "vtkMatrix4x4.h"
> #include "vtkTrackerTool.h"
> using namespace std;
>
> class Starttracker_aks
> {
> vtkNDITracker* newtracker;
> int x;
> int tool;
> const char *filename;
> public:
> void asignvalues()
> { // setting up the tracker
> newtracker
> = vtkNDITracker::New();
> tool=3;
> filename=
>
> "C:\\ATUL_WORKS\\SOFTWARES\\vtkptog\\Cone\\Cone_Aks\\ToolKit\\8700340Probe.rom";
> string versionname;
> int serialname;
> newtracker->SetSerialDevice("COM5:");
> newtracker->Probe();
> // get the values from the tracker
> cout <<"GetSerialPort:\t "<< newtracker->GetSerialPort()
> << "\n";
> cout <<"GetSerialDevice:\t "<<
> newtracker->GetSerialDevice() << "\n";
> cout <<"GetBaudRate:\t "<< newtracker->GetBaudRate() <<
> "\n";
> // load tools
> newtracker->LoadVirtualSROM(tool,filename);
> // check status of the tracker
> int statust= newtracker->IsTracking() ;
> newtracker->Command("BEEP:1");
> *// start tracking and activate the tool handles*
> *newtracker->StartTracking();
> newtracker->Update();
> cout <<"updaterate rate:\t "<<
> newtracker->GetInternalUpdateRate() <<
> "\n";
> // get the 3D positions of the tool
> for(int k=1;k<3;k++)
> {
> cout << "3D coordinates:\t" <<
> newtracker->Command("3D:011")<< "\n";
> }*
> // get world calibration matrix:
> cout << "GetWorldCalibrationMatrix:\t"<< "\n";
> vtkMatrix4x4*
> matrixw=newtracker->GetWorldCalibrationMatrix();
> for(int i =0 ; i<4;i++) {
> for(int j =0 ; j<4;j++){
> cout << matrixw->GetElement(i,j) << "\t" ;
> }
> cout << "\n";
> }
> // Check the current status of the tracke and tool
> versionname=GetVersion();
>
> vtkTrackerTool* gettool;
> gettool=newtracker->GetTool(tool);
>
> cout <<"Is the tracker Missing:\t "<< gettool->IsMissing()
> << "\n";
> cout <<"gettool variable:\t "<< gettool << "\n";
> cout <<"Version:\t "<< newtracker->GetVersion() << "\n";
> statust= newtracker->IsTracking() ;
> cout <<"current running Status:\t "<< statust << "\n";
> double updaterate= newtracker->GetInternalUpdateRate();
> cout <<"current updaterate Status:\t "<< updaterate <<
> "\n";
> cout <<"ECHO:\t "<< newtracker->Command("ECHO:Tracker
> Running") << "\n";
> }
> };
>
> int main(int, char *[])
> { // ndicapi* yourdevice;
> Starttracker_aks statr;
> statr.asignvalues();
> return EXIT_SUCCESS;
> }
>
> <http://vtk.1045678.n5.nabble.com/file/n5732969/ErrorDay2.jpg>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/SynchroGrab4D-vtk-Polaris-tracking-tp4600704p5732969.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150718/a3305039/attachment.html>
More information about the vtkusers
mailing list