1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-19 09:54:15 +01:00

OP-306 Update all Gadgets so that they destroy their widgets properly when they die.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2681 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-02-01 23:01:52 +00:00 committed by edouard
parent a568ff893d
commit 9170155f5f
14 changed files with 868 additions and 884 deletions

View File

@ -1,46 +1,46 @@
/**
******************************************************************************
*
* @file configgadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ConfigPlugin Config Plugin
* @{
* @brief The Configuration Gadget used to update settings in the firmware
*****************************************************************************/
/*
* 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 "configgadget.h"
#include "configgadgetwidget.h"
#include "configgadgetconfiguration.h"
ConfigGadget::ConfigGadget(QString classId, ConfigGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
ConfigGadget::~ConfigGadget()
{
}
void ConfigGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
Q_UNUSED(config);
}
/**
******************************************************************************
*
* @file configgadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ConfigPlugin Config Plugin
* @{
* @brief The Configuration Gadget used to update settings in the firmware
*****************************************************************************/
/*
* 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 "configgadget.h"
#include "configgadgetwidget.h"
#include "configgadgetconfiguration.h"
ConfigGadget::ConfigGadget(QString classId, ConfigGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
ConfigGadget::~ConfigGadget()
{
delete m_widget;
}
void ConfigGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
Q_UNUSED(config);
}

View File

@ -1,39 +1,39 @@
/**
******************************************************************************
*
* @file emptygadget.cpp
* @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
*/
#include "emptygadget.h"
#include "emptygadgetwidget.h"
EmptyGadget::EmptyGadget(QString classId, EmptyGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
EmptyGadget::~EmptyGadget()
{
}
/**
******************************************************************************
*
* @file emptygadget.cpp
* @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
*/
#include "emptygadget.h"
#include "emptygadgetwidget.h"
EmptyGadget::EmptyGadget(QString classId, EmptyGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
EmptyGadget::~EmptyGadget()
{
delete m_widget;
}

View File

@ -1,337 +1,337 @@
/**
******************************************************************************
*
* @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 "gcscontrolgadgetconfiguration.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include <QDebug>
#define JOYSTICK_UPDATE_RATE 50
GCSControlGadget::GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent, QObject *plugin) :
IUAVGadget(classId, parent),
m_widget(widget)
{
connect(getManualControlCommand(),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(manualControlCommandUpdated(UAVObject*)));
connect(widget,SIGNAL(sticksChanged(double,double,double,double)),this,SLOT(sticksChangedLocally(double,double,double,double)));
connect(this,SIGNAL(sticksChangedRemotely(double,double,double,double)),widget,SLOT(updateSticks(double,double,double,double)));
manualControlCommandUpdated(getManualControlCommand());
joystickTime.start();
GCSControlPlugin *pl = dynamic_cast<GCSControlPlugin*>(plugin);
connect(pl->sdlGamepad,SIGNAL(gamepads(quint8)),this,SLOT(gamepads(quint8)));
connect(pl->sdlGamepad,SIGNAL(buttonState(ButtonNumber,bool)),this,SLOT(buttonState(ButtonNumber,bool)));
connect(pl->sdlGamepad,SIGNAL(axesValues(QListInt16)),this,SLOT(axesValues(QListInt16)));
}
GCSControlGadget::~GCSControlGadget()
{
}
void GCSControlGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
GCSControlGadgetConfiguration *GCSControlConfig = qobject_cast< GCSControlGadgetConfiguration*>(config);
QList<int> ql = GCSControlConfig->getChannelsMapping();
rollChannel = ql.at(0);
pitchChannel = ql.at(1);
yawChannel = ql.at(2);
throttleChannel = ql.at(3);
controlsMode = GCSControlConfig->getControlsMode();
int i;
for (i=0;i<8;i++)
{
buttonSettings[i].ActionID=GCSControlConfig->getbuttonSettings(i).ActionID;
buttonSettings[i].FunctionID=GCSControlConfig->getbuttonSettings(i).FunctionID;
buttonSettings[i].Amount=GCSControlConfig->getbuttonSettings(i).Amount;
buttonSettings[i].Amount=GCSControlConfig->getbuttonSettings(i).Amount;
channelReverse[i]=GCSControlConfig->getChannelsReverse().at(i);
}
}
ManualControlCommand* GCSControlGadget::getManualControlCommand() {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
return dynamic_cast<ManualControlCommand*>( objManager->getObject(QString("ManualControlCommand")) );
}
void GCSControlGadget::manualControlCommandUpdated(UAVObject * obj) {
double roll = obj->getField("Roll")->getDouble();
double pitch = obj->getField("Pitch")->getDouble();
double yaw = obj->getField("Yaw")->getDouble();
double throttle = obj->getField("Throttle")->getDouble();
// Remap RPYT to left X/Y and right X/Y depending on mode
switch (controlsMode) {
case 1:
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
emit sticksChangedRemotely(yaw,-pitch,roll,throttle);
break;
case 2:
// Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch
emit sticksChangedRemotely(yaw,throttle,roll,-pitch);
break;
case 3:
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
emit sticksChangedRemotely(roll,-pitch,yaw,throttle);
break;
case 4:
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
emit sticksChangedRemotely(roll,throttle,yaw,-pitch);
break;
}
}
/**
Update the manual commands - maps depending on mode
*/
void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double rightX, double rightY) {
ManualControlCommand * obj = getManualControlCommand();
double oldRoll = obj->getField("Roll")->getDouble();
double oldPitch = obj->getField("Pitch")->getDouble();
double oldYaw = obj->getField("Yaw")->getDouble();
double oldThrottle = obj->getField("Throttle")->getDouble();
double newRoll;
double newPitch;
double newYaw;
double newThrottle;
// Remap left X/Y and right X/Y to RPYT depending on mode
switch (controlsMode) {
case 1:
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
newRoll = rightX;
newPitch = -leftY;
newYaw = leftX;
newThrottle = rightY;
break;
case 2:
// Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch
newRoll = rightX;
newPitch = -rightY;
newYaw = leftX;
newThrottle = leftY;
break;
case 3:
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
newRoll = leftX;
newPitch = -leftY;
newYaw = rightX;
newThrottle = rightY;
break;
case 4:
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
newRoll = leftX;
newPitch = -rightY;
newYaw = rightX;
newThrottle = leftY;
break;
}
//check if buttons have control over this axis... if so don't update it
int buttonRollControl=0;
int buttonPitchControl=0;
int buttonYawControl=0;
int buttonThrottleControl=0;
for (int i=0;i<8;i++)
{
if ((buttonSettings[i].FunctionID==1)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonRollControl=1;
if ((buttonSettings[i].FunctionID==2)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonPitchControl=1;
if ((buttonSettings[i].FunctionID==3)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonYawControl=1;
if ((buttonSettings[i].FunctionID==4)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonThrottleControl=1;
}
//if we are not in local gcs control mode, ignore the joystick input
if (((GCSControlGadgetWidget *)m_widget)->getGCSControl()==false)return;
if((newThrottle != oldThrottle) || (newPitch != oldPitch) || (newYaw != oldYaw) || (newRoll != oldRoll)) {
if (buttonRollControl==0)obj->getField("Roll")->setDouble(newRoll);
if (buttonPitchControl==0)obj->getField("Pitch")->setDouble(newPitch);
if (buttonYawControl==0)obj->getField("Yaw")->setDouble(newYaw);
if (buttonThrottleControl==0)obj->getField("Throttle")->setDouble(newThrottle);
obj->updated();
}
}
void GCSControlGadget::gamepads(quint8 count)
{
// sdlGamepad.setGamepad(0);
// sdlGamepad.setTickRate(JOYSTICK_UPDATE_RATE);
}
void GCSControlGadget::buttonState(ButtonNumber number, bool pressed)
{
int state;
if ((buttonSettings[number].ActionID>0)&&(buttonSettings[number].FunctionID>0)&&(pressed))
{//this button is configured
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("ManualControlCommand")) );
bool currentCGSControl = ((GCSControlGadgetWidget *)m_widget)->getGCSControl();
switch (buttonSettings[number].ActionID)
{
case 1://increase
if (currentCGSControl)
{
switch (buttonSettings[number].FunctionID)
{
case 1://Roll
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()+buttonSettings[number].Amount));
break;
case 2://Pitch
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()+buttonSettings[number].Amount));
break;
case 3://Yaw
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()+buttonSettings[number].Amount));
break;
case 4://Throttle
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()+buttonSettings[number].Amount));
break;
}
}
break;
case 2://decrease
if (currentCGSControl)
{
switch (buttonSettings[number].FunctionID)
{
case 1://Roll
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()-buttonSettings[number].Amount));
break;
case 2://Pitch
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()-buttonSettings[number].Amount));
break;
case 3://Yaw
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()-buttonSettings[number].Amount));
break;
case 4://Throttle
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()-buttonSettings[number].Amount));
break;
}
}
break;
case 3://toggle
switch (buttonSettings[number].FunctionID)
{
case 1://Armed
if (currentCGSControl)
{
if(obj->getField("Armed")->getValue().toString().compare("True")==0)
{
obj->getField("Armed")->setValue("False");
}
else
{
obj->getField("Armed")->setValue("True");
}
}
break;
case 2://GCS Control
//Toggle the GCS Control checkbox, its built in signalling will handle the update to OP
((GCSControlGadgetWidget *)m_widget)->setGCSControl(!currentCGSControl);
break;
}
break;
}
obj->updated();
}
//buttonSettings[number].ActionID NIDT
//buttonSettings[number].FunctionID -RPYTAC
//buttonSettings[number].Amount
}
void GCSControlGadget::axesValues(QListInt16 values)
{
int chMax = values.length();
if (rollChannel > chMax || pitchChannel > chMax ||
yawChannel > chMax || throttleChannel > chMax ) {
qDebug() << "GCSControl: configuration is inconsistent with current joystick! Aborting update.";
return;
}
double rValue = (rollChannel > -1) ? values[rollChannel] : 0;
double pValue = (pitchChannel > -1) ? values[pitchChannel] : 0;
double yValue = (yawChannel > -1) ? values[yawChannel] : 0;
double tValue = (throttleChannel > -1) ? values[throttleChannel] : 0;
double max = 32767;
if (rollChannel > -1) if(channelReverse[rollChannel]==true)rValue = -rValue;
if (pitchChannel > -1) if(channelReverse[pitchChannel]==true)pValue = -pValue;
if (yawChannel > -1) if(channelReverse[yawChannel]==true)yValue = -yValue;
if (throttleChannel > -1) if(channelReverse[throttleChannel]==true)tValue = -tValue;
if(joystickTime.elapsed() > JOYSTICK_UPDATE_RATE) {
joystickTime.restart();
// Remap RPYT to left X/Y and right X/Y depending on mode
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
// Mode 2: LeftX = Yaw, LeftY = THrottle, RightX = Roll, RightY = Pitch
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
switch (controlsMode) {
case 1:
sticksChangedLocally(yValue/max,-pValue/max,rValue/max,-tValue/max);
break;
case 2:
sticksChangedLocally(yValue/max,-tValue/max,rValue/max,-pValue/max);
break;
case 3:
sticksChangedLocally(rValue/max,-pValue/max,yValue/max,-tValue/max);
break;
case 4:
sticksChangedLocally(rValue/max,-tValue/max,yValue/max,-pValue/max);
break;
}
}
}
double GCSControlGadget::bound(double input)
{
if (input > 1.0)return 1.0;
if (input <-1.0)return -1.0;
return input;
}
double GCSControlGadget::wrap(double input)
{
while (input > 1.0)input -= 2.0;
while (input <-1.0)input += 2.0;
return input;
}
/**
******************************************************************************
*
* @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 "gcscontrolgadgetconfiguration.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include <QDebug>
#define JOYSTICK_UPDATE_RATE 50
GCSControlGadget::GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent, QObject *plugin) :
IUAVGadget(classId, parent),
m_widget(widget)
{
connect(getManualControlCommand(),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(manualControlCommandUpdated(UAVObject*)));
connect(widget,SIGNAL(sticksChanged(double,double,double,double)),this,SLOT(sticksChangedLocally(double,double,double,double)));
connect(this,SIGNAL(sticksChangedRemotely(double,double,double,double)),widget,SLOT(updateSticks(double,double,double,double)));
manualControlCommandUpdated(getManualControlCommand());
joystickTime.start();
GCSControlPlugin *pl = dynamic_cast<GCSControlPlugin*>(plugin);
connect(pl->sdlGamepad,SIGNAL(gamepads(quint8)),this,SLOT(gamepads(quint8)));
connect(pl->sdlGamepad,SIGNAL(buttonState(ButtonNumber,bool)),this,SLOT(buttonState(ButtonNumber,bool)));
connect(pl->sdlGamepad,SIGNAL(axesValues(QListInt16)),this,SLOT(axesValues(QListInt16)));
}
GCSControlGadget::~GCSControlGadget()
{
delete m_widget;
}
void GCSControlGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
GCSControlGadgetConfiguration *GCSControlConfig = qobject_cast< GCSControlGadgetConfiguration*>(config);
QList<int> ql = GCSControlConfig->getChannelsMapping();
rollChannel = ql.at(0);
pitchChannel = ql.at(1);
yawChannel = ql.at(2);
throttleChannel = ql.at(3);
controlsMode = GCSControlConfig->getControlsMode();
int i;
for (i=0;i<8;i++)
{
buttonSettings[i].ActionID=GCSControlConfig->getbuttonSettings(i).ActionID;
buttonSettings[i].FunctionID=GCSControlConfig->getbuttonSettings(i).FunctionID;
buttonSettings[i].Amount=GCSControlConfig->getbuttonSettings(i).Amount;
buttonSettings[i].Amount=GCSControlConfig->getbuttonSettings(i).Amount;
channelReverse[i]=GCSControlConfig->getChannelsReverse().at(i);
}
}
ManualControlCommand* GCSControlGadget::getManualControlCommand() {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
return dynamic_cast<ManualControlCommand*>( objManager->getObject(QString("ManualControlCommand")) );
}
void GCSControlGadget::manualControlCommandUpdated(UAVObject * obj) {
double roll = obj->getField("Roll")->getDouble();
double pitch = obj->getField("Pitch")->getDouble();
double yaw = obj->getField("Yaw")->getDouble();
double throttle = obj->getField("Throttle")->getDouble();
// Remap RPYT to left X/Y and right X/Y depending on mode
switch (controlsMode) {
case 1:
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
emit sticksChangedRemotely(yaw,-pitch,roll,throttle);
break;
case 2:
// Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch
emit sticksChangedRemotely(yaw,throttle,roll,-pitch);
break;
case 3:
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
emit sticksChangedRemotely(roll,-pitch,yaw,throttle);
break;
case 4:
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
emit sticksChangedRemotely(roll,throttle,yaw,-pitch);
break;
}
}
/**
Update the manual commands - maps depending on mode
*/
void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double rightX, double rightY) {
ManualControlCommand * obj = getManualControlCommand();
double oldRoll = obj->getField("Roll")->getDouble();
double oldPitch = obj->getField("Pitch")->getDouble();
double oldYaw = obj->getField("Yaw")->getDouble();
double oldThrottle = obj->getField("Throttle")->getDouble();
double newRoll;
double newPitch;
double newYaw;
double newThrottle;
// Remap left X/Y and right X/Y to RPYT depending on mode
switch (controlsMode) {
case 1:
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
newRoll = rightX;
newPitch = -leftY;
newYaw = leftX;
newThrottle = rightY;
break;
case 2:
// Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch
newRoll = rightX;
newPitch = -rightY;
newYaw = leftX;
newThrottle = leftY;
break;
case 3:
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
newRoll = leftX;
newPitch = -leftY;
newYaw = rightX;
newThrottle = rightY;
break;
case 4:
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
newRoll = leftX;
newPitch = -rightY;
newYaw = rightX;
newThrottle = leftY;
break;
}
//check if buttons have control over this axis... if so don't update it
int buttonRollControl=0;
int buttonPitchControl=0;
int buttonYawControl=0;
int buttonThrottleControl=0;
for (int i=0;i<8;i++)
{
if ((buttonSettings[i].FunctionID==1)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonRollControl=1;
if ((buttonSettings[i].FunctionID==2)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonPitchControl=1;
if ((buttonSettings[i].FunctionID==3)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonYawControl=1;
if ((buttonSettings[i].FunctionID==4)&&((buttonSettings[i].ActionID==1)||(buttonSettings[i].ActionID==2)))buttonThrottleControl=1;
}
//if we are not in local gcs control mode, ignore the joystick input
if (((GCSControlGadgetWidget *)m_widget)->getGCSControl()==false)return;
if((newThrottle != oldThrottle) || (newPitch != oldPitch) || (newYaw != oldYaw) || (newRoll != oldRoll)) {
if (buttonRollControl==0)obj->getField("Roll")->setDouble(newRoll);
if (buttonPitchControl==0)obj->getField("Pitch")->setDouble(newPitch);
if (buttonYawControl==0)obj->getField("Yaw")->setDouble(newYaw);
if (buttonThrottleControl==0)obj->getField("Throttle")->setDouble(newThrottle);
obj->updated();
}
}
void GCSControlGadget::gamepads(quint8 count)
{
// sdlGamepad.setGamepad(0);
// sdlGamepad.setTickRate(JOYSTICK_UPDATE_RATE);
}
void GCSControlGadget::buttonState(ButtonNumber number, bool pressed)
{
int state;
if ((buttonSettings[number].ActionID>0)&&(buttonSettings[number].FunctionID>0)&&(pressed))
{//this button is configured
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("ManualControlCommand")) );
bool currentCGSControl = ((GCSControlGadgetWidget *)m_widget)->getGCSControl();
switch (buttonSettings[number].ActionID)
{
case 1://increase
if (currentCGSControl)
{
switch (buttonSettings[number].FunctionID)
{
case 1://Roll
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()+buttonSettings[number].Amount));
break;
case 2://Pitch
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()+buttonSettings[number].Amount));
break;
case 3://Yaw
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()+buttonSettings[number].Amount));
break;
case 4://Throttle
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()+buttonSettings[number].Amount));
break;
}
}
break;
case 2://decrease
if (currentCGSControl)
{
switch (buttonSettings[number].FunctionID)
{
case 1://Roll
obj->getField("Roll")->setValue(bound(obj->getField("Roll")->getValue().toDouble()-buttonSettings[number].Amount));
break;
case 2://Pitch
obj->getField("Pitch")->setValue(bound(obj->getField("Pitch")->getValue().toDouble()-buttonSettings[number].Amount));
break;
case 3://Yaw
obj->getField("Yaw")->setValue(wrap(obj->getField("Yaw")->getValue().toDouble()-buttonSettings[number].Amount));
break;
case 4://Throttle
obj->getField("Throttle")->setValue(bound(obj->getField("Throttle")->getValue().toDouble()-buttonSettings[number].Amount));
break;
}
}
break;
case 3://toggle
switch (buttonSettings[number].FunctionID)
{
case 1://Armed
if (currentCGSControl)
{
if(obj->getField("Armed")->getValue().toString().compare("True")==0)
{
obj->getField("Armed")->setValue("False");
}
else
{
obj->getField("Armed")->setValue("True");
}
}
break;
case 2://GCS Control
//Toggle the GCS Control checkbox, its built in signalling will handle the update to OP
((GCSControlGadgetWidget *)m_widget)->setGCSControl(!currentCGSControl);
break;
}
break;
}
obj->updated();
}
//buttonSettings[number].ActionID NIDT
//buttonSettings[number].FunctionID -RPYTAC
//buttonSettings[number].Amount
}
void GCSControlGadget::axesValues(QListInt16 values)
{
int chMax = values.length();
if (rollChannel > chMax || pitchChannel > chMax ||
yawChannel > chMax || throttleChannel > chMax ) {
qDebug() << "GCSControl: configuration is inconsistent with current joystick! Aborting update.";
return;
}
double rValue = (rollChannel > -1) ? values[rollChannel] : 0;
double pValue = (pitchChannel > -1) ? values[pitchChannel] : 0;
double yValue = (yawChannel > -1) ? values[yawChannel] : 0;
double tValue = (throttleChannel > -1) ? values[throttleChannel] : 0;
double max = 32767;
if (rollChannel > -1) if(channelReverse[rollChannel]==true)rValue = -rValue;
if (pitchChannel > -1) if(channelReverse[pitchChannel]==true)pValue = -pValue;
if (yawChannel > -1) if(channelReverse[yawChannel]==true)yValue = -yValue;
if (throttleChannel > -1) if(channelReverse[throttleChannel]==true)tValue = -tValue;
if(joystickTime.elapsed() > JOYSTICK_UPDATE_RATE) {
joystickTime.restart();
// Remap RPYT to left X/Y and right X/Y depending on mode
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
// Mode 2: LeftX = Yaw, LeftY = THrottle, RightX = Roll, RightY = Pitch
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
switch (controlsMode) {
case 1:
sticksChangedLocally(yValue/max,-pValue/max,rValue/max,-tValue/max);
break;
case 2:
sticksChangedLocally(yValue/max,-tValue/max,rValue/max,-pValue/max);
break;
case 3:
sticksChangedLocally(rValue/max,-pValue/max,yValue/max,-tValue/max);
break;
case 4:
sticksChangedLocally(rValue/max,-tValue/max,yValue/max,-pValue/max);
break;
}
}
}
double GCSControlGadget::bound(double input)
{
if (input > 1.0)return 1.0;
if (input <-1.0)return -1.0;
return input;
}
double GCSControlGadget::wrap(double input)
{
while (input > 1.0)input -= 2.0;
while (input <-1.0)input += 2.0;
return input;
}

