From db7248a6de07e7dacac24e1f59afe7e6fe45ba9c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Apr 2017 21:33:10 +0200 Subject: proto/flightgear: few issues - move fgtypes.h contents into module header - fix several inverted DOF - construct a 32-bit ipv4 address from nibblets directly - switch to no alignment for the datagram, was 2 bytes - default to 127.0.0.1 as the target address Issue: #590 --- proto-fg/fgtypes.h | 27 --------------------------- proto-fg/ftnoir_protocol_fg.cpp | 15 +++++---------- proto-fg/ftnoir_protocol_fg.h | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 42 deletions(-) delete mode 100644 proto-fg/fgtypes.h diff --git a/proto-fg/fgtypes.h b/proto-fg/fgtypes.h deleted file mode 100644 index 2e493f46..00000000 --- a/proto-fg/fgtypes.h +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* Type definitions for the FlightGear server. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FGTYPES_H -#define INCLUDED_FGTYPES_H - -// -// x,y,z position in metres, heading, pitch and roll in degrees... -// -#pragma pack(push, 2) -struct TFlightGearData { - double x, y, z, h, p, r; - int status; -}; -#pragma pack(pop) - -#endif//INCLUDED_FGTYPES_H diff --git a/proto-fg/ftnoir_protocol_fg.cpp b/proto-fg/ftnoir_protocol_fg.cpp index 3df51c3e..3e0f955c 100644 --- a/proto-fg/ftnoir_protocol_fg.cpp +++ b/proto-fg/ftnoir_protocol_fg.cpp @@ -14,20 +14,15 @@ // For Todd and Arda Kutlu void flightgear::pose(const double* headpose) { - FlightData.x = headpose[TX] * 1e-2; + FlightData.x = -headpose[TX] * 1e-2; FlightData.y = headpose[TY] * 1e-2; FlightData.z = headpose[TZ] * 1e-2; FlightData.p = headpose[Pitch]; - FlightData.h = headpose[Yaw]; - FlightData.r = headpose[Roll]; + FlightData.h = -headpose[Yaw]; + FlightData.r = -headpose[Roll]; FlightData.status = 1; - QHostAddress destIP(QString("%1.%2.%3.%4").arg( - QString::number(static_cast(s.ip1)), - QString::number(static_cast(s.ip2)), - QString::number(static_cast(s.ip3)), - QString::number(static_cast(s.ip4)))); - int destPort = s.port; - (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(destPort)); + QHostAddress destIP(quint32(s.ip1 << 24 | s.ip2 << 16 | s.ip3 << 8 | s.ip4)); + (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(s.port)); } bool flightgear::correct() diff --git a/proto-fg/ftnoir_protocol_fg.h b/proto-fg/ftnoir_protocol_fg.h index 019b8c57..48e5f1c1 100644 --- a/proto-fg/ftnoir_protocol_fg.h +++ b/proto-fg/ftnoir_protocol_fg.h @@ -10,7 +10,6 @@ */ #pragma once #include "ui_ftnoir_fgcontrols.h" -#include "fgtypes.h" #include #include #include @@ -18,15 +17,23 @@ #include "options/options.hpp" using namespace options; +// x,y,z position in meters, heading, pitch and roll in degrees +#pragma pack(push, 1) +struct flightgear_datagram { + double x, y, z, h, p, r; + int status; +}; +#pragma pack(pop) + struct settings : opts { value ip1, ip2, ip3, ip4; value port; settings() : opts("flightgear-proto"), - ip1(b, "ip1", 192), - ip2(b, "ip2", 168), + ip1(b, "ip1", 127), + ip2(b, "ip2", 0), ip3(b, "ip3", 0), - ip4(b, "ip4", 2), + ip4(b, "ip4", 1), port(b, "port", 5542) {} }; @@ -41,7 +48,7 @@ public: } private: settings s; - TFlightGearData FlightData; + flightgear_datagram FlightData; QUdpSocket outSocket; }; -- cgit v1.2.3