1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Barest beginnings of GCS manual control interface

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1134 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-07-19 06:20:13 +00:00 committed by peabody124
parent 89e0c687d7
commit f1d7c604c1
13 changed files with 564 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<plugin name="GCSControl" version="0.0.1" compatVersion="1.0.0">
<vendor>The OpenPilot Project</vendor>
<copyright>(C) 2010 OpenPilot Project</copyright>
<license>The GNU Public License (GPL) Version 3</license>
<description>Allow GCS to take over from the receiver and control the UAV, either with a mouse and keyboard or an external joystick</description>
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
</dependencyList>
</plugin>

View File

@ -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

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GCSControl</class>
<widget class="QWidget" name="GCSControl">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>73</x>
<y>61</y>
<width>181</width>
<height>191</height>
</rect>
</property>
<property name="text">
<string>FlightMode</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -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<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("ManualControlCommand")) );
}

View File

@ -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 <coreplugin/iuavgadget.h>
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<int> context() const { return m_context; }
QWidget *widget() { return m_widget; }
QString contextHelpId() const { return QString(); }
void loadConfiguration(IUAVGadgetConfiguration* config);
private:
QWidget *m_widget;
QList<int> m_context;
};
#endif // GCSControlGADGET_H_

View File

@ -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 <coreplugin/iuavgadget.h>
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);
}

View File

@ -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 <coreplugin/iuavgadgetfactory.h>
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_

View File

@ -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 <QDebug>
#include <QStringList>
#include <QtGui/QWidget>
#include <QtGui/QTextEdit>
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
#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<UAVObjectManager>();
ManualControlCommand* obj = dynamic_cast<ManualControlCommand*>( 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 );
}

View File

@ -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 <QtGui/QLabel>
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_ */

View File

@ -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 <QDebug>
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
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)

View File

@ -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 <extensionsystem/iplugin.h>
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_ */

View File

@ -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 <QtGui/QLabel>
class EmptyGadgetWidget : public QLabel
{
Q_OBJECT
public:
EmptyGadgetWidget(QWidget *parent = 0);
~EmptyGadgetWidget();
private:
};
#endif /* EMPTYGADGETWIDGET_H_ */

View File

@ -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