Commit 95c71cb1 authored by LM's avatar LM

Flightgear sim running

parent 9daf5fde
......@@ -927,7 +927,7 @@ bool MAVLinkXMLParserV10::generate()
// QString compact2Send("\n\n#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS_SMALL\nstatic inline void mavlink_msg_%3_send(%1 chan%5)\n{\n\t%2 hdr;\n\tmavlink_%3_t payload;\n\tuint16_t checksum;\n\tmavlink_%3_t *p = &payload;\n\n%6\n\thdr.STX = MAVLINK_STX;\n\thdr.len = MAVLINK_MSG_ID_%4_LEN;\n\thdr.msgid = MAVLINK_MSG_ID_%4;\n");
QString compact2Send0( "\n#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS\n" );
QString compact2Send1("static inline void mavlink_msg_%3_send(%1 chan%5)\n{\n\t%2 hdr;\n\tmavlink_%3_t payload;\n\n\tMAVLINK_BUFFER_CHECK_START( chan, MAVLINK_MSG_ID_%4_LEN )\n%6\n\thdr.STX = MAVLINK_STX;\n\thdr.len = MAVLINK_MSG_ID_%4_LEN;\n\thdr.msgid = MAVLINK_MSG_ID_%4;\n");
QString compact2Send2("\thdr.sysid = mavlink_system.sysid;\n\thdr.compid = mavlink_system.compid;\n\thdr.seq = mavlink_get_channel_status(chan)->current_tx_seq;\n\tmavlink_get_channel_status(chan)->current_tx_seq = hdr.seq + 1;\n\tmavlink_send_mem(chan, (uint8_t *)&hdr.STX, MAVLINK_NUM_HEADER_BYTES );\n");
QString compact2Send2("\thdr.sysid = mavlink_system.sysid;\n\thdr.compid = mavlink_system.compid;\n\thdr.seq = mavlink_get_channel_status(chan)->current_tx_seq;\n\tmavlink_get_channel_status(chan)->current_tx_seq = hdr.seq + 1;\n\tmavlink_send_mem(chan, (uint8_t *)&hdr.STX, MAVLINK_NUM_HEADER_BYTES );\n\tmavlink_send_mem(chan, (uint8_t *)&payload, sizeof(payload) );\n");
QString compact2Send3("\n\tcrc_init(&hdr.ck);\n\tcrc_calculate_mem((uint8_t *)&hdr.len, &hdr.ck, MAVLINK_CORE_HEADER_LEN);\n\tcrc_calculate_mem((uint8_t *)&payload, &hdr.ck, hdr.len );\n\tcrc_accumulate( 0x%1, &hdr.ck); /// include key in X25 checksum\n\tmavlink_send_mem(chan, (uint8_t *)&hdr.ck, MAVLINK_NUM_CHECKSUM_BYTES);\n\tMAVLINK_BUFFER_CHECK_END\n}\n\n#endif");
QString compact2Send = compact2Send0 + commentSendContainer.arg(messageName.toLower(), commentLines) + compact2Send1.arg(channelType, headerType, messageName, messageName.toUpper(), packParameters, packLines.replace(QString("p->"),QString("payload.")) ) + compact2Send2 + compact2Send3.arg(stringCRC.toUpper());
// QString cFile = "// MESSAGE " + messageName.toUpper() + " PACKING\n\n" + idDefine.arg(messageName.toUpper(), QString::number(messageId), QString::number(calculatedLength), stringCRC.toUpper() ) + "\n\n" + cStruct + "\n" + arrayDefines + "\n" + commentContainer.arg(messageName.toLower(), commentLines) + pack + commentPackChanContainer.arg(messageName.toLower(), commentLines) + packChan + commentEncodeContainer.arg(messageName.toLower()) + encode + "\n" + commentSendContainer.arg(messageName.toLower(), commentLines) + compactSend + compact2Send + "\n" + "// MESSAGE " + messageName.toUpper() + " UNPACKING\n\n" + unpacking + commentDecodeContainer.arg(messageName.toLower()) + decode;
......
......@@ -178,7 +178,7 @@ void QGCFlightGearLink::writeBytes(const char* data, qint64 size)
qDebug() << bytes;
qDebug() << "ASCII:" << ascii;
#endif
socket->writeDatagram(data, size, currentHost, currentPort);
if (connectState && socket) socket->writeDatagram(data, size, currentHost, currentPort);
}
/**
......@@ -202,7 +202,7 @@ void QGCFlightGearLink::readBytes()
// Print string
QString state(b);
qDebug() << "FG LINK GOT:" << state;
//qDebug() << "FG LINK GOT:" << state;
QStringList values = state.split(",");
......@@ -254,6 +254,14 @@ qint64 QGCFlightGearLink::bytesAvailable()
**/
bool QGCFlightGearLink::disconnectSimulation()
{
disconnect(process, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(processError(QProcess::ProcessError)));
disconnect(mav, SIGNAL(hilControlsChanged(uint64_t, float, float, float, float, uint8_t, uint8_t)), this, SLOT(updateControls(uint64_t,float,float,float,float,uint8_t,uint8_t)));
disconnect(this, SIGNAL(hilStateChanged(uint64_t,float,float,float,float,float,float,int32_t,int32_t,int32_t,int16_t,int16_t,int16_t,int16_t,int16_t,int16_t)), mav, SLOT(sendHilState(uint64_t,float,float,float,float,float,float,int32_t,int32_t,int32_t,int16_t,int16_t,int16_t,int16_t,int16_t,int16_t)));
process->close();
delete process;
process = NULL;
delete socket;
socket = NULL;
......@@ -331,7 +339,7 @@ QObject::connect( process, SIGNAL(error(QProcess::ProcessError)),
QStringList processCall;
QString processFgfs;
QString fgRoot;
QString aircraft("Rascal110");
QString aircraft("Rascal110-JSBSim");
#ifdef Q_OS_MACX
processFgfs = "/Applications/FlightGear.app/Contents/Resources/fgfs";
......@@ -343,18 +351,40 @@ processFgfs = "C:\Program Files (x86)\FlightGear\bin\Win32\fgfs";
fgRoot = "--fg-root=C:\Program Files (x86)\FlightGear\data";
#endif
#ifdef Q_OS_LINUX
processFgfs = "fgfs";
fgRoot = "--fg-root=/usr/share/flightgear/data";
#endif
processCall << fgRoot;
//processCall << "--generic=socket,out,50,127.0.0.1,49005,udp,ardupilot" << "--generic=socket,in,50,127.0.0.1,49000,udp,ardupilot" << "--in-air" << "--altitude=10" << "--vc=90" << "--heading=300" << "--timeofday=noon";
//processCall << QString("--aircraft=%2").arg(aircraft);
processCall << "--generic=socket,out,50,127.0.0.1,49005,udp,ardupilot";
processCall << "--generic=socket,in,50,127.0.0.1,49000,udp,ardupilot";
processCall << "--in-air";
processCall << "--altitude=10";
processCall << "--vc=90";
processCall << "--heading=300";
processCall << "--timeofday=noon";
processCall << "--disable-hud-3d";
processCall << "--control=mouse";
processCall << "--disable-intro-music";
processCall << "--disable-sound";
processCall << "--disable-anti-alias-hud";
processCall << "--disable-fullscreen";
processCall << "--disable-random-objects";
processCall << "--disable-ai-models";
processCall << "--wind=0@0";
processCall << "--fdm=jsb";
// Add new argument with this: processCall << "";
processCall << QString("--aircraft=%2").arg(aircraft);
process->start(processFgfs, processCall);
qDebug() << "STARTING: " << processFgfs << processCall;
if (!process->waitForStarted())
{
qDebug() << "PROCESS START FAILED!";
}
//if (!process->waitForStarted())
//{
// qDebug() << "PROCESS START FAILED!";
//}
emit flightGearConnected(connectState);
if (connectState) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment