diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 7e4bb4e8dc0390c424177755722fbfeafbf29f7c..b9c3f86da8d80469c1ca116237f7994a41bc5ddd 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -391,7 +391,7 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) } // Create a new UAS object - uas = QGCMAVLinkUASFactory::createUAS(this, link, message.sysid, &heartbeat); + uas = QGCMAVLinkUASFactory::createUAS(this, link, message.sysid, (MAV_AUTOPILOT)heartbeat.autopilot); } diff --git a/src/uas/QGCMAVLinkUASFactory.cc b/src/uas/QGCMAVLinkUASFactory.cc index 34c1a697f744e20029785c509edbb7bb871e4475..42020a548d64774c0b9415973566ed1c62f321b6 100644 --- a/src/uas/QGCMAVLinkUASFactory.cc +++ b/src/uas/QGCMAVLinkUASFactory.cc @@ -6,26 +6,13 @@ QGCMAVLinkUASFactory::QGCMAVLinkUASFactory(QObject *parent) : { } -UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInterface* link, int sysid, mavlink_heartbeat_t* heartbeat, QObject* parent) +UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInterface* link, int sysid, MAV_AUTOPILOT autopilotType) { - QPointer p; - - if (parent != NULL) - { - p = parent; - } - else - { - p = mavlink; - } - UASInterface* uasInterface; - UAS* uasObject = new UAS(mavlink, sysid); + UAS* uasObject = new UAS(mavlink, sysid, autopilotType); Q_CHECK_PTR(uasObject); uasInterface = uasObject; - - uasObject->setSystemType((int)heartbeat->type); // Connect this robot to the UAS object // It is IMPORTANT here to use the right object type, @@ -33,9 +20,6 @@ UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInte // packets never reach their goal) connect(mavlink, &MAVLinkProtocol::messageReceived, uasObject, &UAS::receiveMessage); - // Set the autopilot type - uasInterface->setAutopilotType((int)heartbeat->autopilot); - // Make UAS aware that this link can be used to communicate with the actual robot uasInterface->addLink(link); diff --git a/src/uas/QGCMAVLinkUASFactory.h b/src/uas/QGCMAVLinkUASFactory.h index 55242be34c88436f699c9786a025ad46d369f0ce..a0820f4af9682c83a3b20ad2bc4265fcfca9a172 100644 --- a/src/uas/QGCMAVLinkUASFactory.h +++ b/src/uas/QGCMAVLinkUASFactory.h @@ -18,7 +18,7 @@ public: explicit QGCMAVLinkUASFactory(QObject *parent = 0); /** @brief Create a new UAS object using MAVLink as protocol */ - static UASInterface* createUAS(MAVLinkProtocol* mavlink, LinkInterface* link, int sysid, mavlink_heartbeat_t* heartbeat, QObject* parent=NULL); + static UASInterface* createUAS(MAVLinkProtocol* mavlink, LinkInterface* link, int sysid, MAV_AUTOPILOT autopilotType); signals: