File indexing completed on 2024-12-29 05:20:09
0001 /* 0002 * Copyright 2019 Patrick José Pereira <patrickjp@kde.org> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 #include "mavlinkplugin.h" 0022 0023 #include "mavlinkudpconnection.h" 0024 #include "mavlinkvehicle.h" 0025 0026 #include <KLocalizedString> 0027 #include <KPluginFactory> 0028 0029 #include "mavlink_plugin_debug.h" 0030 0031 MAVLinkPlugin::MAVLinkPlugin(QObject *parent, const QVariantList & /* args */) 0032 : Kirogi::VehicleSupportPlugin(parent) 0033 { 0034 qCDebug(KIROGI_VEHICLESUPPORT_MAVLINK_PLUGIN) << "MAVLink Vehicle Support Plugin initializing ..."; 0035 qRegisterMetaType<mavlink_message_t>("mavlink_message_t"); 0036 0037 Kirogi::UdpConfiguration connectionConfiguration; 0038 connectionConfiguration.setName("Main Connection"); 0039 connectionConfiguration.setHost(QHostAddress("0.0.0.0")); 0040 connectionConfiguration.setPort(14550); 0041 m_connection = QSharedPointer<MAVLinkUdpConnection>(new MAVLinkUdpConnection(connectionConfiguration, 0, this)); 0042 m_connection->connect(); 0043 0044 MAVLinkVehicle::Configuration vehicleConfiguration; 0045 vehicleConfiguration.sysid = 0; 0046 vehicleConfiguration.compid = 0; 0047 vehicleConfiguration.type = MAV_TYPE_QUADROTOR; 0048 vehicleConfiguration.name = "Main Vehicle"; 0049 m_vehicle = QSharedPointer<MAVLinkVehicle>(new MAVLinkVehicle(vehicleConfiguration, m_connection.data(), this)); 0050 0051 QMetaObject::invokeMethod(this, "vehicleAdded", Qt::QueuedConnection, Q_ARG(Kirogi::AbstractVehicle *, m_vehicle.data())); 0052 } 0053 0054 MAVLinkPlugin::~MAVLinkPlugin() 0055 { 0056 qCDebug(KIROGI_VEHICLESUPPORT_MAVLINK_PLUGIN) << "MAVLink Vehicle Support Plugin unloaded."; 0057 } 0058 0059 QList<Kirogi::AbstractVehicle *> MAVLinkPlugin::vehicles() const 0060 { 0061 return QList<Kirogi::AbstractVehicle *>() << m_vehicle.data(); 0062 } 0063 0064 K_PLUGIN_CLASS_WITH_JSON(MAVLinkPlugin, "kirogimavlinkplugin.json") 0065 0066 #include "mavlinkplugin.moc"