From 43420d828647b026a315c58db621202fc5a17403 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Tue, 8 Feb 2011 21:17:36 +0000 Subject: Updating FlightGear protocol git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@49 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR.suo | Bin 347136 -> 347136 bytes .../ClientFiles/FlightGear/Nasal/headtracker.xml | 16 ----- FaceTrackNoIR/FGServer.cpp | 68 ++++++++++++--------- FaceTrackNoIR/tracker.cpp | 2 - bin/FaceTrackNoIR.exe | Bin 761856 -> 761856 bytes bin/Settings/FlightGear.ini | 25 ++++++-- 6 files changed, 57 insertions(+), 54 deletions(-) diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo index a9d31016..2d013289 100644 Binary files a/FaceTrackNoIR.suo and b/FaceTrackNoIR.suo differ diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml b/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml index 0d6e8005..d8bd1d0a 100644 --- a/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml +++ b/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml @@ -1,19 +1,6 @@ - - - - = (equal sign) - Reset Head Tracker - - nasal - - - - - - diff --git a/FaceTrackNoIR/FGServer.cpp b/FaceTrackNoIR/FGServer.cpp index 53cd68ff..292c194b 100644 --- a/FaceTrackNoIR/FGServer.cpp +++ b/FaceTrackNoIR/FGServer.cpp @@ -61,22 +61,6 @@ int no_bytes; QHostAddress sender; quint16 senderPort; - // - // Create UDP-sockets if they don't exist already. - // They must be created here, because they must be in the Tracker thread (Tracker::run()) - // - if (inSocket == 0) { - qDebug() << "FGServer::sendHeadposeToGame creating sockets"; - inSocket = new QUdpSocket(); - // Connect the inSocket to the port, to receive messages -// inSocket->bind(QHostAddress::LocalHost, 5551); - inSocket->bind(QHostAddress::Any, destPort+1); - } - - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - // // Copy the Raw measurements directly to the client. // @@ -94,28 +78,32 @@ quint16 senderPort; //! [1] // no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), QHostAddress::LocalHost, 5550); - no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort); - if ( no_bytes > 0) { -// qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); - } - else { - qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; + if (outSocket != 0) { + no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort); + if ( no_bytes > 0) { + // qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); + } + else { + qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; + } } // // FlightGear keeps sending data, so we must read that here. // - while (inSocket->hasPendingDatagrams()) { + if (inSocket != 0) { + while (inSocket->hasPendingDatagrams()) { - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); + QByteArray datagram; + datagram.resize(inSocket->pendingDatagramSize()); - inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); + inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); - fg_cmd = cmd; // Let's just accept that command for now... - if ( cmd > 0 ) { - qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; - headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle + fg_cmd = cmd; // Let's just accept that command for now... + if ( cmd > 0 ) { + qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; + headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle + } } } } @@ -139,6 +127,26 @@ bool FGServer::checkServerInstallationOK( HANDLE handle ) inSocket = 0; outSocket = 0; + // + // Create UDP-sockets. + // + if (inSocket == 0) { + qDebug() << "FGServer::sendHeadposeToGame creating insocket"; + inSocket = new QUdpSocket(); + + // Connect the inSocket to the port, to receive messages + if (!inSocket->bind(QHostAddress::Any, destPort+1)) { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); + delete inSocket; + inSocket = 0; + return false; + } + } + + if (outSocket == 0) { + outSocket = new QUdpSocket(); + } + return true; } diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 91c386c0..5a2d07a2 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -321,8 +321,6 @@ void Tracker::run() { float rawrotX, rawrotY, rawrotZ; // Locals... float rawposX, rawposY, rawposZ; - //float new_camera_position.pitch, new_camera_position.yaw, new_camera_position.roll; // Locals... - //float new_camera_position.x, new_camera_position.y, new_camera_position.z; SYSTEMTIME now; long newHeadPoseTime; diff --git a/bin/FaceTrackNoIR.exe b/bin/FaceTrackNoIR.exe index a411d723..17fbe3db 100644 Binary files a/bin/FaceTrackNoIR.exe and b/bin/FaceTrackNoIR.exe differ diff --git a/bin/Settings/FlightGear.ini b/bin/Settings/FlightGear.ini index 1184bcf7..0b3d6235 100644 --- a/bin/Settings/FlightGear.ini +++ b/bin/Settings/FlightGear.ini @@ -1,18 +1,21 @@ [Tracking] -Smooth=2 +Smooth=4 invertYaw=false invertPitch=false invertRoll=false invertX=false invertY=false invertZ=false -useEWMA=false +useEWMA=true redYaw=70 redPitch=70 redRoll=70 redX=70 redY=70 redZ=70 +minSmooth=15 +powCurve=10 +maxSmooth=50 [GameProtocol] Selection=1 @@ -22,12 +25,12 @@ Selection=0 [Curves] Yaw_point1=@Variant(\0\0\0\x1a@\x14\0\0\0\0\0\0@\x14\0\0\0\0\0\0) -Yaw_point2=@Variant(\0\0\0\x1a@Y \0\0\0\0\0@/\0\0\0\0\0\0) -Yaw_point3=@Variant(\0\0\0\x1a@`\x80\0\0\0\0\0@?\0\0\0\0\0\0) +Yaw_point2=@Variant(\0\0\0\x1a@X\xe0\0\0\0\0\0@C\xc0\0\0\0\0\0) +Yaw_point3=@Variant(\0\0\0\x1a@_\xa0\0\0\0\0\0@E\0\0\0\0\0\0) Yaw_point4=@Variant(\0\0\0\x1a@f\x80\0\0\0\0\0@I\0\0\0\0\0\0) Pitch_point1=@Variant(\0\0\0\x1a@\x18\0\0\0\0\0\0@\x18\0\0\0\0\0\0) -Pitch_point2=@Variant(\0\0\0\x1a@M\x80\0\0\0\0\0@3\0\0\0\0\0\0) -Pitch_point3=@Variant(\0\0\0\x1a@Y\xc0\0\0\0\0\0@A\0\0\0\0\0\0) +Pitch_point2=@Variant(\0\0\0\x1a@K\xc0\0\0\0\0\0@A\xc0\0\0\0\0\0) +Pitch_point3=@Variant(\0\0\0\x1a@Y\xa0\0\0\0\0\0@F\x80\0\0\0\0\0) Pitch_point4=@Variant(\0\0\0\x1a@f\x80\0\0\0\0\0@I\0\0\0\0\0\0) Roll_point1=@Variant(\0\0\0\x1a@\x10\0\0\0\0\0\0@\x10\0\0\0\0\0\0) Roll_point2=@Variant(\0\0\0\x1a@F\0\0\0\0\0\0@0\0\0\0\0\0\0) @@ -65,3 +68,13 @@ Inhibit_Roll=false Inhibit_X=false Inhibit_Y=false Inhibit_Z=false +SetZero=false +SetEngineStop=false + +[FG] +LocalPCOnly=true +IP-1=127 +IP-2=0 +IP-3=0 +IP-4=1 +PortNumber=5550 -- cgit v1.2.3