The code that I have posted below, is basically used to get (continuous streaming data) from a software and display that data as it is received. The issue that I am facing is, that the software (which already has the "server") is on Windows, but I need to get the data on a separate system running Linux (Ubuntu).
Can anyone guide me regarding what changes do I need to make to the code in-order to make it work on Linux?
Also since they are "communicating" over a network, will there be any changes in the code to point to the server on the windows machine? ( I am sorry for such terminology, I am a bit new to this, so please correct me if I am mistaken)
#include "vrpn_Connection.h" // Missing this file? Get the latest VRPN distro at
#include "vrpn_Tracker.h" // ftp://ftp.cs.unc.edu/pub/packages/GRIP/vrpn
#include "conio.h" // for kbhit()
//== Callback prototype ==--
void VRPN_CALLBACK handle_pos (void *, const vrpn_TRACKERCB t);
//== Main entry point ==--
int main(int argc, char* argv[])
{
vrpn_Connection *connection;
char connectionName[128];
int port = 3883;
sprintf(connectionName,"localhost:%d", port);
connection = vrpn_get_connection_by_name(connectionName);
vrpn_Tracker_Remote *tracker = new vrpn_Tracker_Remote("Tracker", connection);
tracker->register_change_handler(NULL, handle_pos);
while(!kbhit())
{
tracker->mainloop();
connection->mainloop();
Sleep(5);
}
return 0;
}
//== Position/Orientation Callback ==--
void VRPN_CALLBACK handle_pos (void *, const vrpn_TRACKERCB t)
{
printf("Tracker Position:(%.4f,%.4f,%.4f) Orientation:(%.2f,%.2f,%.2f,%.2f)\n",
t.pos[0], t.pos[1], t.pos[2],
t.quat[0], t.quat[1], t.quat[2], t.quat[3]);
}
I would appreciate if anyone could suggest an "easier" alternate to this as well. Thank you!