View File

@ -1,171 +1,172 @@
/**
******************************************************************************
*
* @file gpsdisplaygadget.cpp
* @author Edouard Lafargue Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A gadget that displays GPS status and enables basic configuration
*****************************************************************************/
/*
* 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 "gpsdisplaygadget.h"
#include "gpsdisplaywidget.h"
#include "gpsdisplaygadgetconfiguration.h"
GpsDisplayGadget::GpsDisplayGadget(QString classId, GpsDisplayWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget),
connected(FALSE)
{
connect(m_widget->connectButton, SIGNAL(clicked(bool)), this,SLOT(onConnect()));
connect(m_widget->disconnectButton, SIGNAL(clicked(bool)), this,SLOT(onDisconnect()));
}
GpsDisplayGadget::~GpsDisplayGadget()
{
}
/*
This is called when a configuration is loaded, and updates the plugin's settings.
Careful: the plugin is already drawn before the loadConfiguration method is called the
first time, so you have to be careful not to assume all the plugin values are initialized
the first time you use them
*/
void GpsDisplayGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
// Delete the (old)port, this also closes it.
if(port) {
delete port;
}
// Delete the (old)parser, this also disconnects all signals.
if(parser) {
delete parser;
}
GpsDisplayGadgetConfiguration *gpsDisplayConfig = qobject_cast< GpsDisplayGadgetConfiguration*>(config);
if (gpsDisplayConfig->connectionMode() == "Serial") {
PortSettings portsettings;
portsettings.BaudRate=gpsDisplayConfig->speed();
portsettings.DataBits=gpsDisplayConfig->dataBits();
portsettings.FlowControl=gpsDisplayConfig->flow();
portsettings.Parity=gpsDisplayConfig->parity();
portsettings.StopBits=gpsDisplayConfig->stopBits();
portsettings.Timeout_Millisec=gpsDisplayConfig->timeOut();
// In case we find no port, buttons disabled
m_widget->connectButton->setEnabled(false);
m_widget->disconnectButton->setEnabled(false);
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach( QextPortInfo nport, ports ) {
if(nport.friendName == gpsDisplayConfig->port())
{
qDebug() << "Using Serial parser";
parser = new NMEAParser();
#ifdef Q_OS_WIN
port=new QextSerialPort(nport.portName,portsettings,QextSerialPort::EventDriven);
#else
port=new QextSerialPort(nport.physName,portsettings,QextSerialPort::EventDriven);
#endif
m_widget->connectButton->setEnabled(true);
m_widget->disconnectButton->setEnabled(false);
m_widget->connectButton->setHidden(false);
m_widget->disconnectButton->setHidden(false);
connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
}
}
m_widget->dataStreamGroupBox->setHidden(false);
} else if (gpsDisplayConfig->connectionMode() == "Telemetry") {
qDebug() << "Using Telemetry parser";
parser = new TelemetryParser();
m_widget->disconnectButton->setHidden(true);
m_widget->connectButton->setHidden(true);
m_widget->dataStreamGroupBox->setHidden(true);
} else if (gpsDisplayConfig->connectionMode() == "Network") {
// Not implemented for now...
m_widget->connectButton->setEnabled(false);
m_widget->disconnectButton->setEnabled(false);
m_widget->dataStreamGroupBox->setHidden(false);
}
connect(parser, SIGNAL(sv(int)), m_widget,SLOT(setSVs(int)));
connect(parser, SIGNAL(position(double,double,double)), m_widget,SLOT(setPosition(double,double,double)));
connect(parser, SIGNAL(speedheading(double,double)), m_widget,SLOT(setSpeedHeading(double,double)));
connect(parser, SIGNAL(datetime(double,double)), m_widget,SLOT(setDateTime(double,double)));
connect(parser, SIGNAL(packet(QString)), m_widget, SLOT(dumpPacket(QString)));
connect(parser, SIGNAL(satellite(int,int,int,int,int)), m_widget->gpsSky, SLOT(updateSat(int,int,int,int,int)));
connect(parser, SIGNAL(satellite(int,int,int,int,int)), m_widget->gpsSnrWidget, SLOT(updateSat(int,int,int,int,int)));
connect(parser, SIGNAL(fixtype(QString)), m_widget, SLOT(setFixType(QString)));
connect(parser, SIGNAL(dop(double,double,double)), m_widget, SLOT(setDOP(double,double,double)));
}
void GpsDisplayGadget::onConnect() {
m_widget->textBrowser->append(QString("Connecting to GPS ...\n"));
// TODO: Somehow mark that we're running, and disable connect button while so?
if (port) {
qDebug() << "Opening: " << port->portName() << ".";
bool isOpen = port->open(QIODevice::ReadWrite);
qDebug() << "Open: " << isOpen;
if(isOpen) {
m_widget->connectButton->setEnabled(false);
m_widget->disconnectButton->setEnabled(true);
}
} else {
qDebug() << "Port undefined or invalid.";
}
}
void GpsDisplayGadget::onDisconnect() {
if (port) {
qDebug() << "Closing: " << port->portName() << ".";
port->close();
m_widget->connectButton->setEnabled(true);
m_widget->disconnectButton->setEnabled(false);
} else {
qDebug() << "Port undefined or invalid.";
}
}
void GpsDisplayGadget::onDataAvailable() {
int avail = port->bytesAvailable();
if( avail > 0 ) {
QByteArray serialData;
serialData.resize(avail);
int bytesRead = port->read(serialData.data(), serialData.size());
if( bytesRead > 0 ) {
processNewSerialData(serialData);
}
}
}
void GpsDisplayGadget::processNewSerialData(QByteArray serialData) {
int dataLength = serialData.size();
const char* data = serialData.constData();
for(int pos = 0; pos < dataLength; pos++) {
parser->processInputStream(data[pos]);
}
}
/**
******************************************************************************
*
* @file gpsdisplaygadget.cpp
* @author Edouard Lafargue Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GPSGadgetPlugin GPS Gadget Plugin
* @{
* @brief A gadget that displays GPS status and enables basic configuration
*****************************************************************************/
/*
* 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 "gpsdisplaygadget.h"
#include "gpsdisplaywidget.h"
#include "gpsdisplaygadgetconfiguration.h"
GpsDisplayGadget::GpsDisplayGadget(QString classId, GpsDisplayWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget),
connected(FALSE)
{
connect(m_widget->connectButton, SIGNAL(clicked(bool)), this,SLOT(onConnect()));
connect(m_widget->disconnectButton, SIGNAL(clicked(bool)), this,SLOT(onDisconnect()));
}
GpsDisplayGadget::~GpsDisplayGadget()
{
delete m_widget;
}
/*
This is called when a configuration is loaded, and updates the plugin's settings.
Careful: the plugin is already drawn before the loadConfiguration method is called the
first time, so you have to be careful not to assume all the plugin values are initialized
the first time you use them
*/
void GpsDisplayGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
// Delete the (old)port, this also closes it.
if(port) {
delete port;
}
// Delete the (old)parser, this also disconnects all signals.
if(parser) {
delete parser;
}
GpsDisplayGadgetConfiguration *gpsDisplayConfig = qobject_cast< GpsDisplayGadgetConfiguration*>(config);
if (gpsDisplayConfig->connectionMode() == "Serial") {
PortSettings portsettings;
portsettings.BaudRate=gpsDisplayConfig->speed();
portsettings.DataBits=gpsDisplayConfig->dataBits();
portsettings.FlowControl=gpsDisplayConfig->flow();
portsettings.Parity=gpsDisplayConfig->parity();
portsettings.StopBits=gpsDisplayConfig->stopBits();
portsettings.Timeout_Millisec=gpsDisplayConfig->timeOut();
// In case we find no port, buttons disabled
m_widget->connectButton->setEnabled(false);
m_widget->disconnectButton->setEnabled(false);
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach( QextPortInfo nport, ports ) {
if(nport.friendName == gpsDisplayConfig->port())
{
qDebug() << "Using Serial parser";
parser = new NMEAParser();
#ifdef Q_OS_WIN
port=new QextSerialPort(nport.portName,portsettings,QextSerialPort::EventDriven);
#else
port=new QextSerialPort(nport.physName,portsettings,QextSerialPort::EventDriven);
#endif
m_widget->connectButton->setEnabled(true);
m_widget->disconnectButton->setEnabled(false);
m_widget->connectButton->setHidden(false);
m_widget->disconnectButton->setHidden(false);
connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
}
}
m_widget->dataStreamGroupBox->setHidden(false);
} else if (gpsDisplayConfig->connectionMode() == "Telemetry") {
qDebug() << "Using Telemetry parser";
parser = new TelemetryParser();
m_widget->disconnectButton->setHidden(true);
m_widget->connectButton->setHidden(true);
m_widget->dataStreamGroupBox->setHidden(true);
} else if (gpsDisplayConfig->connectionMode() == "Network") {
// Not implemented for now...
m_widget->connectButton->setEnabled(false);
m_widget->disconnectButton->setEnabled(false);
m_widget->dataStreamGroupBox->setHidden(false);
}
connect(parser, SIGNAL(sv(int)), m_widget,SLOT(setSVs(int)));
connect(parser, SIGNAL(position(double,double,double)), m_widget,SLOT(setPosition(double,double,double)));
connect(parser, SIGNAL(speedheading(double,double)), m_widget,SLOT(setSpeedHeading(double,double)));
connect(parser, SIGNAL(datetime(double,double)), m_widget,SLOT(setDateTime(double,double)));
connect(parser, SIGNAL(packet(QString)), m_widget, SLOT(dumpPacket(QString)));
connect(parser, SIGNAL(satellite(int,int,int,int,int)), m_widget->gpsSky, SLOT(updateSat(int,int,int,int,int)));
connect(parser, SIGNAL(satellite(int,int,int,int,int)), m_widget->gpsSnrWidget, SLOT(updateSat(int,int,int,int,int)));
connect(parser, SIGNAL(fixtype(QString)), m_widget, SLOT(setFixType(QString)));
connect(parser, SIGNAL(dop(double,double,double)), m_widget, SLOT(setDOP(double,double,double)));
}
void GpsDisplayGadget::onConnect() {
m_widget->textBrowser->append(QString("Connecting to GPS ...\n"));
// TODO: Somehow mark that we're running, and disable connect button while so?
if (port) {
qDebug() << "Opening: " << port->portName() << ".";
bool isOpen = port->open(QIODevice::ReadWrite);
qDebug() << "Open: " << isOpen;
if(isOpen) {
m_widget->connectButton->setEnabled(false);
m_widget->disconnectButton->setEnabled(true);
}
} else {
qDebug() << "Port undefined or invalid.";
}
}
void GpsDisplayGadget::onDisconnect() {
if (port) {
qDebug() << "Closing: " << port->portName() << ".";
port->close();
m_widget->connectButton->setEnabled(true);
m_widget->disconnectButton->setEnabled(false);
} else {
qDebug() << "Port undefined or invalid.";
}
}
void GpsDisplayGadget::onDataAvailable() {
int avail = port->bytesAvailable();
if( avail > 0 ) {
QByteArray serialData;
serialData.resize(avail);
int bytesRead = port->read(serialData.data(), serialData.size());
if( bytesRead > 0 ) {
processNewSerialData(serialData);
}
}
}
void GpsDisplayGadget::processNewSerialData(QByteArray serialData) {
int dataLength = serialData.size();
const char* data = serialData.constData();
for(int pos = 0; pos < dataLength; pos++) {
parser->processInputStream(data[pos]);
}
}

View File

@ -1,67 +1,67 @@
/**
******************************************************************************
*
* @file hitl.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup HITLPlugin HITL Plugin
* @{
* @brief The Hardware In The Loop 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
*/
#include "hitlgadget.h"
#include "hitlwidget.h"
#include "hitlconfiguration.h"
#include "simulator.h"
HITLGadget::HITLGadget(QString classId, HITLWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
connect(this,SIGNAL(changeConfiguration(void)),m_widget,SLOT(stopButtonClicked(void)));
}
HITLGadget::~HITLGadget()
{
}
void HITLGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
HITLConfiguration *m = qobject_cast<HITLConfiguration*>(config);
// FG
// simulator->setFGPathBin( m->fgPathBin() );
// simulator->setFGPathData( m->fgPathData() );
// simulator->setFGManualControl( m->fgManualControl() );
// // IL2
emit changeConfiguration();
m_widget->setSettingParameters(m->Settings());
// m_widget->setSimulatorId(m->SimulatorId());
// m_widget->setPathBin(m->PathBin());
// m_widget->setPathData(m->PathData());
// m_widget->setHostName(m->HostName());
// m_widget->setLatitude(m->Latitude());
// m_widget->setLongitude(m->Longitude());
// m_widget->setOutPort(m->OutPort());
// m_widget->setInPort(m->InPort());
// m_widget->setManualControl(m->ManualControl());
}
/**
******************************************************************************
*
* @file hitl.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup HITLPlugin HITL Plugin
* @{
* @brief The Hardware In The Loop 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
*/
#include "hitlgadget.h"
#include "hitlwidget.h"
#include "hitlconfiguration.h"
#include "simulator.h"
HITLGadget::HITLGadget(QString classId, HITLWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
connect(this,SIGNAL(changeConfiguration(void)),m_widget,SLOT(stopButtonClicked(void)));
}
HITLGadget::~HITLGadget()
{
delete m_widget;
}
void HITLGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
HITLConfiguration *m = qobject_cast<HITLConfiguration*>(config);
// FG
// simulator->setFGPathBin( m->fgPathBin() );
// simulator->setFGPathData( m->fgPathData() );
// simulator->setFGManualControl( m->fgManualControl() );
// // IL2
emit changeConfiguration();
m_widget->setSettingParameters(m->Settings());
// m_widget->setSimulatorId(m->SimulatorId());
// m_widget->setPathBin(m->PathBin());
// m_widget->setPathData(m->PathData());
// m_widget->setHostName(m->HostName());
// m_widget->setLatitude(m->Latitude());
// m_widget->setLongitude(m->Longitude());
// m_widget->setOutPort(m->OutPort());
// m_widget->setInPort(m->InPort());
// m_widget->setManualControl(m->ManualControl());
}

