WorldViz User Forum  

Go Back   WorldViz User Forum > Precision Position Tracker (PPT)

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 02-14-2006, 12:35 PM
MiamiTodd MiamiTodd is offline
Member
 
Join Date: Feb 2006
Posts: 15
This looks to be just what I needed. Thanks ever so much!
Reply With Quote
  #2  
Old 02-24-2006, 01:38 PM
MiamiTodd MiamiTodd is offline
Member
 
Join Date: Feb 2006
Posts: 15
Perhaps I spoke a bit too soon. When I try to create a project and compile it after compiling the VRPN source code I get all sorts of errors regarding the extern "C" lines and other extern lines in the VRPN source if I compile it as a C module.

I did manage to get to a certain point using C++ project though. But when I try to compile the code I get the following error:
...\extender\Tracker.cpp(8): error C2664: 'int vrpn_Tracker_Remote::register_change_handler(void *,vrpn_TRACKERCHANGEHANDLER,vrpn_int32)' : cannot convert parameter 2 from 'void (void *,vrpn_TRACKERCB)' to 'vrpn_TRACKERCHANGEHANDLER'

I'm trying to get a dll compiled from the below code:

(Tracker.h)
Code:
#include <vrpn_Tracker.h>

class Tracker{
public:
	Tracker(char* address);
	int* getPosition();
	void handlePos(void *userdata, vrpn_TRACKERCHANGEHANDLER t);
	
	vrpn_Tracker_Remote* tracker;
	vrpn_float64* lastPosition;
};
(Tracker.cpp)
Code:
#include <string.h>
#include <vrpn_Tracker.h>
#include "Tracker.h"

Tracker::Tracker(char* address){
	tracker = new vrpn_Tracker_Remote(address);
	//Setup callback for when new position data comes in
	tracker->register_change_handler(NULL, handlePos);
	lastPosition = new vrpn_float64[3];
}

Tracker::handlePos(void *userdata, vrpn_TRACKERCB t){
	lastPosition[0] = t.pos[0];
	lastPosition[1] = t.pos[1];
	lastPosition[2] = t.pos[2];
}

Tracker::getPosition(){
	return lastPosition;
}
I've tried chaning several things such as the vrpn_TRACKERCB to the vrpn_TRACKERCHANGEHANDLER but this doesn't seem to make any headway. I am unfortunately not familiar enough with C/C++ to recognize any simple errors I might be inducing here. Any help you can offer is greatly appreciated.
Reply With Quote
  #3  
Old 02-24-2006, 01:56 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I don't think you can use VRPN with C, you must use C++. Which version of VRPN are you using? The code I supplied you was based on version 6.06. If you have a newer version then that code might now work.
Reply With Quote
  #4  
Old 02-24-2006, 02:05 PM
MiamiTodd MiamiTodd is offline
Member
 
Join Date: Feb 2006
Posts: 15
The VRPN base is vrpn_06_06.beta9. It was the only 6.6 I could find on their site.

The reason I changed the format to a class was so that the callback would be called again and again and the users that import the dll into python would have access to the most currently recorded position data. It looked like the skeleton provided wouldn't store that data or keep running.

As well the requirements for wrapping that code into an importable module for python required the restructuring from what I could tell. I assume from what I have read that the import in python extensions calls an intializer method once, which makes sense to me to be the spot to make the connection to the tracker. Then have a method that allows the users to fetch the data, hence the getPosition in the above code segments. As well, from what I have read, the callback has to be something that can be called by the VRPN separately so I just had that write the most recent data into the classes data member that would be returned on request.

Does this sound right or completely off base?

Thanks,
Todd
Reply With Quote
  #5  
Old 02-24-2006, 02:22 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Your vrpn callback must be a function. You are trying to pass a class method instead, which won't work. Try the following instead:

(Tracker.h)
Code:
#include <vrpn_Tracker.h>

class Tracker{
public:
	Tracker(char* address);
	~Tracker();

	vrpn_float64 lastPosition[3];

protected:
	vrpn_Tracker_Remote* tracker;
};
(Tracker.cpp)
Code:
#include <string.h>
#include <vrpn_Tracker.h>
#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];
}

Tracker::Tracker(char* address)
{
	tracker = new vrpn_Tracker_Remote(address);
	//Setup callback for when new position data comes in
	tracker->register_change_handler((void*)this, handlePos);
}

Tracker::~Tracker()
{
    delete tracker;
}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:00 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC