summaryrefslogtreecommitdiffhomepage
path: root/FaceTrackNoIR
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2011-02-08 21:17:36 +0000
committerWim Vriend <facetracknoir@gmail.com>2011-02-08 21:17:36 +0000
commit43420d828647b026a315c58db621202fc5a17403 (patch)
tree439a38fe942c8e90e41a9c7b282f09a9b5828382 /FaceTrackNoIR
parentd3ff506356286dd7cbff67b8736482539a317006 (diff)
Updating FlightGear protocol
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@49 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FaceTrackNoIR')
-rw-r--r--FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml16
-rw-r--r--FaceTrackNoIR/FGServer.cpp68
-rw-r--r--FaceTrackNoIR/tracker.cpp2
3 files changed, 38 insertions, 48 deletions
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 @@
<?xml version="1.0"?>
<PropertyList>
- <input>
- <keyboard>
- <key n="61">
- <name>= (equal sign)</name>
- <desc>Reset Head Tracker</desc>
- <binding>
- <command>nasal</command>
- <script>headtracker.reset()</script>
- </binding>
- </key>
- </keyboard>
- </input>
-
<nasal>
<headtracker>
<script>
@@ -21,12 +8,10 @@
new: func(prop) {
var m = { parents: [Value] };
m.prop = props.globals.getNode(prop, 1);
- m.lowpass = aircraft.lowpass.new(0.7);
m.value = 0;
return m;
},
apply: func(value) {
- value = me.lowpass.filter(value);
me.prop.setDoubleValue(me.prop.getValue() - me.value + value);
me.value = value;
},
@@ -79,7 +64,6 @@
loop();
- gui.popupTip("press '=' (equal sign) to reset head tracker", 20);
</script>
</headtracker>
</nasal>
diff --git a/FaceTrackNoIR/FGServer.cpp b/FaceTrackNoIR/FGServer.cpp
index 53cd68ff..292c194b 100644
--- a/FaceTrackNoIR/FGServer.cpp
+++ b/FaceTrackNoIR/FGServer.cpp
@@ -62,22 +62,6 @@ 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.
//
TestData.x = virtPosX;
@@ -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;