We are still having problems using the below code to access the tracker data. We put in a print line call to see if the call back method is ever being called and it never prints out anything.
We saw that there was no tracker->mainloop() or equivalent call any place in your most recent code. Is this something we should be concerned with?
Thanks,
Todd
Tracker.cpp
Code:
#include <string.h>
#include <vrpn_Tracker.h>
#include <iostream>
using namespace std;
#include "Tracker.h"
void handlePos(void *userdata, vrpn_TRACKERCB t)
{
Tracker *tracker = (Tracker*)userdata;
tracker->lastPosition[0] = t.pos[0];
tracker->lastPosition[1] = t.pos[1];
tracker->lastPosition[2] = t.pos[2];
cout << t.pos[0] << endl;
}
Tracker::Tracker(char* address)
{
cout << "Printed here" << endl;
tracker = new vrpn_Tracker_Remote(address);
//Setup callback for when new position data comes in
tracker->register_change_handler((void*)this, handlePos);
}
double Tracker::getXPos()
{
return 6.0;//lastPosition[0];
}
double Tracker::getYPos()
{
tracker->mainloop();
return lastPosition[1];
}
double Tracker::getZPos()
{
return lastPosition[2];
}
Tracker::~Tracker()
{
delete tracker;
}
Tracker.h
Code:
#include <vrpn_Tracker.h>
class Tracker{
public:
Tracker(char* address);
~Tracker();
vrpn_float64 lastPosition[3];
//double* getPosition();
double getXPos();
double getYPos();
double getZPos();
protected:
vrpn_Tracker_Remote* tracker;
};