Commit 31a1a070 authored by Lorenz Meier's avatar Lorenz Meier

Fixed HIL startup crash, fixed yaw offset

parent f9a43531
...@@ -317,7 +317,7 @@ void QGCXPlaneLink::readBytes() ...@@ -317,7 +317,7 @@ void QGCXPlaneLink::readBytes()
//qDebug() << "HDNG" << "pitch" << p.f[0] << "roll" << p.f[1] << "hding true" << p.f[2] << "hding mag" << p.f[3]; //qDebug() << "HDNG" << "pitch" << p.f[0] << "roll" << p.f[1] << "hding true" << p.f[2] << "hding mag" << p.f[3];
pitch = p.f[0] / 180.0f * M_PI; pitch = p.f[0] / 180.0f * M_PI;
roll = p.f[1] / 180.0f * M_PI; roll = p.f[1] / 180.0f * M_PI;
yaw = (p.f[2] - 180.0f) / 180.0f * M_PI; yaw = p.f[2] / 180.0f * M_PI;
} }
// else if (p.index == 19) // else if (p.index == 19)
...@@ -552,6 +552,10 @@ void QGCXPlaneLink::setRandomAttitude() ...@@ -552,6 +552,10 @@ void QGCXPlaneLink::setRandomAttitude()
**/ **/
bool QGCXPlaneLink::connectSimulation() bool QGCXPlaneLink::connectSimulation()
{ {
qDebug() << "STARTING X-PLANE LINK, CONNECTING TO" << remoteHost << ":" << remotePort;
start(LowPriority);
if (!mav) return false; if (!mav) return false;
if (connectState) return false; if (connectState) return false;
...@@ -772,10 +776,6 @@ bool QGCXPlaneLink::connectSimulation() ...@@ -772,10 +776,6 @@ bool QGCXPlaneLink::connectSimulation()
// qDebug() << "STARTING SIM"; // qDebug() << "STARTING SIM";
// qDebug() << "STARTING: " << processFgfs << processCall; // qDebug() << "STARTING: " << processFgfs << processCall;
qDebug() << "STARTING X-PLANE LINK, CONNECTING TO" << remoteHost << ":" << remotePort;
start(LowPriority);
return connectState; return connectState;
} }
......
...@@ -106,7 +106,8 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), ...@@ -106,7 +106,8 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
connectionLost(false), connectionLost(false),
lastVoltageWarning(0), lastVoltageWarning(0),
lastNonNullTime(0), lastNonNullTime(0),
onboardTimeOffsetInvalidCount(0) onboardTimeOffsetInvalidCount(0),
hilEnabled(false)
{ {
for (unsigned int i = 0; i<255;++i) for (unsigned int i = 0; i<255;++i)
...@@ -2605,6 +2606,8 @@ void UAS::sendHilState(uint64_t time_us, float roll, float pitch, float yaw, flo ...@@ -2605,6 +2606,8 @@ void UAS::sendHilState(uint64_t time_us, float roll, float pitch, float yaw, flo
**/ **/
void UAS::startHil() void UAS::startHil()
{ {
if (hilEnabled) return;
hilEnabled = true;
// Connect HIL simulation link // Connect HIL simulation link
simulation->connectSimulation(); simulation->connectSimulation();
mavlink_message_t msg; mavlink_message_t msg;
...@@ -2621,6 +2624,7 @@ void UAS::stopHil() ...@@ -2621,6 +2624,7 @@ void UAS::stopHil()
mavlink_message_t msg; mavlink_message_t msg;
mavlink_msg_set_mode_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), mode & !MAV_MODE_FLAG_HIL_ENABLED, navMode); mavlink_msg_set_mode_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), mode & !MAV_MODE_FLAG_HIL_ENABLED, navMode);
sendMessage(msg); sendMessage(msg);
hilEnabled = false;
} }
void UAS::shutdown() void UAS::shutdown()
......
...@@ -680,6 +680,7 @@ protected: ...@@ -680,6 +680,7 @@ protected:
quint64 lastVoltageWarning; ///< Time at which the last voltage warning occured quint64 lastVoltageWarning; ///< Time at which the last voltage warning occured
quint64 lastNonNullTime; ///< The last timestamp from the MAV that was not null quint64 lastNonNullTime; ///< The last timestamp from the MAV that was not null
unsigned int onboardTimeOffsetInvalidCount; ///< Count when the offboard time offset estimation seemed wrong unsigned int onboardTimeOffsetInvalidCount; ///< Count when the offboard time offset estimation seemed wrong
bool hilEnabled; ///< Set to true if HIL mode is enabled from GCS (UAS might be in HIL even if this flag is not set, this defines the GCS HIL setting)
protected slots: protected slots:
/** @brief Write settings to disk */ /** @brief Write settings to disk */
......
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