以下に投稿したコードは、基本的に、ソフトウェアから (連続ストリーミング データ) を取得し、受信したデータを表示するために使用されます。私が直面している問題は、ソフトウェア (既に「サーバー」を持っている) が Windows 上にあるということですが、Linux (Ubuntu) を実行している別のシステムでデータを取得する必要があります。
Linuxで動作させるためにコードにどのような変更を加える必要があるかについて、誰かが私を導くことができますか?
また、それらはネットワークを介して「通信」しているため、Windows マシン上のサーバーを指すようにコードに変更はありますか? (このような用語で申し訳ありません。私はこれに少し慣れていないので、間違っている場合は修正してください)
#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]);
}
これに代わる「より簡単な」代替案も提案していただければ幸いです。ありがとうございました!