View File

@ -39,6 +39,7 @@ ImportExportGadget::ImportExportGadget(QString classId, ImportExportGadgetWidget
ImportExportGadget::~ImportExportGadget()
{
delete m_widget;
}
/*

View File

@ -1,47 +1,47 @@
/**
******************************************************************************
*
* @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 "logginggadget.h"
#include "logginggadgetwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
LoggingGadget::LoggingGadget(QString classId, LoggingGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
LoggingGadget::~LoggingGadget()
{
}
void LoggingGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
}
/**
******************************************************************************
*
* @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 "logginggadget.h"
#include "logginggadgetwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
LoggingGadget::LoggingGadget(QString classId, LoggingGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
LoggingGadget::~LoggingGadget()
{
delete m_widget;
}
void LoggingGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
}

View File

@ -1,48 +1,49 @@
/**
******************************************************************************
*
* @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 "magicwaypointgadget.h"
#include "magicwaypointgadgetwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include <QDebug>
MagicWaypointGadget::MagicWaypointGadget(QString classId, MagicWaypointGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
MagicWaypointGadget::~MagicWaypointGadget()
{
}
void MagicWaypointGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
Q_UNUSED(config);
}
/**
******************************************************************************
*
* @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 "magicwaypointgadget.h"
#include "magicwaypointgadgetwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include <QDebug>
MagicWaypointGadget::MagicWaypointGadget(QString classId, MagicWaypointGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
MagicWaypointGadget::~MagicWaypointGadget()
{
delete m_widget;
}
void MagicWaypointGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
Q_UNUSED(config);
}

View File

@ -1,50 +1,50 @@
/**
******************************************************************************
*
* @file modelviewgadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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 "modelviewgadget.h"
#include "modelviewgadgetwidget.h"
#include "modelviewgadgetconfiguration.h"
ModelViewGadget::ModelViewGadget(QString classId, ModelViewGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
ModelViewGadget::~ModelViewGadget()
{
}
void ModelViewGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
ModelViewGadgetConfiguration *m = qobject_cast<ModelViewGadgetConfiguration*>(config);
m_widget->setAcFilename(m->acFilename());
m_widget->setBgFilename(m->bgFilename());
m_widget->setVboEnable(m->vboEnabled());
m_widget->reloadScene();
}
/**
******************************************************************************
*
* @file modelviewgadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ModelViewPlugin ModelView Plugin
* @{
* @brief A gadget that displays a 3D representation of the UAV
*****************************************************************************/
/*
* 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 "modelviewgadget.h"
#include "modelviewgadgetwidget.h"
#include "modelviewgadgetconfiguration.h"
ModelViewGadget::ModelViewGadget(QString classId, ModelViewGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
ModelViewGadget::~ModelViewGadget()
{
delete m_widget;
}
void ModelViewGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
ModelViewGadgetConfiguration *m = qobject_cast<ModelViewGadgetConfiguration*>(config);
m_widget->setAcFilename(m->acFilename());
m_widget->setBgFilename(m->bgFilename());
m_widget->setVboEnable(m->vboEnabled());
m_widget->reloadScene();
}

View File

@ -1,54 +1,55 @@
/**
******************************************************************************
*
* @file opmapgadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup OPMapPlugin OpenPilot Map Plugin
* @{
* @brief The OpenPilot Map 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
*/
#include "opmapgadget.h"
#include "opmapgadgetwidget.h"
#include "opmapgadgetconfiguration.h"
OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
OPMapGadget::~OPMapGadget()
{
}
void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
{
OPMapGadgetConfiguration *m = qobject_cast<OPMapGadgetConfiguration*>(config);
m_widget->setMapProvider(m->mapProvider());
m_widget->setZoom(m->zoom());
m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
m_widget->setUseOpenGL(m->useOpenGL());
m_widget->setShowTileGridLines(m->showTileGridLines());
m_widget->setAccessMode(m->accessMode());
m_widget->setUseMemoryCache(m->useMemoryCache());
m_widget->setCacheLocation(m->cacheLocation());
}
/**
******************************************************************************
*
* @file opmapgadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup OPMapPlugin OpenPilot Map Plugin
* @{
* @brief The OpenPilot Map 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
*/
#include "opmapgadget.h"
#include "opmapgadgetwidget.h"
#include "opmapgadgetconfiguration.h"
OPMapGadget::OPMapGadget(QString classId, OPMapGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
OPMapGadget::~OPMapGadget()
{
delete m_widget;
}
void OPMapGadget::loadConfiguration(IUAVGadgetConfiguration *config)
{
OPMapGadgetConfiguration *m = qobject_cast<OPMapGadgetConfiguration*>(config);
m_widget->setMapProvider(m->mapProvider());
m_widget->setZoom(m->zoom());
m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
m_widget->setUseOpenGL(m->useOpenGL());
m_widget->setShowTileGridLines(m->showTileGridLines());
m_widget->setAccessMode(m->accessMode());
m_widget->setUseMemoryCache(m->useMemoryCache());
m_widget->setCacheLocation(m->cacheLocation());
}

View File

@ -32,25 +32,18 @@
#include <coreplugin/iuavgadget.h>
OPMapGadgetFactory::OPMapGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("OPMapGadget"), tr("OPMap Gadget"), parent),
gadgetWidget(NULL)
IUAVGadgetFactory(QString("OPMapGadget"), tr("OPMap Gadget"), parent)
{
}
OPMapGadgetFactory::~OPMapGadgetFactory()
{
if (gadgetWidget)
{
delete gadgetWidget;
gadgetWidget = NULL;
}
}
Core::IUAVGadget * OPMapGadgetFactory::createGadget(QWidget *parent)
{
// OPMapGadgetWidget *gadgetWidget = new OPMapGadgetWidget(parent);
gadgetWidget = new OPMapGadgetWidget(parent);
return new OPMapGadget(QString("OPMapGadget"), gadgetWidget, parent);
OPMapGadgetWidget *gadgetWidget = new OPMapGadgetWidget(parent);
return new OPMapGadget(QString("OPMapGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *OPMapGadgetFactory::createConfiguration(QSettings* qSettings)

View File

@ -50,9 +50,6 @@ public:
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
protected:
OPMapGadgetWidget *gadgetWidget;
};
#endif // OPMAP_GADGETFACTORY_H_

View File

@ -31,24 +31,17 @@
#include <coreplugin/iuavgadget.h>
PipXtremeGadgetFactory::PipXtremeGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("PipXtreme"), tr("PipXtreme Gadget"), parent),
gadgetWidget(NULL)
IUAVGadgetFactory(QString("PipXtreme"), tr("PipXtreme Gadget"), parent)
{
}
PipXtremeGadgetFactory::~PipXtremeGadgetFactory()
{
if (gadgetWidget)
{
delete gadgetWidget;
gadgetWidget = NULL;
}
}
Core::IUAVGadget* PipXtremeGadgetFactory::createGadget(QWidget *parent)
{
// PipXtremeGadgetWidget *gadgetWidget = new PipXtremeGadgetWidget(parent);
gadgetWidget = new PipXtremeGadgetWidget(parent);
PipXtremeGadgetWidget *gadgetWidget = new PipXtremeGadgetWidget(parent);
return new PipXtremeGadget(QString("PipXtreme"), gadgetWidget, parent);
}

View File

@ -48,9 +48,6 @@ public:
IUAVGadgetConfiguration * createConfiguration(QSettings *qSettings);
IOptionsPage * createOptionsPage(IUAVGadgetConfiguration *config);
protected:
PipXtremeGadgetWidget *gadgetWidget;
};
#endif