diff --git a/ground/src/plugins/gcscontrol/GCSControl.pluginspec b/ground/src/plugins/gcscontrol/GCSControl.pluginspec new file mode 100644 index 000000000..79660f2d3 --- /dev/null +++ b/ground/src/plugins/gcscontrol/GCSControl.pluginspec @@ -0,0 +1,11 @@ + + The OpenPilot Project + (C) 2010 OpenPilot Project + The GNU Public License (GPL) Version 3 + Allow GCS to take over from the receiver and control the UAV, either with a mouse and keyboard or an external joystick + http://www.openpilot.org + + + + + diff --git a/ground/src/plugins/gcscontrol/gcscontrol.pro b/ground/src/plugins/gcscontrol/gcscontrol.pro new file mode 100644 index 000000000..a680cf100 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrol.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +TARGET = GCSControl + +include(../../openpilotgcsplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) +include(../../plugins/uavobjects/uavobjects.pri) + +HEADERS += gcscontrolgadget.h +HEADERS += gcscontrolgadgetwidget.h +HEADERS += gcscontrolgadgetfactory.h +HEADERS += gcscontrolplugin.h + +SOURCES += gcscontrolgadget.cpp +SOURCES += gcscontrolgadgetwidget.cpp +SOURCES += gcscontrolgadgetfactory.cpp +SOURCES += gcscontrolplugin.cpp + +OTHER_FILES += GCSControl.pluginspec + +FORMS += gcscontrol.ui diff --git a/ground/src/plugins/gcscontrol/gcscontrol.ui b/ground/src/plugins/gcscontrol/gcscontrol.ui new file mode 100644 index 000000000..98d495a11 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrol.ui @@ -0,0 +1,32 @@ + + + GCSControl + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 73 + 61 + 181 + 191 + + + + FlightMode + + + + + + diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp new file mode 100644 index 000000000..7e4c68173 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp @@ -0,0 +1,51 @@ +/** + ****************************************************************************** + * + * @file GCSControlgadget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "gcscontrolgadget.h" +#include "gcscontrolgadgetwidget.h" + +#include "extensionsystem/pluginmanager.h" +#include "uavobjects/uavobjectmanager.h" +#include "uavobjects/uavobject.h" + +GCSControlGadget::GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent) : + IUAVGadget(classId, parent), + m_widget(widget) +{ +} + +GCSControlGadget::~GCSControlGadget() +{ + +} + +void GCSControlGadget::loadConfiguration(IUAVGadgetConfiguration* config) +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + + UAVDataObject* obj = dynamic_cast( objManager->getObject(QString("ManualControlCommand")) ); +} diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadget.h b/ground/src/plugins/gcscontrol/gcscontrolgadget.h new file mode 100644 index 000000000..0d8b7551c --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadget.h @@ -0,0 +1,60 @@ +/** + ****************************************************************************** + * + * @file GCSControlgadget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GCSControlGADGET_H_ +#define GCSControlGADGET_H_ + +#include + +namespace Core { +class IUAVGadget; +} +//class QWidget; +//class QString; +class GCSControlGadgetWidget; + +using namespace Core; + +class GCSControlGadget : public Core::IUAVGadget +{ + Q_OBJECT +public: + GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent = 0); + ~GCSControlGadget(); + + QList context() const { return m_context; } + QWidget *widget() { return m_widget; } + QString contextHelpId() const { return QString(); } + + void loadConfiguration(IUAVGadgetConfiguration* config); +private: + QWidget *m_widget; + QList m_context; +}; + + +#endif // GCSControlGADGET_H_ diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.cpp new file mode 100644 index 000000000..3d9ad0704 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.cpp @@ -0,0 +1,47 @@ +/** + ****************************************************************************** + * + * @file GCSControlgadgetfactory.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "gcscontrolgadgetfactory.h" +#include "gcscontrolgadgetwidget.h" +#include "gcscontrolgadget.h" +#include + +GCSControlGadgetFactory::GCSControlGadgetFactory(QObject *parent) : + IUAVGadgetFactory(QString("GCSControlGadget"), + tr("UAV Control"), + parent) +{ +} + +GCSControlGadgetFactory::~GCSControlGadgetFactory() +{ + +} + +IUAVGadget* GCSControlGadgetFactory::createGadget(QWidget *parent) { + GCSControlGadgetWidget* gadgetWidget = new GCSControlGadgetWidget(parent); + return new GCSControlGadget(QString("GCSControlGadget"), gadgetWidget, parent); +} diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.h b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.h new file mode 100644 index 000000000..283c36e80 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.h @@ -0,0 +1,50 @@ +/** + ****************************************************************************** + * + * @file GCSControlgadgetfactory.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GCSControlGADGETFACTORY_H_ +#define GCSControlGADGETFACTORY_H_ + +#include + +namespace Core { +class IUAVGadget; +class IUAVGadgetFactory; +} + +using namespace Core; + +class GCSControlGadgetFactory : public IUAVGadgetFactory +{ + Q_OBJECT +public: + GCSControlGadgetFactory(QObject *parent = 0); + ~GCSControlGadgetFactory(); + + IUAVGadget *createGadget(QWidget *parent); +}; + +#endif // GCSControlGADGETFACTORY_H_ diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp new file mode 100644 index 000000000..4a37c9de4 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp @@ -0,0 +1,81 @@ +/** + ****************************************************************************** + * + * @file GCSControlgadgetwidget.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "gcscontrolgadgetwidget.h" +#include "ui_gcscontrol.h" + +#include +#include +#include +#include +#include +#include + +#include "uavobjects/uavobject.h" +#include "uavobjects/uavobjectmanager.h" +#include "uavobjects/manualcontrolcommand.h" +#include "extensionsystem/pluginmanager.h" + +GCSControlGadgetWidget::GCSControlGadgetWidget(QWidget *parent) : QLabel(parent) +{ + m_gcscontrol = new Ui_GCSControl(); + m_gcscontrol->setupUi(this); + connect(m_gcscontrol->pushButton, SIGNAL(clicked()), this, SLOT(buttonPressed())); +} + +GCSControlGadgetWidget::~GCSControlGadgetWidget() +{ + // Do nothing +} + +void GCSControlGadgetWidget::buttonPressed() +{ + // Get access to the ManualControlObject + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objManager = pm->getObject(); + ManualControlCommand* obj = dynamic_cast( objManager->getObject(QString("ManualControlCommand")) ); + + // Need to set the metadata to let GCS override OpenPilot + UAVObject::Metadata mdata = obj->getMetadata(); + mdata.gcsAccess = UAVObject::ACCESS_READWRITE; + mdata.flightAccess = UAVObject::ACCESS_READONLY; + obj->setMetadata(mdata); + + // Set values to some constants for now + ManualControlCommand::DataFields data = obj->getData(); + data.FlightMode = ManualControlCommand::FLIGHTMODE_STABILIZED; + data.Pitch = .5; + data.Roll = .3; + data.Throttle = .2; + data.Yaw = .3; + obj->setData(data); + + // Visual confirmation + m_gcscontrol->pushButton->setText(obj->toString()); + + //Q_ASSERT( 0 ); +} + diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.h b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.h new file mode 100644 index 000000000..eeeb5ec43 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.h @@ -0,0 +1,50 @@ +/** + ****************************************************************************** + * + * @file GCSControlgadgetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A place holder gadget plugin + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GCSControlGADGETWIDGET_H_ +#define GCSControlGADGETWIDGET_H_ + +#include + +class Ui_GCSControl; + +class GCSControlGadgetWidget : public QLabel +{ + Q_OBJECT + +public: + GCSControlGadgetWidget(QWidget *parent = 0); + ~GCSControlGadgetWidget(); + +private slots: + void buttonPressed(); + +private: + Ui_GCSControl *m_gcscontrol; +}; + +#endif /* GCSControlGADGETWIDGET_H_ */ diff --git a/ground/src/plugins/gcscontrol/gcscontrolplugin.cpp b/ground/src/plugins/gcscontrol/gcscontrolplugin.cpp new file mode 100644 index 000000000..a95a58284 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolplugin.cpp @@ -0,0 +1,65 @@ +/** + ****************************************************************************** + * + * @file GCSControlplugin.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "gcscontrolplugin.h" +#include "gcscontrolgadgetfactory.h" +#include +#include +#include +#include + + +GCSControlPlugin::GCSControlPlugin() +{ + // Do nothing +} + +GCSControlPlugin::~GCSControlPlugin() +{ + // Do nothing +} + +bool GCSControlPlugin::initialize(const QStringList& args, QString *errMsg) +{ + Q_UNUSED(args); + Q_UNUSED(errMsg); + mf = new GCSControlGadgetFactory(this); + addAutoReleasedObject(mf); + + return true; +} + +void GCSControlPlugin::extensionsInitialized() +{ + // Do nothing +} + +void GCSControlPlugin::shutdown() +{ + // Do nothing +} +Q_EXPORT_PLUGIN(GCSControlPlugin) + diff --git a/ground/src/plugins/gcscontrol/gcscontrolplugin.h b/ground/src/plugins/gcscontrol/gcscontrolplugin.h new file mode 100644 index 000000000..68e12d00c --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolplugin.h @@ -0,0 +1,47 @@ +/** + ****************************************************************************** + * + * @file GCSControlplugin.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GCSControlPLUGIN_H_ +#define GCSControlPLUGIN_H_ + +#include + +class GCSControlGadgetFactory; + +class GCSControlPlugin : public ExtensionSystem::IPlugin +{ +public: + GCSControlPlugin(); + ~GCSControlPlugin(); + + void extensionsInitialized(); + bool initialize(const QStringList & arguments, QString * errorString); + void shutdown(); +private: + GCSControlGadgetFactory *mf; +}; +#endif /* GCSControlPLUGIN_H_ */ diff --git a/ground/src/plugins/gcscontrol/gcsonctrolgadgetwidget.h b/ground/src/plugins/gcscontrol/gcsonctrolgadgetwidget.h new file mode 100644 index 000000000..360b59080 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcsonctrolgadgetwidget.h @@ -0,0 +1,44 @@ +/** + ****************************************************************************** + * + * @file emptygadgetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup EmptyGadgetPlugin Empty Gadget Plugin + * @{ + * @brief A place holder gadget plugin + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef EMPTYGADGETWIDGET_H_ +#define EMPTYGADGETWIDGET_H_ + +#include + +class EmptyGadgetWidget : public QLabel +{ + Q_OBJECT + +public: + EmptyGadgetWidget(QWidget *parent = 0); + ~EmptyGadgetWidget(); + +private: +}; + +#endif /* EMPTYGADGETWIDGET_H_ */ diff --git a/ground/src/plugins/plugins.pro b/ground/src/plugins/plugins.pro index f5e53eab8..402d8b532 100644 --- a/ground/src/plugins/plugins.pro +++ b/ground/src/plugins/plugins.pro @@ -135,3 +135,9 @@ plugin_hitlil2.depends += plugin_uavobjects plugin_hitlil2.depends += plugin_uavtalk SUBDIRS += plugin_hitlil2 +#GCS Control of UAV Gadget +plugin_gcscontrol.subdir = gcscontrol +plugin_gcscontrol.depends = plugin_coreplugin +plugin_gcscontrol.depends += plugin_uavobjects +plugin_gcscontrol.depends += plugin_uavtalk +SUBDIRS += plugin_gcscontrol