Commit f3286d58 authored by Don Gagne's avatar Don Gagne

Remove unreachable APM code

parent 6cb8eb14
......@@ -324,38 +324,11 @@ FORMS += \
src/ui/uas/QGCMessageView.ui \
src/ui/JoystickButton.ui \
src/ui/JoystickAxis.ui \
src/ui/configuration/ApmHardwareConfig.ui \
src/ui/configuration/ApmSoftwareConfig.ui \
src/ui/configuration/FrameTypeConfig.ui \
src/ui/configuration/CompassConfig.ui \
src/ui/configuration/AccelCalibrationConfig.ui \
src/ui/configuration/RadioCalibrationConfig.ui \
src/ui/configuration/FlightModeConfig.ui \
src/ui/configuration/Radio3DRConfig.ui \
src/ui/configuration/BatteryMonitorConfig.ui \
src/ui/configuration/SonarConfig.ui \
src/ui/configuration/AirspeedConfig.ui \
src/ui/configuration/OpticalFlowConfig.ui \
src/ui/configuration/OsdConfig.ui \
src/ui/configuration/AntennaTrackerConfig.ui \
src/ui/configuration/CameraGimbalConfig.ui \
src/ui/configuration/BasicPidConfig.ui \
src/ui/configuration/StandardParamConfig.ui \
src/ui/configuration/GeoFenceConfig.ui \
src/ui/configuration/FailSafeConfig.ui \
src/ui/configuration/AdvancedParamConfig.ui \
src/ui/configuration/ArduCopterPidConfig.ui \
src/ui/configuration/ApmPlaneLevel.ui \
src/ui/configuration/ParamWidget.ui \
src/ui/configuration/ArduPlanePidConfig.ui \
src/ui/configuration/AdvParameterList.ui \
src/ui/configuration/ArduRoverPidConfig.ui \
src/ui/QGCConfigView.ui \
src/ui/main/QGCViewModeSelection.ui \
src/ui/main/QGCWelcomeMainWindow.ui \
src/ui/configuration/terminalconsole.ui \
src/ui/configuration/SerialSettingsDialog.ui \
src/ui/configuration/ApmFirmwareConfig.ui \
src/ui/px4_configuration/QGCPX4AirframeConfig.ui \
src/ui/px4_configuration/QGCPX4MulticopterConfig.ui \
src/ui/px4_configuration/QGCPX4SensorCalibration.ui \
......@@ -411,7 +384,6 @@ HEADERS += \
src/ui/QGCSensorSettingsWidget.h \
src/ui/linechart/Linecharts.h \
src/uas/PxQuadMAV.h \
src/uas/ArduPilotMegaMAV.h \
src/uas/senseSoarMAV.h \
src/ui/watchdog/WatchdogControl.h \
src/ui/watchdog/WatchdogProcessView.h \
......@@ -503,34 +475,6 @@ HEADERS += \
src/ui/uas/QGCMessageView.h \
src/ui/JoystickButton.h \
src/ui/JoystickAxis.h \
src/ui/configuration/ApmHardwareConfig.h \
src/ui/configuration/ApmSoftwareConfig.h \
src/ui/configuration/FrameTypeConfig.h \
src/ui/configuration/CompassConfig.h \
src/ui/configuration/AccelCalibrationConfig.h \
src/ui/configuration/RadioCalibrationConfig.h \
src/ui/configuration/FlightModeConfig.h \
src/ui/configuration/Radio3DRConfig.h \
src/ui/configuration/BatteryMonitorConfig.h \
src/ui/configuration/SonarConfig.h \
src/ui/configuration/AirspeedConfig.h \
src/ui/configuration/OpticalFlowConfig.h \
src/ui/configuration/OsdConfig.h \
src/ui/configuration/AntennaTrackerConfig.h \
src/ui/configuration/CameraGimbalConfig.h \
src/ui/configuration/AP2ConfigWidget.h \
src/ui/configuration/BasicPidConfig.h \
src/ui/configuration/StandardParamConfig.h \
src/ui/configuration/GeoFenceConfig.h \
src/ui/configuration/FailSafeConfig.h \
src/ui/configuration/AdvancedParamConfig.h \
src/ui/configuration/ArduCopterPidConfig.h \
src/ui/apmtoolbar.h \
src/ui/configuration/ApmPlaneLevel.h \
src/ui/configuration/ParamWidget.h \
src/ui/configuration/ArduPlanePidConfig.h \
src/ui/configuration/AdvParameterList.h \
src/ui/configuration/ArduRoverPidConfig.h \
src/ui/QGCConfigView.h \
src/ui/main/QGCViewModeSelection.h \
src/ui/main/QGCWelcomeMainWindow.h \
......@@ -538,7 +482,6 @@ HEADERS += \
src/ui/configuration/SerialSettingsDialog.h \
src/ui/configuration/terminalconsole.h \
src/ui/configuration/ApmHighlighter.h \
src/ui/configuration/ApmFirmwareConfig.h \
src/uas/UASParameterDataModel.h \
src/uas/UASParameterCommsMgr.h \
src/ui/QGCPendingParamWidget.h \
......@@ -602,7 +545,6 @@ SOURCES += \
src/ui/QGCSensorSettingsWidget.cc \
src/ui/linechart/Linecharts.cc \
src/uas/PxQuadMAV.cc \
src/uas/ArduPilotMegaMAV.cc \
src/uas/senseSoarMAV.cpp \
src/ui/watchdog/WatchdogControl.cc \
src/ui/watchdog/WatchdogProcessView.cc \
......@@ -691,34 +633,6 @@ SOURCES += \
src/ui/JoystickButton.cc \
src/ui/JoystickAxis.cc \
src/ui/uas/QGCMessageView.cc \
src/ui/configuration/ApmHardwareConfig.cc \
src/ui/configuration/ApmSoftwareConfig.cc \
src/ui/configuration/FrameTypeConfig.cc \
src/ui/configuration/CompassConfig.cc \
src/ui/configuration/AccelCalibrationConfig.cc \
src/ui/configuration/RadioCalibrationConfig.cc \
src/ui/configuration/FlightModeConfig.cc \
src/ui/configuration/Radio3DRConfig.cc \
src/ui/configuration/BatteryMonitorConfig.cc \
src/ui/configuration/SonarConfig.cc \
src/ui/configuration/AirspeedConfig.cc \
src/ui/configuration/OpticalFlowConfig.cc \
src/ui/configuration/OsdConfig.cc \
src/ui/configuration/AntennaTrackerConfig.cc \
src/ui/configuration/CameraGimbalConfig.cc \
src/ui/configuration/AP2ConfigWidget.cc \
src/ui/configuration/BasicPidConfig.cc \
src/ui/configuration/StandardParamConfig.cc \
src/ui/configuration/GeoFenceConfig.cc \
src/ui/configuration/FailSafeConfig.cc \
src/ui/configuration/AdvancedParamConfig.cc \
src/ui/configuration/ArduCopterPidConfig.cc \
src/ui/apmtoolbar.cpp \
src/ui/configuration/ApmPlaneLevel.cc \
src/ui/configuration/ParamWidget.cc \
src/ui/configuration/ArduPlanePidConfig.cc \
src/ui/configuration/AdvParameterList.cc \
src/ui/configuration/ArduRoverPidConfig.cc \
src/ui/QGCConfigView.cc \
src/ui/main/QGCViewModeSelection.cc \
src/ui/main/QGCWelcomeMainWindow.cc \
......@@ -726,7 +640,6 @@ SOURCES += \
src/ui/configuration/console.cpp \
src/ui/configuration/SerialSettingsDialog.cc \
src/ui/configuration/ApmHighlighter.cc \
src/ui/configuration/ApmFirmwareConfig.cc \
src/uas/UASParameterDataModel.cc \
src/uas/UASParameterCommsMgr.cc \
src/ui/QGCPendingParamWidget.cc \
......@@ -768,7 +681,6 @@ HEADERS += \
src/qgcunittest/MockMavlinkInterface.h \
src/qgcunittest/MockMavlinkFileServer.h \
src/qgcunittest/MultiSignalSpy.h \
src/qgcunittest/FlightModeConfigTest.h \
src/qgcunittest/FlightGearTest.h \
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/TCPLoopBackServer.h \
......@@ -782,7 +694,6 @@ SOURCES += \
src/qgcunittest/MockQGCUASParamManager.cc \
src/qgcunittest/MockMavlinkFileServer.cc \
src/qgcunittest/MultiSignalSpy.cc \
src/qgcunittest/FlightModeConfigTest.cc \
src/qgcunittest/FlightGearTest.cc \
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/TCPLoopBackServer.cc \
......
......@@ -25,7 +25,6 @@
#include "UASInterface.h"
#include "UAS.h"
#include "PxQuadMAV.h"
#include "ArduPilotMegaMAV.h"
#include "configuration.h"
#include "LinkManager.h"
#include "QGCMAVLink.h"
......
......@@ -585,28 +585,6 @@ void MAVLinkSimulationLink::mainloop()
memcpy(stream+streampointer, buffer, bufferlength);
streampointer += bufferlength;
// // HEARTBEAT VEHICLE 2
// // Pack message and get size of encoded byte string
// mavlink_msg_heartbeat_pack(54, componentId, &msg, MAV_HELICOPTER, MAV_AUTOPILOT_ARDUPILOTMEGA);
// // Allocate buffer with packet data
// bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
// //add data into datastream
// memcpy(stream+streampointer,buffer, bufferlength);
// streampointer += bufferlength;
// // HEARTBEAT VEHICLE 3
// // Pack message and get size of encoded byte string
// mavlink_msg_heartbeat_pack(60, componentId, &msg, MAV_FIXED_WING, MAV_AUTOPILOT_PIXHAWK);
// // Allocate buffer with packet data
// bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
// //add data into datastream
// memcpy(stream+streampointer,buffer, bufferlength);
// streampointer += bufferlength;
// Pack message and get size of encoded byte string
mavlink_msg_sys_status_encode(54, componentId, &msg, &status);
// Allocate buffer with packet data
......
......@@ -72,7 +72,7 @@ void MAVLinkSimulationMAV::mainloop()
// 1 Hz execution
if (timer1Hz <= 0) {
mavlink_message_t msg;
mavlink_msg_heartbeat_pack(systemid, MAV_COMP_ID_IMU, &msg, MAV_TYPE_FIXED_WING, MAV_AUTOPILOT_ARDUPILOTMEGA, MAV_MODE_GUIDED_ARMED, 0, MAV_STATE_ACTIVE);
mavlink_msg_heartbeat_pack(systemid, MAV_COMP_ID_IMU, &msg, MAV_TYPE_FIXED_WING, MAV_AUTOPILOT_PIXHAWK, MAV_MODE_GUIDED_ARMED, 0, MAV_STATE_ACTIVE);
link->sendMAVLinkMessage(&msg);
planner.handleMessage(msg);
......
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef FLIGHTMODECONFIGTEST_H
#define FLIGHTMODECONFIGTEST_H
#include "AutoTest.h"
#include "MockUASManager.h"
#include "MockUAS.h"
#include <QLabel>
#include <QComboBox>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
class FlightModeConfig;
/// @file
/// @brief FlightModeConfig unit test
///
/// @author Don Gagne <don@thegagnes.com>
class FlightModeConfigUnitTest : public QObject
{
Q_OBJECT
public:
FlightModeConfigUnitTest(void);
private slots:
void init(void);
void cleanup(void);
void _nullUAS_test(void);
void _validUAS_test(void);
void _nullToValidUAS_test(void);
void _simpleModeFixedWing_test(void);
void _simpleModeRover_test(void);
void _simpleModeRotor_test(void);
void _modeSwitchParam_test(void);
void _pwmFixedWing_test(void);
void _pwmRotor_test(void);
void _pwmRover_test(void);
void _pwmInvalidChannel_test(void);
void _unknownSystemType_test(void);
void _unknownMode_test(void);
private:
void _findControls(QObject* fmc);
void _pwmTestWorker(int systemType, int modeSwitchChannel, const char* modeSwitchParam);
private:
MockUASManager* _mockUASManager;
MockUAS* _mockUAS;
// FlightModeConfig ui elements
static const size_t _cCombo = 6;
QLabel* _rgLabel[_cCombo];
QComboBox* _rgCombo[_cCombo];
QCheckBox* _rgSimpleModeCheckBox[_cCombo];
QLabel* _rgPWMLabel[_cCombo];
QPushButton* _saveButton;
};
DECLARE_TEST(FlightModeConfigUnitTest)
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of class MainWindow
* @author Your Name here
*/
#include "ArduPilotMegaMAV.h"
#ifdef QGC_USE_ARDUPILOTMEGA_MESSAGES
#ifndef MAVLINK_MSG_ID_MOUNT_CONFIGURE
#include "ardupilotmega/mavlink_msg_mount_configure.h"
#endif
#ifndef MAVLINK_MSG_ID_MOUNT_CONTROL
#include "ardupilotmega/mavlink_msg_mount_control.h"
#endif
#endif
ArduPilotMegaMAV::ArduPilotMegaMAV(MAVLinkProtocol* mavlink, QThread* thread, int id) :
UAS(mavlink, thread, id)//,
// place other initializers here
{
//This does not seem to work. Manually request each stream type at a specified rate.
// Ask for all streams at 4 Hz
//enableAllDataTransmission(4);
txReqTimer = new QTimer(this);
connect(txReqTimer,SIGNAL(timeout()),this,SLOT(sendTxRequests()));
QTimer::singleShot(5000,this,SLOT(sendTxRequests())); //Send an initial TX request in 5 seconds.
txReqTimer->start(300000); //Resend the TX requests every 5 minutes.
}
void ArduPilotMegaMAV::sendTxRequests()
{
enableExtendedSystemStatusTransmission(2);
QGC::SLEEP::msleep(250);
enablePositionTransmission(3);
QGC::SLEEP::msleep(250);
enableExtra1Transmission(10);
QGC::SLEEP::msleep(250);
enableExtra2Transmission(10);
QGC::SLEEP::msleep(250);
enableExtra3Transmission(2);
QGC::SLEEP::msleep(250);
enableRawSensorDataTransmission(2);
QGC::SLEEP::msleep(250);
enableRCChannelDataTransmission(2);
}
/**
* This function is called by MAVLink once a complete, uncorrupted (CRC check valid)
* mavlink packet is received.
*
* @param link Hardware link the message came from (e.g. /dev/ttyUSB0 or UDP port).
* messages can be sent back to the system via this link
* @param message MAVLink message, as received from the MAVLink protocol stack
*/
void ArduPilotMegaMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
{
// Let UAS handle the default message set
UAS::receiveMessage(link, message);
if (message.sysid == uasId) {
// Handle your special messages
switch (message.msgid) {
case MAVLINK_MSG_ID_HEARTBEAT:
{
//qDebug() << "ARDUPILOT RECEIVED HEARTBEAT";
break;
}
default:
//qDebug() << "\nARDUPILOT RECEIVED MESSAGE WITH ID" << message.msgid;
break;
}
}
}
void ArduPilotMegaMAV::setMountConfigure(unsigned char mode, bool stabilize_roll,bool stabilize_pitch,bool stabilize_yaw)
{
#ifdef QGC_USE_ARDUPILOTMEGA_MESSAGES
//Only supported by APM
mavlink_message_t msg;
mavlink_msg_mount_configure_pack(255,1,&msg,this->uasId,1,mode,stabilize_roll,stabilize_pitch,stabilize_yaw);
sendMessage(msg);
#else
Q_UNUSED(mode);
Q_UNUSED(stabilize_roll);
Q_UNUSED(stabilize_pitch);
Q_UNUSED(stabilize_yaw);
#endif
}
void ArduPilotMegaMAV::setMountControl(double pa,double pb,double pc,bool islatlong)
{
#ifdef QGC_USE_ARDUPILOTMEGA_MESSAGES
mavlink_message_t msg;
if (islatlong)
{
mavlink_msg_mount_control_pack(255,1,&msg,this->uasId,1,pa*10000000.0,pb*10000000.0,pc*10000000.0,0);
}
else
{
mavlink_msg_mount_control_pack(255,1,&msg,this->uasId,1,pa,pb,pc,0);
}
sendMessage(msg);
#else
Q_UNUSED(pa);
Q_UNUSED(pb);
Q_UNUSED(pc);
Q_UNUSED(islatlong);
#endif
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef ARDUPILOTMEGAMAV_H
#define ARDUPILOTMEGAMAV_H
#include "UAS.h"
class ArduPilotMegaMAV : public UAS
{
Q_OBJECT
public:
ArduPilotMegaMAV(MAVLinkProtocol* mavlink, QThread* thread, int id = 0);
/** @brief Set camera mount stabilization modes */
void setMountConfigure(unsigned char mode, bool stabilize_roll,bool stabilize_pitch,bool stabilize_yaw);
/** @brief Set camera mount control */
void setMountControl(double pa,double pb,double pc,bool islatlong);
public slots:
/** @brief Receive a MAVLink message from this MAV */
void receiveMessage(LinkInterface* link, mavlink_message_t message);
void sendTxRequests();
private:
QTimer *txReqTimer;
};
#endif // ARDUPILOTMAV_H
......@@ -67,21 +67,6 @@ UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInte
uas = px4;
}
break;
// XXX the APM support needs polishing before it can be shown to users
// case MAV_AUTOPILOT_ARDUPILOTMEGA:
// {
// ArduPilotMegaMAV* mav = new ArduPilotMegaMAV(mavlink, worker, sysid);
// // Set the system type
// mav->setSystemType((int)heartbeat->type);
// // Connect this robot to the UAS object
// // it is IMPORTANT here to use the right object type,
// // else the slot of the parent object is called (and thus the special
// // packets never reach their goal)
// connect(mavlink, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), mav, SLOT(receiveMessage(LinkInterface*, mavlink_message_t)));
// uas = mav;
// }
// break;
#ifdef QGC_USE_SENSESOAR_MESSAGES
case MAV_AUTOPILOT_SENSESOAR:
{
......
......@@ -12,7 +12,6 @@
#include "UAS.h"
#include "PxQuadMAV.h"
#include "senseSoarMAV.h"
#include "ArduPilotMegaMAV.h"
class QGCMAVLinkUASFactory : public QObject
{
......
......@@ -64,9 +64,6 @@ This file is part of the QGROUNDCONTROL project
#include "QGCTabbedInfoView.h"
#include "UASRawStatusView.h"
#include "PrimaryFlightDisplay.h"
#include <apmtoolbar.h>
#include <ApmHardwareConfig.h>
#include <ApmSoftwareConfig.h>
#include <QGCConfigView.h>
#include "SerialSettingsDialog.h"
#include "terminalconsole.h"
......@@ -205,31 +202,27 @@ void MainWindow::init()
// Load Toolbar
if (!(getCustomMode() == CUSTOM_MODE_APM)) {
toolBar = new QGCToolBar(this);
this->addToolBar(toolBar);
// Add actions for average users (displayed next to each other)
QList<QAction*> actions;
actions << ui.actionMissionView;
actions << ui.actionFlightView;
actions << ui.actionHardwareConfig;
toolBar->setPerspectiveChangeActions(actions);
// Add actions for advanced users (displayed in dropdown under "advanced")
QList<QAction*> advancedActions;
advancedActions << ui.actionEngineersView;
advancedActions << ui.actionGoogleEarthView;
advancedActions << ui.actionLocal3DView;
advancedActions << ui.actionSoftwareConfig;
advancedActions << ui.actionTerminalView;
advancedActions << ui.actionSimulationView;
toolBar->setPerspectiveChangeAdvancedActions(advancedActions);
} else {
ui.actionHardwareConfig->setText(tr("Hardware"));
}
toolBar = new QGCToolBar(this);
this->addToolBar(toolBar);
// Add actions for average users (displayed next to each other)
QList<QAction*> actions;
actions << ui.actionMissionView;
actions << ui.actionFlightView;
actions << ui.actionHardwareConfig;
toolBar->setPerspectiveChangeActions(actions);
// Add actions for advanced users (displayed in dropdown under "advanced")
QList<QAction*> advancedActions;
advancedActions << ui.actionEngineersView;
advancedActions << ui.actionGoogleEarthView;
advancedActions << ui.actionLocal3DView;
advancedActions << ui.actionSoftwareConfig;
advancedActions << ui.actionTerminalView;
advancedActions << ui.actionSimulationView;
toolBar->setPerspectiveChangeAdvancedActions(advancedActions);
customStatusBar = new QGCStatusBar(this);
setStatusBar(customStatusBar);
......@@ -255,28 +248,6 @@ void MainWindow::init()
connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addLink(LinkInterface*)));
if (getCustomMode() == CUSTOM_MODE_APM) {
// Add the APM 'toolbar'
APMToolBar *apmToolBar = new APMToolBar();
apmToolBar->setFlightViewAction(ui.actionFlightView);
apmToolBar->setFlightPlanViewAction(ui.actionMissionView);
apmToolBar->setHardwareViewAction(ui.actionHardwareConfig);
apmToolBar->setSoftwareViewAction(ui.actionSoftwareConfig);
apmToolBar->setSimulationViewAction(ui.actionSimulationView);
apmToolBar->setTerminalViewAction(ui.actionTerminalView);
QDockWidget *widget = new QDockWidget(tr("APM Tool Bar"),this);
QWidget *toolbarWidget = QWidget::createWindowContainer(apmToolBar, this);
widget->setWidget(toolbarWidget);
widget->setMinimumHeight(72);
widget->setMaximumHeight(72);
widget->setMinimumWidth(1024);
widget->setFeatures(QDockWidget::NoDockWidgetFeatures);
widget->setTitleBarWidget(new QWidget(this)); // Disables the title bar
this->addDockWidget(Qt::TopDockWidgetArea, widget);
}
// Connect user interface devices
emit initStatusChanged(tr("Initializing joystick interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
joystick = new JoystickInput();
......@@ -559,31 +530,12 @@ void MainWindow::buildCommonWidgets()
addToCentralStackedWidget(terminalView, VIEW_TERMINAL, tr("Terminal View"));
}
if (getCustomMode() == CUSTOM_MODE_APM) {
if (!configView)
{
configView = new SubMainWindow(this);
configView->setObjectName("VIEW_HARDWARE_CONFIG");
configView->setCentralWidget(new ApmHardwareConfig(this));
addToCentralStackedWidget(configView, VIEW_HARDWARE_CONFIG, "Hardware");
}
if (!softwareConfigView)
{
softwareConfigView = new SubMainWindow(this);
softwareConfigView->setObjectName("VIEW_SOFTWARE_CONFIG");
softwareConfigView->setCentralWidget(new ApmSoftwareConfig(this));
addToCentralStackedWidget(softwareConfigView, VIEW_SOFTWARE_CONFIG, "Software");
}
} else {
if (!configView)
{
configView = new SubMainWindow(this);
configView->setObjectName("VIEW_HARDWARE_CONFIG");
configView->setCentralWidget(new QGCConfigView(this));
addToCentralStackedWidget(configView, VIEW_HARDWARE_CONFIG, "Config");
}
if (!configView)
{
configView = new SubMainWindow(this);
configView->setObjectName("VIEW_HARDWARE_CONFIG");
configView->setCentralWidget(new QGCConfigView(this));
addToCentralStackedWidget(configView, VIEW_HARDWARE_CONFIG, "Config");
}
if (!engineeringView)
......@@ -1209,14 +1161,12 @@ void MainWindow::connectCommonActions()
perspectives->addAction(ui.actionSimulationView);
perspectives->addAction(ui.actionMissionView);
perspectives->addAction(ui.actionHardwareConfig);
perspectives->addAction(ui.actionSoftwareConfig);
perspectives->addAction(ui.actionTerminalView);
perspectives->addAction(ui.actionGoogleEarthView);
perspectives->addAction(ui.actionLocal3DView);
perspectives->setExclusive(true);
/* Hide the actions that are not relevant */
ui.actionSoftwareConfig->setVisible(getCustomMode() == CUSTOM_MODE_APM);
#ifndef QGC_GOOGLE_EARTH_ENABLED
ui.actionGoogleEarthView->setVisible(false);
#endif
......@@ -1617,7 +1567,7 @@ void MainWindow::UASCreated(UASInterface* uas)
watchdogControlDockWidget->setObjectName("WATCHDOG_CONTROL_DOCKWIDGET");
}
}
// Reload view state in case new widgets were added
loadViewState();
}
......
......@@ -98,7 +98,6 @@ public:
CUSTOM_MODE_UNCHANGED = 0,
CUSTOM_MODE_NONE,
CUSTOM_MODE_PX4,
CUSTOM_MODE_APM,
CUSTOM_MODE_WIFI
};
......
......@@ -51,7 +51,7 @@
<x>0</x>
<y>0</y>
<width>1024</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuMGround">
......@@ -100,7 +100,6 @@
<addaction name="actionEngineersView"/>
<addaction name="actionGoogleEarthView"/>
<addaction name="actionLocal3DView"/>
<addaction name="actionSoftwareConfig"/>
<addaction name="actionTerminalView"/>
<addaction name="actionSimulationView"/>
<addaction name="actionFirmwareUpdateView"/>
......
#include <QDebug>
#include <QQmlContext>
#include <QGraphicsObject>
#include <QQuickItem>
#include "LinkManager.h"
#include "MainWindow.h"
#include "apmtoolbar.h"
APMToolBar::APMToolBar():
QQuickView(), m_uas(0)
{
// Configure our QML object
// Hack to fix QTBUG 34300 on OSX where QDir::currentPath has changed behavior. This causes
// relative paths to inside the .app package to fail.
#ifdef Q_OS_MAC
QString qmlFile = QApplication::applicationDirPath();
qmlFile.append("/qml/ApmToolBar.qml");
setSource(QUrl::fromLocalFile(qmlFile));
#else
setSource(QUrl::fromLocalFile("qml/ApmToolBar.qml"));
#endif
setResizeMode(QQuickView::SizeRootObjectToView);
rootContext()->setContextProperty("globalObj", this);
connect(LinkManager::instance(),SIGNAL(newLink(LinkInterface*)),
this, SLOT(updateLinkDisplay(LinkInterface*)));
if (LinkManager::instance()->getLinks().count()>=3) {
updateLinkDisplay(LinkManager::instance()->getLinks().last());
}
setConnection(false);
connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUasSet(UASInterface*)));
activeUasSet(UASManager::instance()->getActiveUAS());
}
void APMToolBar::activeUasSet(UASInterface *uas)
{
if (!uas)
{
return;
}
if (m_uas)
{
disconnect(m_uas,SIGNAL(armingChanged(bool)),
this,SLOT(armingChanged(bool)));
disconnect(uas,SIGNAL(armingChanged(int, QString)),
this,SLOT(armingChanged(int, QString)));
}
connect(uas,SIGNAL(armingChanged(bool)),
this,SLOT(armingChanged(bool)));
connect(uas,SIGNAL(armingChanged(int, QString)),
this,SLOT(armingChanged(int, QString)));
}
void APMToolBar::armingChanged(bool armed)
{
rootObject()->setProperty("armed", armed);
}
void APMToolBar::armingChanged(int sysId, QString armingState)
{
qDebug() << "APMToolBar: sysid " << sysId << " armState" << armingState;
}
void APMToolBar::setFlightViewAction(QAction *action)
{
connect(this, SIGNAL(triggerFlightView()), action, SIGNAL(triggered()));
}
void APMToolBar::setFlightPlanViewAction(QAction *action)
{
connect(this, SIGNAL(triggerFlightPlanView()), action, SIGNAL(triggered()));
}
void APMToolBar::setHardwareViewAction(QAction *action)
{
connect(this, SIGNAL(triggerHardwareView()), action, SIGNAL(triggered()));
}
void APMToolBar::setSoftwareViewAction(QAction *action)
{
connect(this, SIGNAL(triggerSoftwareView()), action, SIGNAL(triggered()));
}
void APMToolBar::setSimulationViewAction(QAction *action)
{
connect(this, SIGNAL(triggerSimulationView()), action, SIGNAL(triggered()));
}
void APMToolBar::setTerminalViewAction(QAction *action)
{
connect(this, SIGNAL(triggerTerminalView()), action, SIGNAL(triggered()));
}
void APMToolBar::setConnectMAVAction(QAction *action)
{
connect(this, SIGNAL(connectMAV()), action, SIGNAL(triggered()));
}
void APMToolBar::selectFlightView()
{
qDebug() << "APMToolBar: SelectFlightView";
emit triggerFlightView();
}
void APMToolBar::selectFlightPlanView()
{
qDebug() << "APMToolBar: SelectFlightPlanView";
emit triggerFlightPlanView();
}
void APMToolBar::selectHardwareView()
{
qDebug() << "APMToolBar: selectHardwareView";
emit triggerHardwareView();
}
void APMToolBar::selectSoftwareView()
{
qDebug() << "APMToolBar: selectSoftwareView";
emit triggerSoftwareView();
}
void APMToolBar::selectSimulationView()
{
qDebug() << "APMToolBar: selectSimulationView";
}
void APMToolBar::selectTerminalView()
{
qDebug() << "APMToolBar: selectTerminalView";
}
void APMToolBar::connectMAV()
{
qDebug() << "APMToolBar: connectMAV ";
if (LinkManager::instance()->getSerialLinks().count() > 0) {
bool result;
bool connected = LinkManager::instance()->getSerialLinks().last()->isConnected();
if (connected) {
// result need to be the opposite of success.
result = !LinkManager::instance()->getSerialLinks().last()->disconnect();
} else {
// Need to Connect Link
result = LinkManager::instance()->getSerialLinks().last()->connect();
}
qDebug() << "result = " << result;
// Change the image to represent the state
setConnection(result);
emit MAVConnected(result);
} else {
// No Link so prompt to connect one
MainWindow::instance()->addLink();
}
}
void APMToolBar::setConnection(bool connection)
{
// Change the image to represent the state
rootObject()->setProperty("connected", connection);
}
APMToolBar::~APMToolBar()
{
qDebug() << "Destory APM Toolbar";
}
void APMToolBar::showConnectionDialog()
{
// Displays a UI where the user can select a MAV Link.
qDebug() << "APMToolBar: showConnectionDialog link count ="
<< LinkManager::instance()->getLinks().count();
bool result;
if (LinkManager::instance()->getSerialLinks().count() > 0)
{
SerialLink *link = LinkManager::instance()->getSerialLinks().last();
// Serial Link so prompt to config it
connect(link, SIGNAL(updateLink(LinkInterface*)),
this, SLOT(updateLinkDisplay(LinkInterface*)));
result = MainWindow::instance()->configLink(link);
if (!result)
qDebug() << "Link Config Failed!";
} else {
// No Link so prompt to create one
MainWindow::instance()->addLink();
}
}
void APMToolBar::updateLinkDisplay(LinkInterface* newLink)
{
qDebug() << "APMToolBar: updateLinkDisplay";
QObject *object = rootObject();
if (newLink && rootObject()){
qint64 baudrate = newLink->getConnectionSpeed();
object->setProperty("baudrateLabel", QString::number(baudrate));
QString linkName = newLink->getName();
object->setProperty("linkNameLabel", linkName);
connect(newLink, SIGNAL(connected(bool)),
this, SLOT(setConnection(bool)));
setConnection(newLink->isConnected());
}
}
#ifndef APMTOOLBAR_H
#define APMTOOLBAR_H
#include <QAction>
#include <QQuickView>
#include "UASInterface.h"
class LinkInterface;
class APMToolBar : public QQuickView
{
Q_OBJECT
public:
explicit APMToolBar();
~APMToolBar();
void setFlightViewAction(QAction *action);
void setFlightPlanViewAction(QAction *action);
void setHardwareViewAction(QAction *action);
void setSoftwareViewAction(QAction *action);
void setSimulationViewAction(QAction *action);
void setTerminalViewAction(QAction *action);
void setConnectMAVAction(QAction *action);
signals:
void triggerFlightView();
void triggerFlightPlanView();
void triggerHardwareView();
void triggerSoftwareView();
void triggerSimulationView();
void triggerTerminalView();
void MAVConnected(bool connected);
public slots:
void selectFlightView();
void selectFlightPlanView();
void selectHardwareView();
void selectSoftwareView();
void selectSimulationView();
void selectTerminalView();
void connectMAV();
void showConnectionDialog();
void setConnection(bool connection);
void activeUasSet(UASInterface *uas);
void armingChanged(int sysId, QString armingState);
void armingChanged(bool armed);
void updateLinkDisplay(LinkInterface *newLink);
private:
UASInterface *m_uas;
};
#endif // APMTOOLBAR_H
#include <QMessageBox>
#include "AP2ConfigWidget.h"
AP2ConfigWidget::AP2ConfigWidget(QWidget *parent) : QWidget(parent)
{
m_uas = 0;
}
void AP2ConfigWidget::initConnections()
{
connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUASSet(UASInterface*)));
activeUASSet(UASManager::instance()->getActiveUAS());
}
void AP2ConfigWidget::activeUASSet(UASInterface *uas)
{
if (m_uas)
{
disconnect(m_uas,SIGNAL(parameterChanged(int,int,QString,QVariant)),this,SLOT(parameterChanged(int,int,QString,QVariant)));
m_uas = 0;
}
if (!uas) return;
m_uas = uas;
connect(m_uas,SIGNAL(parameterChanged(int,int,QString,QVariant)),this,SLOT(parameterChanged(int,int,QString,QVariant)));
}
void AP2ConfigWidget::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
Q_UNUSED(uas);
Q_UNUSED(component);
Q_UNUSED(parameterName);
Q_UNUSED(value);
}
void AP2ConfigWidget::showNullMAVErrorMessageBox()
{
QMessageBox::information(0,tr("Error"),tr("Please connect to a MAV before attempting to set configuration"));
}
#ifndef AP2CONFIGWIDGET_H
#define AP2CONFIGWIDGET_H
#include <QWidget>
#include "UASManager.h"
#include "UASInterface.h"
class AP2ConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit AP2ConfigWidget(QWidget *parent = 0);
protected:
UASInterface *m_uas;
void showNullMAVErrorMessageBox();
void initConnections();
signals:
public slots:
virtual void activeUASSet(UASInterface *uas);
virtual void parameterChanged(int uas, int component, QString parameterName, QVariant value);
};
#endif // AP2CONFIGWIDGET_H
#include "AccelCalibrationConfig.h"
AccelCalibrationConfig::AccelCalibrationConfig(QWidget *parent) : AP2ConfigWidget(parent)
{
ui.setupUi(this);
connect(ui.calibrateAccelButton,SIGNAL(clicked()),this,SLOT(calibrateButtonClicked()));
m_accelAckCount=0;
initConnections();
}
AccelCalibrationConfig::~AccelCalibrationConfig()
{
}
void AccelCalibrationConfig::activeUASSet(UASInterface *uas)
{
if (m_uas)
{
disconnect(m_uas,SIGNAL(textMessageReceived(int,int,int,QString)),this,SLOT(uasTextMessageReceived(int,int,int,QString)));
}
AP2ConfigWidget::activeUASSet(uas);
if (!uas)
{
return;
}
connect(m_uas,SIGNAL(textMessageReceived(int,int,int,QString)),this,SLOT(uasTextMessageReceived(int,int,int,QString)));
}
void AccelCalibrationConfig::calibrateButtonClicked()
{
if (!m_uas)
{
showNullMAVErrorMessageBox();
return;
}
if (m_accelAckCount == 0)
{
MAV_CMD command = MAV_CMD_PREFLIGHT_CALIBRATION;
int confirm = 0;
float param1 = 0.0;
float param2 = 0.0;
float param3 = 0.0;
float param4 = 0.0;
float param5 = 1.0;
float param6 = 0.0;
float param7 = 0.0;
int component = 1;
m_uas->executeCommand(command, confirm, param1, param2, param3, param4, param5, param6, param7, component);
}
else if (m_accelAckCount <= 5)
{
m_uas->executeCommandAck(m_accelAckCount++,true);
}
else
{
m_uas->executeCommandAck(m_accelAckCount++,true);
ui.calibrateAccelButton->setText("Calibrate\nAccelerometer");
if (m_accelAckCount > 8)
{
//We've clicked too many times! Reset.
for (int i=0;i<8;i++)
{
m_uas->executeCommandAck(i,true);
}
m_accelAckCount = 0;
}
}
}
void AccelCalibrationConfig::hideEvent(QHideEvent *evt)
{
Q_UNUSED(evt);
if (!m_uas || !m_accelAckCount)
{
return;
}
for (int i=m_accelAckCount;i<8;i++)
{
m_uas->executeCommandAck(i,true); //Clear out extra commands.
}
}
void AccelCalibrationConfig::uasTextMessageReceived(int uasid, int componentid, int severity, QString text)
{
Q_UNUSED(uasid);
Q_UNUSED(componentid);
//command received: " Severity 1
//Place APM Level and press any key" severity 5
if (severity == 5)
{
//This is a calibration instruction
if (m_accelAckCount == 0)
{
//Calibration Sucessful\r"
ui.calibrateAccelButton->setText("Continue");
m_accelAckCount++;
}
if (m_accelAckCount == 7)
{
//All finished
//ui.outputLabel->setText(ui.outputLabel->text() + "\n" + text);
ui.outputLabel->setText(text);
m_accelAckCount++;
}
if (m_accelAckCount == 8)
{
if (text.contains("Calibration") && text.contains("successful"))
{
m_accelAckCount = 0;
}
else if (text.contains("Calibration") && text.contains("FAILED")) //Failure
{
m_accelAckCount = 0;
}
ui.outputLabel->setText(ui.outputLabel->text() + "\n" + text);
}
else
{
ui.outputLabel->setText(text.replace("press any key","click Continue below"));
if (!this->isVisible())
{
//Clear out!
m_uas->executeCommandAck(m_accelAckCount++,true);
ui.calibrateAccelButton->setText("Calibrate\nAccelerometer");
}
}
}
}
#ifndef ACCELCALIBRATIONCONFIG_H
#define ACCELCALIBRATIONCONFIG_H
#include <QWidget>
#include "ui_AccelCalibrationConfig.h"
#include "UASManager.h"
#include "UASInterface.h"
#include "AP2ConfigWidget.h"
class AccelCalibrationConfig : public AP2ConfigWidget
{
Q_OBJECT
public:
explicit AccelCalibrationConfig(QWidget *parent = 0);
~AccelCalibrationConfig();
protected:
void hideEvent(QHideEvent *evt);
private slots:
void activeUASSet(UASInterface *uas);
void calibrateButtonClicked();
void uasTextMessageReceived(int uasid, int componentid, int severity, QString text);
private:
int m_accelAckCount;
Ui::AccelCalibrationConfig ui;
};
#endif // ACCELCALIBRATIONCONFIG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AccelCalibrationConfig</class>
<widget class="QWidget" name="AccelCalibrationConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>576</width>
<height>354</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>231</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>&lt;h2&gt;Accelerometer Calibration&lt;/h2&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="calibrateAccelButton">
<property name="geometry">
<rect>
<x>70</x>
<y>160</y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Calibrate
Accelerometer</string>
</property>
</widget>
<widget class="QLabel" name="outputLabel">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>311</width>
<height>101</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
#include "AdvParameterList.h"
AdvParameterList::AdvParameterList(QWidget *parent) : AP2ConfigWidget(parent)
{
ui.setupUi(this);
ui.tableWidget->setColumnCount(4);
ui.tableWidget->horizontalHeader()->hide();
ui.tableWidget->verticalHeader()->hide();
ui.tableWidget->setColumnWidth(0,200);
ui.tableWidget->setColumnWidth(1,100);
ui.tableWidget->setColumnWidth(2,200);
ui.tableWidget->setColumnWidth(3,800);
initConnections();
}
AdvParameterList::~AdvParameterList()
{
}
void AdvParameterList::setParameterMetaData(QString name,QString humanname,QString description)
{
m_paramToNameMap[name] = humanname;
m_paramToDescriptionMap[name] = description;
}
void AdvParameterList::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
Q_UNUSED(uas);
Q_UNUSED(component);
if (!m_paramValueMap.contains(parameterName))
{
ui.tableWidget->setRowCount(ui.tableWidget->rowCount()+1);
if (m_paramToNameMap.contains(parameterName))
{
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem(m_paramToNameMap[parameterName]));
}
else
{
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem("Unknown"));
}
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,1,new QTableWidgetItem(QString::number(value.toFloat(),'f',2)));
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,2,new QTableWidgetItem(parameterName));
if (m_paramToDescriptionMap.contains(parameterName))
{
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem(m_paramToDescriptionMap[parameterName]));
}
else
{
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem("Unknown"));
}
m_paramValueMap[parameterName] = ui.tableWidget->item(ui.tableWidget->rowCount()-1,1);
}
m_paramValueMap[parameterName]->setText(QString::number(value.toFloat(),'f',2));
}
#ifndef ADVPARAMETERLIST_H
#define ADVPARAMETERLIST_H
#include <QWidget>
#include "ui_AdvParameterList.h"
#include "AP2ConfigWidget.h"
class AdvParameterList : public AP2ConfigWidget
{
Q_OBJECT
public:
explicit AdvParameterList(QWidget *parent = 0);
void setParameterMetaData(QString name,QString humanname,QString description);
~AdvParameterList();
private slots:
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
private:
QMap<QString,QTableWidgetItem*> m_paramValueMap;
QMap<QString,QString> m_paramToNameMap;
QMap<QString,QString> m_paramToDescriptionMap;
Ui::AdvParameterList ui;
};
#endif // ADVPARAMETERLIST_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AdvParameterList</class>
<widget class="QWidget" name="AdvParameterList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>666</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;h2&gt;Full Parameter List&lt;/h2&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "AdvancedParamConfig.h"
AdvancedParamConfig::AdvancedParamConfig(QWidget *parent) : AP2ConfigWidget(parent)
{
ui.setupUi(this);
initConnections();
}
AdvancedParamConfig::~AdvancedParamConfig()
{
}
void AdvancedParamConfig::addRange(QString title,QString description,QString param,double min,double max)
{
ParamWidget *widget = new ParamWidget(param,ui.scrollAreaWidgetContents);
connect(widget,SIGNAL(doubleValueChanged(QString,double)),this,SLOT(doubleValueChanged(QString,double)));
connect(widget,SIGNAL(intValueChanged(QString,int)),this,SLOT(intValueChanged(QString,int)));
m_paramToWidgetMap[param] = widget;
widget->setupDouble(title + "(" + param + ")",description,0,min,max);
ui.verticalLayout->addWidget(widget);
widget->show();
}
void AdvancedParamConfig::addCombo(QString title,QString description,QString param,QList<QPair<int,QString> > valuelist)
{
ParamWidget *widget = new ParamWidget(param,ui.scrollAreaWidgetContents);
connect(widget,SIGNAL(doubleValueChanged(QString,double)),this,SLOT(doubleValueChanged(QString,double)));
connect(widget,SIGNAL(intValueChanged(QString,int)),this,SLOT(intValueChanged(QString,int)));
m_paramToWidgetMap[param] = widget;
widget->setupCombo(title + "(" + param + ")",description,valuelist);
ui.verticalLayout->addWidget(widget);
widget->show();
}
void AdvancedParamConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
Q_UNUSED(uas);
Q_UNUSED(component);
if (m_paramToWidgetMap.contains(parameterName))
{
if (value.type() == QVariant::Double)
{
m_paramToWidgetMap[parameterName]->setValue(value.toDouble());
}
else
{
m_paramToWidgetMap[parameterName]->setValue(value.toInt());
}
}
}
void AdvancedParamConfig::doubleValueChanged(QString param,double value)
{
if (!m_uas)
{
this->showNullMAVErrorMessageBox();
}
m_uas->getParamManager()->setParameter(1,param,value);
}
void AdvancedParamConfig::intValueChanged(QString param,int value)
{
if (!m_uas)
{
this->showNullMAVErrorMessageBox();
}
m_uas->getParamManager()->setParameter(1,param,value);
}
#ifndef ADVANCEDPARAMCONFIG_H
#define ADVANCEDPARAMCONFIG_H
#include <QWidget>
#include "ui_AdvancedParamConfig.h"
#include "AP2ConfigWidget.h"
#include "ParamWidget.h"
class AdvancedParamConfig : public AP2ConfigWidget
{
Q_OBJECT
public:
explicit AdvancedParamConfig(QWidget *parent = 0);
~AdvancedParamConfig();
void addRange(QString title,QString description,QString param,double min,double max);
void addCombo(QString title,QString description,QString param,QList<QPair<int,QString> > valuelist);
private slots:
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
void doubleValueChanged(QString param,double value);
void intValueChanged(QString param,int value);
private:
QMap<QString,ParamWidget*> m_paramToWidgetMap;
Ui::AdvancedParamConfig ui;
};
#endif // ADVANCEDPARAMCONFIG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AdvancedParamConfig</class>
<widget class="QWidget" name="AdvancedParamConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>725</width>
<height>632</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;h2&gt;Advanced Params&lt;/h2&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>705</width>
<height>585</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "AirspeedConfig.h"
#include <QMessageBox>
AirspeedConfig::AirspeedConfig(QWidget *parent) : AP2ConfigWidget(parent)
{
ui.setupUi(this);
connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(enableCheckBoxClicked(bool)));
connect(ui.useAirspeedCheckBox,SIGNAL(toggled(bool)),this,SLOT(useCheckBoxClicked(bool)));
initConnections();
}
AirspeedConfig::~AirspeedConfig()
{
}
void AirspeedConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
Q_UNUSED(uas);
Q_UNUSED(component);
if (parameterName == "ARSPD_ENABLE")
{
if (value.toInt() == 0)
{
disconnect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(enableCheckBoxClicked(bool)));
ui.enableCheckBox->setChecked(false);
connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(enableCheckBoxClicked(bool)));
ui.useAirspeedCheckBox->setEnabled(false);
}
else
{
disconnect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(enableCheckBoxClicked(bool)));
ui.enableCheckBox->setChecked(true);
connect(ui.enableCheckBox,SIGNAL(toggled(bool)),this,SLOT(enableCheckBoxClicked(bool)));
ui.useAirspeedCheckBox->setEnabled(true);
}
}
else if (parameterName == "ARSPD_USE")
{
if (value.toInt() == 0)
{
disconnect(ui.useAirspeedCheckBox,SIGNAL(toggled(bool)),this,SLOT(useCheckBoxClicked(bool)));
ui.useAirspeedCheckBox->setChecked(false);
connect(ui.useAirspeedCheckBox,SIGNAL(toggled(bool)),this,SLOT(useCheckBoxClicked(bool)));
}
else
{
disconnect(ui.useAirspeedCheckBox,SIGNAL(toggled(bool)),this,SLOT(useCheckBoxClicked(bool)));
ui.useAirspeedCheckBox->setChecked(true);
connect(ui.useAirspeedCheckBox,SIGNAL(toggled(bool)),this,SLOT(useCheckBoxClicked(bool)));
}
}
}
void AirspeedConfig::useCheckBoxClicked(bool checked)
{
if (!m_uas)
{
showNullMAVErrorMessageBox();
return;
}
if (checked)
{
m_uas->getParamManager()->setParameter(1,"ARSPD_USE",1);
}
else
{
m_uas->getParamManager()->setParameter(1,"ARSPD_USE",0);
}
}
void AirspeedConfig::enableCheckBoxClicked(bool checked)
{
if (!m_uas)
{
showNullMAVErrorMessageBox();
return;
}
if (checked)
{
m_uas->getParamManager()->setParameter(1,"ARSPD_ENABLE",1);
}
else
{
m_uas->getParamManager()->setParameter(1,"ARSPD_ENABLE",0);
}
}
#ifndef AIRSPEEDCONFIG_H
#define AIRSPEEDCONFIG_H
#include <QWidget>
#include "AP2ConfigWidget.h"
#include "ui_AirspeedConfig.h"
class AirspeedConfig : public AP2ConfigWidget
{
Q_OBJECT
public:
explicit AirspeedConfig(QWidget *parent = 0);
~AirspeedConfig();
private slots:
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
void useCheckBoxClicked(bool checked);
void enableCheckBoxClicked(bool checked);
private:
Ui::AirspeedConfig ui;
};
#endif // AIRSPEEDCONFIG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AirspeedConfig</class>
<widget class="QWidget" name="AirspeedConfig">
<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="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>131</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>&lt;h2&gt;Airspeed&lt;/h2&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>71</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../qgroundcontrol.qrc">:/files/images/devices/BR-0004-03-2.jpg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="enableCheckBox">
<property name="geometry">
<rect>
<x>110</x>
<y>70</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Enable</string>
</property>
</widget>
<widget class="QCheckBox" name="useAirspeedCheckBox">
<property name="geometry">
<rect>
<x>110</x>
<y>100</y>
<width>91</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Use Airspeed</string>
</property>
</widget>
</widget>
<resources>
<include location="../../../qgroundcontrol.qrc"/>
</resources>
<connections/>
</ui>
#include "AntennaTrackerConfig.h"
AntennaTrackerConfig::AntennaTrackerConfig(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
}
AntennaTrackerConfig::~AntennaTrackerConfig()
{
}
#ifndef ANTENNATRACKERCONFIG_H
#define ANTENNATRACKERCONFIG_H
#include <QWidget>
#include "ui_AntennaTrackerConfig.h"
class AntennaTrackerConfig : public QWidget
{
Q_OBJECT
public:
explicit AntennaTrackerConfig(QWidget *parent = 0);
~AntennaTrackerConfig();
private:
Ui::AntennaTrackerConfig ui;
};
#endif // ANTENNATRACKERCONFIG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AntennaTrackerConfig</class>
<widget class="QWidget" name="AntennaTrackerConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1171</width>
<height>560</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>151</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>&lt;h2&gt;Antenna Tracker&lt;/h2&gt;</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>46</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>Interface</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>80</x>
<y>50</y>
<width>69</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="comboBox_2">
<property name="geometry">
<rect>
<x>160</x>
<y>50</y>
<width>69</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="comboBox_3">
<property name="geometry">
<rect>
<x>240</x>
<y>50</y>
<width>69</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="connectPushButton">
<property name="geometry">
<rect>
<x>320</x>
<y>50</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>20</x>
<y>80</y>
<width>581</width>
<height>131</height>
</rect>
</property>
<property name="title">
<string>Pan</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,2,5,0">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Angle</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>PWM</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Center PWM</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="panAngleLineEdit"/>
</item>
<item>
<widget class="QLineEdit" name="panPwmLineEdit"/>
</item>
<item>
<widget class="QLineEdit" name="pwnCenterLineEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Trim</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider">
<property name="minimum">
<number>-180</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="panTrimLabel">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="panRevCheckBox">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>581</width>
<height>131</height>
</rect>
</property>
<property name="title">
<string>Tilt</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,2,5,0">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Angle</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>PWM</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Center PWM</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLineEdit" name="tiltAngleLineEdit"/>
</item>
<item>
<widget class="QLineEdit" name="tiltPwmLineEdit"/>
</item>
<item>
<widget class="QLineEdit" name="tiltCenterLineEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Trim</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider_2">
<property name="minimum">
<number>-180</number>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="tiltTrimLabel">
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="tiltRevCheckBox">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
#ifndef APMFIRMWARECONFIG_H
#define APMFIRMWARECONFIG_H
#include <QWidget>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>
#include <QTemporaryFile>
#include <QProcess>
#include <QXmlStreamReader>
#include <QMessageBox>
#include <QProcess>
#include <QScrollBar>
#include <QSerialPort>
#include "ui_ApmFirmwareConfig.h"
class ApmFirmwareConfig : public QWidget
{
Q_OBJECT
public:
explicit ApmFirmwareConfig(QWidget *parent = 0);
~ApmFirmwareConfig();
private slots:
void firmwareListFinished();
void firmwareListError(QNetworkReply::NetworkError error);
void flashButtonClicked();
void betaFirmwareButtonClicked(bool betafirmwareenabled);
void downloadFinished();
void firmwareProcessFinished(int status);
void firmwareProcessReadyRead();
void firmwareProcessError(QProcess::ProcessError error);
void firmwareDownloadProgress(qint64 received,qint64 total);
void requestFirmwares();
void requestBetaFirmwares();
private:
void addBetaLabel(QWidget *parent);
void hideBetaLabels();
void showBetaLabels();
//ApmFirmwareStatus *firmwareStatus;
QString m_detectedComPort;
QTemporaryFile *m_tempFirmwareFile;
QNetworkAccessManager *m_networkManager;
QList<QLabel*> m_betaButtonLabelList;
bool stripVersionFromGitReply(QString url,QString reply,QString type,QString stable,QString *out);
bool m_betaFirmwareChecked;
QMap<QPushButton*,QString> m_buttonToUrlMap;
Ui::ApmFirmwareConfig ui;
class FirmwareDef
{
public:
QString url;
QString url2560;
QString url25602;
QString urlpx4;
QString type;
QString name;
QString desc;
int version;
};
QList<FirmwareDef> m_firmwareList;
};
#endif // APMFIRMWARECONFIG_H
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2013 Michael Carpenter (malcom2073@gmail.com)
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief APM Hardware Configuration widget source.
*
* @author Michael Carpenter <malcom2073@gmail.com>
*
*/
#include "ApmHardwareConfig.h"
ApmHardwareConfig::ApmHardwareConfig(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
ui.manditoryHardware->setVisible(false);
ui.frameTypeButton->setVisible(false);
ui.compassButton->setVisible(false);
ui.accelCalibrateButton->setVisible(false);
ui.arduPlaneLevelButton->setVisible(false);
ui.radioCalibrateButton->setVisible(false);
ui.optionalHardwareButton->setVisible(false);
ui.batteryMonitorButton->setVisible(false);
ui.sonarButton->setVisible(false);
ui.airspeedButton->setVisible(false);
ui.opticalFlowButton->setVisible(false);
ui.osdButton->setVisible(false);
ui.cameraGimbalButton->setVisible(false);
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.radio3DRButton,SLOT(setVisible(bool)));
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.batteryMonitorButton,SLOT(setVisible(bool)));
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.sonarButton,SLOT(setVisible(bool)));
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.opticalFlowButton,SLOT(setVisible(bool)));
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.osdButton,SLOT(setVisible(bool)));
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.cameraGimbalButton,SLOT(setVisible(bool)));
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.antennaTrackerButton,SLOT(setVisible(bool)));
connect(ui.frameTypeButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_apmFirmwareConfig = new ApmFirmwareConfig(this);
ui.stackedWidget->addWidget(m_apmFirmwareConfig); //Firmware placeholder.
m_buttonToConfigWidgetMap[ui.firmwareButton] = m_apmFirmwareConfig;
connect(ui.firmwareButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_frameConfig = new FrameTypeConfig(this);
ui.stackedWidget->addWidget(m_frameConfig);
m_buttonToConfigWidgetMap[ui.frameTypeButton] = m_frameConfig;
connect(ui.frameTypeButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_compassConfig = new CompassConfig(this);
ui.stackedWidget->addWidget(m_compassConfig);
m_buttonToConfigWidgetMap[ui.compassButton] = m_compassConfig;
connect(ui.compassButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_accelConfig = new AccelCalibrationConfig(this);
ui.stackedWidget->addWidget(m_accelConfig);
m_buttonToConfigWidgetMap[ui.accelCalibrateButton] = m_accelConfig;
connect(ui.accelCalibrateButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_planeLevel = new ApmPlaneLevel(this);
ui.stackedWidget->addWidget(m_planeLevel);
m_buttonToConfigWidgetMap[ui.arduPlaneLevelButton] = m_planeLevel;
connect(ui.arduPlaneLevelButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_radioConfig = new RadioCalibrationConfig(this);
ui.stackedWidget->addWidget(m_radioConfig);
m_buttonToConfigWidgetMap[ui.radioCalibrateButton] = m_radioConfig;
connect(ui.radioCalibrateButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_radio3drConfig = new Radio3DRConfig(this);
ui.stackedWidget->addWidget(m_radio3drConfig);
m_buttonToConfigWidgetMap[ui.radio3DRButton] = m_radio3drConfig;
connect(ui.radio3DRButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_batteryConfig = new BatteryMonitorConfig(this);
ui.stackedWidget->addWidget(m_batteryConfig);
m_buttonToConfigWidgetMap[ui.batteryMonitorButton] = m_batteryConfig;
connect(ui.batteryMonitorButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_sonarConfig = new SonarConfig(this);
ui.stackedWidget->addWidget(m_sonarConfig);
m_buttonToConfigWidgetMap[ui.sonarButton] = m_sonarConfig;
connect(ui.sonarButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_airspeedConfig = new AirspeedConfig(this);
ui.stackedWidget->addWidget(m_airspeedConfig);
m_buttonToConfigWidgetMap[ui.airspeedButton] = m_airspeedConfig;
connect(ui.airspeedButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_opticalFlowConfig = new OpticalFlowConfig(this);
ui.stackedWidget->addWidget(m_opticalFlowConfig);
m_buttonToConfigWidgetMap[ui.opticalFlowButton] = m_opticalFlowConfig;
connect(ui.opticalFlowButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_osdConfig = new OsdConfig(this);
ui.stackedWidget->addWidget(m_osdConfig);
m_buttonToConfigWidgetMap[ui.osdButton] = m_osdConfig;
connect(ui.osdButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_cameraGimbalConfig = new CameraGimbalConfig(this);
ui.stackedWidget->addWidget(m_cameraGimbalConfig);
m_buttonToConfigWidgetMap[ui.cameraGimbalButton] = m_cameraGimbalConfig;
connect(ui.cameraGimbalButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
m_antennaTrackerConfig = new AntennaTrackerConfig(this);
ui.stackedWidget->addWidget(m_antennaTrackerConfig);
m_buttonToConfigWidgetMap[ui.antennaTrackerButton] = m_antennaTrackerConfig;
connect(ui.antennaTrackerButton,SIGNAL(clicked()),this,SLOT(activateStackedWidget()));
connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUASSet(UASInterface*)));
if (UASManager::instance()->getActiveUAS())
{
activeUASSet(UASManager::instance()->getActiveUAS());
}
}
void ApmHardwareConfig::activateStackedWidget()
{
if (m_buttonToConfigWidgetMap.contains(sender()))
{
ui.stackedWidget->setCurrentWidget(m_buttonToConfigWidgetMap[sender()]);
}
}
ApmHardwareConfig::~ApmHardwareConfig()
{
}
void ApmHardwareConfig::activeUASSet(UASInterface *uas)
{
if (!uas)
{
return;
}
if (uas->getSystemType() == MAV_TYPE_FIXED_WING)
{
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.compassButton,SLOT(setVisible(bool)));
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.arduPlaneLevelButton,SLOT(setVisible(bool)));
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.radioCalibrateButton,SLOT(setVisible(bool)));
connect(ui.optionalHardwareButton,SIGNAL(toggled(bool)),ui.airspeedButton,SLOT(setVisible(bool)));
}
else if (uas->getSystemType() == MAV_TYPE_QUADROTOR)
{
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.frameTypeButton,SLOT(setVisible(bool)));
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.compassButton,SLOT(setVisible(bool)));
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.accelCalibrateButton,SLOT(setVisible(bool)));
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.radioCalibrateButton,SLOT(setVisible(bool)));
}
else if (uas->getSystemType() == MAV_TYPE_GROUND_ROVER)
{
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.compassButton,SLOT(setVisible(bool)));
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.radioCalibrateButton,SLOT(setVisible(bool)));
}
else
{
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.compassButton,SLOT(setVisible(bool)));
connect(ui.manditoryHardware,SIGNAL(toggled(bool)),ui.radioCalibrateButton,SLOT(setVisible(bool)));
}
ui.firmwareButton->setVisible(true);
ui.manditoryHardware->setVisible(true);
ui.manditoryHardware->setChecked(true);
ui.optionalHardwareButton->setVisible(true);
ui.optionalHardwareButton->setChecked(true);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2013 Michael Carpenter (malcom2073@gmail.com)
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief APM Hardware Configuration widget header.
*
* @author Michael Carpenter <malcom2073@gmail.com>
*
*/
#ifndef APMHARDWARECONFIG_H
#define APMHARDWARECONFIG_H
#include <QWidget>
#include "ui_ApmHardwareConfig.h"
#include <UASInterface.h>
#include <UASManager.h>
#include "FrameTypeConfig.h"
#include "CompassConfig.h"
#include "AccelCalibrationConfig.h"
#include "RadioCalibrationConfig.h"
#include "Radio3DRConfig.h"
#include "BatteryMonitorConfig.h"
#include "SonarConfig.h"
#include "AirspeedConfig.h"
#include "OpticalFlowConfig.h"
#include "OsdConfig.h"
#include "CameraGimbalConfig.h"
#include "AntennaTrackerConfig.h"
#include "ApmPlaneLevel.h"
#include "ApmFirmwareConfig.h"
class ApmHardwareConfig : public QWidget
{
Q_OBJECT
public:
explicit ApmHardwareConfig(QWidget *parent = 0);
~ApmHardwareConfig();
private:
QPointer<FrameTypeConfig> m_frameConfig;
QPointer<CompassConfig> m_compassConfig;
QPointer<AccelCalibrationConfig> m_accelConfig;
QPointer<RadioCalibrationConfig> m_radioConfig;
QPointer<ApmFirmwareConfig> m_apmFirmwareConfig;
QPointer<Radio3DRConfig> m_radio3drConfig;
QPointer<BatteryMonitorConfig> m_batteryConfig;
QPointer<SonarConfig> m_sonarConfig;
QPointer<AirspeedConfig> m_airspeedConfig;
QPointer<OpticalFlowConfig> m_opticalFlowConfig;
QPointer<OsdConfig> m_osdConfig;
QPointer<CameraGimbalConfig> m_cameraGimbalConfig;
QPointer<AntennaTrackerConfig> m_antennaTrackerConfig;
QPointer<ApmPlaneLevel> m_planeLevel;
private slots:
void activeUASSet(UASInterface *uas);
void activateStackedWidget();
private:
Ui::ApmHardwareConfig ui;
//This is a map between the buttons, and the widgets they should be displying
QMap<QObject*,QWidget*> m_buttonToConfigWidgetMap;
};
#endif // APMHARDWARECONFIG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ApmHardwareConfig</class>
<widget class="QWidget" name="ApmHardwareConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1225</width>
<height>827</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QScrollArea" name="scrollArea_6">
<property name="geometry">
<rect>
<x>0</x>
<y>20</y>
<width>175</width>
<height>531</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>175</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>175</width>
<height>16777215</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>156</width>
<height>676</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QVBoxLayout" name="navBarLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item>
<widget class="QPushButton" name="firmwareButton">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>Install Firmware</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="manditoryHardware">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> &gt;&gt;&gt; Manditory Hardware</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="frameTypeButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string> Frame Type</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="compassButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> Compass</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="accelCalibrateButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string> Accel Calibration</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="arduPlaneLevelButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string> ArduPlane Level</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="radioCalibrateButton">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> Radio Calibration</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="optionalHardwareButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>&gt;&gt;&gt; Optional Hardware</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="radio3DRButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> 3DR Radio</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="batteryMonitorButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> Battery Monitor</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sonarButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> Sonar</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="airspeedButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> Airspeed</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="opticalFlowButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> Optical Flow</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="osdButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>OSD</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cameraGimbalButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> Camera Gimbal</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="antennaTrackerButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string> Antenna Tracker</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QStackedWidget" name="stackedWidget">
<property name="geometry">
<rect>
<x>200</x>
<y>30</y>
<width>921</width>
<height>761</height>
</rect>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
#include "ApmPlaneLevel.h"
#include <QMessageBox>
ApmPlaneLevel::ApmPlaneLevel(QWidget *parent) : AP2ConfigWidget(parent)
{
ui.setupUi(this);
connect(ui.levelPushButton,SIGNAL(clicked()),this,SLOT(levelClicked()));
connect(ui.manualLevelCheckBox,SIGNAL(toggled(bool)),this,SLOT(manualCheckBoxToggled(bool)));
initConnections();
}
ApmPlaneLevel::~ApmPlaneLevel()
{
}
void ApmPlaneLevel::levelClicked()
{
if (!m_uas)
{
showNullMAVErrorMessageBox();
return;
}
QMessageBox::information(0,"Warning","Be sure the plane is completly level, then click ok");
MAV_CMD command = MAV_CMD_PREFLIGHT_CALIBRATION;
int confirm = 0;
float param1 = 1.0;
float param2 = 0.0;
float param3 = 1.0;
float param4 = 0.0;
float param5 = 0.0;
float param6 = 0.0;
float param7 = 0.0;
int component = 1;
m_uas->executeCommand(command, confirm, param1, param2, param3, param4, param5, param6, param7, component);
QMessageBox::information(0,"Warning","Leveling completed");
}
void ApmPlaneLevel::manualCheckBoxToggled(bool checked)
{
if (!m_uas)
{
showNullMAVErrorMessageBox();
return;
}
if (checked)
{
m_uas->getParamManager()->setParameter(1,"MANUAL_LEVEL",1);
}
else
{
m_uas->getParamManager()->setParameter(1,"MANUAL_LEVEL",0);
}
}
void ApmPlaneLevel::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
Q_UNUSED(uas);
Q_UNUSED(component);
if (parameterName == "MANUAL_LEVEL")
{
if (value.toInt() == 1)
{
ui.manualLevelCheckBox->setChecked(true);
}
else
{
ui.manualLevelCheckBox->setChecked(false);
}
}
}
#ifndef APMPLANELEVEL_H
#define APMPLANELEVEL_H
#include <QWidget>
#include "ui_ApmPlaneLevel.h"
#include "AP2ConfigWidget.h"
class ApmPlaneLevel : public AP2ConfigWidget
{
Q_OBJECT
public:
explicit ApmPlaneLevel(QWidget *parent = 0);
~ApmPlaneLevel();
private slots:
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
void levelClicked();
void manualCheckBoxToggled(bool checked);
private:
Ui::ApmPlaneLevel ui;
};
#endif // APMPLANELEVEL_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ApmPlaneLevel</class>
<widget class="QWidget" name="ApmPlaneLevel">
<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="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>&lt;h2&gt;ArduPlane Level&lt;/h2&gt;</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>50</x>
<y>70</y>
<width>271</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>By Default your plane will autolevel on every boot.
To disable this action you need to turn on manual
level and perform a level to calibrate the accel offsets.</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>50</x>
<y>150</y>
<width>291</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Level your plane and click Level to set default accel offsets</string>
</property>
</widget>
<widget class="QPushButton" name="levelPushButton">
<property name="geometry">
<rect>
<x>160</x>
<y>180</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Level</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>120</x>
<y>230</y>
<width>151</width>
<height>51</height>
</rect>
</property>
<property name="title">
<string>For advanced users ONLY</string>
</property>
<widget class="QCheckBox" name="manualLevelCheckBox">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>91</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Manual Level</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
#ifndef APMSOFTWARECONFIG_H
#define APMSOFTWARECONFIG_H
#include <QWidget>
#include "ui_ApmSoftwareConfig.h"
#include "FlightModeConfig.h"
#include "BasicPidConfig.h"
#include "StandardParamConfig.h"
#include "GeoFenceConfig.h"
#include "FailSafeConfig.h"
#include "AdvancedParamConfig.h"
#include "ArduCopterPidConfig.h"
#include "ArduPlanePidConfig.h"
#include "ArduRoverPidConfig.h"
#include "AdvParameterList.h"
#include "UASInterface.h"
#include "UASManager.h"
class ApmSoftwareConfig : public QWidget
{
Q_OBJECT
public:
explicit ApmSoftwareConfig(QWidget *parent = 0);
~ApmSoftwareConfig();
private slots:
void activateStackedWidget();
void activeUASSet(UASInterface *uas);
private:
Ui::ApmSoftwareConfig ui;
QPointer<BasicPidConfig> m_basicPidConfig;
QPointer<FlightModeConfig> m_flightConfig;
QPointer<StandardParamConfig> m_standardParamConfig;
QPointer<GeoFenceConfig> m_geoFenceConfig;
QPointer<FailSafeConfig> m_failSafeConfig;
QPointer<AdvancedParamConfig> m_advancedParamConfig;
QPointer<ArduCopterPidConfig> m_arduCopterPidConfig;
QPointer<ArduPlanePidConfig> m_arduPlanePidConfig;
QPointer<ArduRoverPidConfig> m_arduRoverPidConfig;
QPointer<AdvParameterList> m_advParameterList;
QMap<QObject*,QWidget*> m_buttonToConfigWidgetMap;
};
#endif // APMSOFTWARECONFIG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ApmSoftwareConfig</class>
<widget class="QWidget" name="ApmSoftwareConfig">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>853</width>
<height>619</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QScrollArea" name="scrollArea_6">
<property name="minimumSize">
<size>
<width>175</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>175</width>
<height>16777215</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>173</width>
<height>599</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QVBoxLayout" name="navBarLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item>
<widget class="QPushButton" name="plannerConfigButton">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>qgroundcontrol 2.0 Config</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="flightModesButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>Flight Modes</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="standardParamButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>Standard Params</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="failSafeButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>FailSafe</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="advancedParamButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>Advanced Params</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="advParamListButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>Full Parameter List</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="arduCopterPidButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>ArduCopter Pids</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="arduPlanePidButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>ArduPlane Pids</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="arduRoverPidButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>ArduRover Pids</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "ArduCopterPidConfig.h"
ArduCopterPidConfig::ArduCopterPidConfig(QWidget *parent) : AP2ConfigWidget(parent)
{
ui.setupUi(this);
m_pitchRollLocked = false;
connect(ui.checkBox,SIGNAL(clicked(bool)),this,SLOT(lockCheckBoxClicked(bool)));
connect(ui.stabilPitchPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
connect(ui.stabilRollPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
connect(ui.stabilYawPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
m_nameToBoxMap["STB_RLL_P"] = ui.stabilPitchPSpinBox;
m_nameToBoxMap["STB_PIT_P"] = ui.stabilRollPSpinBox;
m_nameToBoxMap["STB_YAW_P"] = ui.stabilYawPSpinBox;
m_nameToBoxMap["HLD_LAT_P"] = ui.loiterPidPSpinBox;
m_nameToBoxMap["RATE_RLL_P"] = ui.rateRollPSpinBox;
m_nameToBoxMap["RATE_RLL_I"] = ui.rateRollISpinBox;
m_nameToBoxMap["RATE_RLL_D"] = ui.rateRollDSpinBox;
m_nameToBoxMap["RATE_RLL_IMAX"] = ui.rateRollIMAXSpinBox;
m_nameToBoxMap["RATE_PIT_P"] = ui.ratePitchPSpinBox;
m_nameToBoxMap["RATE_PIT_I"] = ui.ratePitchISpinBox;
m_nameToBoxMap["RATE_PIT_D"] = ui.ratePitchDSpinBox;
m_nameToBoxMap["RATE_PIT_IMAX"] = ui.ratePitchIMAXSpinBox;
m_nameToBoxMap["RATE_YAW_P"] = ui.rateYawPSpinBox;
m_nameToBoxMap["RATE_YAW_I"] = ui.rateYawISpinBox;
m_nameToBoxMap["RATE_YAW_D"] = ui.rateYawDSpinBox;
m_nameToBoxMap["RATE_YAW_IMAX"] = ui.rateYawIMAXSpinBox;
m_nameToBoxMap["LOITER_LAT_P"] = ui.rateLoiterPSpinBox;
m_nameToBoxMap["LOITER_LAT_I"] = ui.rateLoiterISpinBox;
m_nameToBoxMap["LOITER_LAT_D"] = ui.rateLoiterDSpinBox;
m_nameToBoxMap["LOITER_LAT_IMAX"] = ui.rateLoiterIMAXSpinBox;
m_nameToBoxMap["THR_ACCEL_P"] = ui.throttleAccelPSpinBox;
m_nameToBoxMap["THR_ACCEL_I"] = ui.throttleAccelISpinBox;
m_nameToBoxMap["THR_ACCEL_D"] = ui.throttleAccelDSpinBox;
m_nameToBoxMap["THR_ACCEL_IMAX"] = ui.throttleAccelIMAXSpinBox;
m_nameToBoxMap["THR_RATE_P"] = ui.throttleRatePSpinBox;
m_nameToBoxMap["THR_RATE_D"] = ui.throttleDateDSpinBox;
m_nameToBoxMap["THR_ALT_P"] = ui.altitudeHoldPSpinBox;
m_nameToBoxMap["WPNAV_SPEED"] = ui.wpNavLoiterSpeedSpinBox;
m_nameToBoxMap["WPNAV_RADIUS"] = ui.wpNavRadiusSpinBox;
m_nameToBoxMap["WPNAV_SPEED_DN"] = ui.wpNavSpeedDownSpinBox;
m_nameToBoxMap["WPNAV_LOIT_SPEED"] = ui.wpNavSpeedSpinBox;
m_nameToBoxMap["WPNAV_SPEED_UP"] = ui.wpNavSpeedUpSpinBox;
m_nameToBoxMap["TUNE_HIGH"] = ui.ch6MaxSpinBox;
m_nameToBoxMap["TUNE_LOW"] = ui.ch6MinSpinBox;
connect(ui.writePushButton,SIGNAL(clicked()),this,SLOT(writeButtonClicked()));
connect(ui.refreshPushButton,SIGNAL(clicked()),this,SLOT(refreshButtonClicked()));
m_ch6ValueToTextList.append(QPair<int,QString>(0,"CH6_NONE"));
m_ch6ValueToTextList.append(QPair<int,QString>(1,"CH6_STABILIZE_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(2,"CH6_STABILIZE_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(3,"CH6_YAW_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(24,"CH6_YAW_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(4,"CH6_RATE_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(5,"CH6_RATE_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(6,"CH6_YAW_RATE_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(26,"CH6_YAW_RATE_KD"));
m_ch6ValueToTextList.append(QPair<int,QString>(7,"CH6_THROTTLE_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(9,"CH6_RELAY"));
m_ch6ValueToTextList.append(QPair<int,QString>(10,"CH6_WP_SPEED"));
m_ch6ValueToTextList.append(QPair<int,QString>(12,"CH6_LOITER_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(13,"CH6_HELI_EXTERNAL_GYRO"));
m_ch6ValueToTextList.append(QPair<int,QString>(14,"CH6_THR_HOLD_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(17,"CH6_OPTFLOW_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(18,"CH6_OPTFLOW_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(19,"CH6_OPTFLOW_KD"));
m_ch6ValueToTextList.append(QPair<int,QString>(21,"CH6_RATE_KD"));
m_ch6ValueToTextList.append(QPair<int,QString>(22,"CH6_LOITER_RATE_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(23,"CH6_LOITER_RATE_KD"));
m_ch6ValueToTextList.append(QPair<int,QString>(25,"CH6_ACRO_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(27,"CH6_LOITER_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(28,"CH6_LOITER_RATE_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(29,"CH6_STABILIZE_KD"));
m_ch6ValueToTextList.append(QPair<int,QString>(30,"CH6_AHRS_YAW_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(31,"CH6_AHRS_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(32,"CH6_INAV_TC"));
m_ch6ValueToTextList.append(QPair<int,QString>(33,"CH6_THROTTLE_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(34,"CH6_THR_ACCEL_KP"));
m_ch6ValueToTextList.append(QPair<int,QString>(35,"CH6_THR_ACCEL_KI"));
m_ch6ValueToTextList.append(QPair<int,QString>(36,"CH6_THR_ACCEL_KD"));
m_ch6ValueToTextList.append(QPair<int,QString>(38,"CH6_DECLINATION"));
m_ch6ValueToTextList.append(QPair<int,QString>(39,"CH6_CIRCLE_RATE"));
for (int i=0;i<m_ch6ValueToTextList.size();i++)
{
ui.ch6OptComboBox->addItem(m_ch6ValueToTextList[i].second);
}
m_ch78ValueToTextList.append(QPair<int,QString>(0,"Do nothing"));
m_ch78ValueToTextList.append(QPair<int,QString>(2,"Flip"));
m_ch78ValueToTextList.append(QPair<int,QString>(3,"Simple mode"));
m_ch78ValueToTextList.append(QPair<int,QString>(4,"RTL"));
m_ch78ValueToTextList.append(QPair<int,QString>(5,"Save Trim"));
m_ch78ValueToTextList.append(QPair<int,QString>(7,"Save WP"));
m_ch78ValueToTextList.append(QPair<int,QString>(8,"Multi Mode"));
m_ch78ValueToTextList.append(QPair<int,QString>(9,"Camera Trigger"));
m_ch78ValueToTextList.append(QPair<int,QString>(10,"Sonar"));
m_ch78ValueToTextList.append(QPair<int,QString>(11,"Fence"));
m_ch78ValueToTextList.append(QPair<int,QString>(12,"ResetToArmedYaw"));
for (int i=0;i<m_ch78ValueToTextList.size();i++)
{
ui.ch7OptComboBox->addItem(m_ch78ValueToTextList[i].second);
ui.ch8OptComboBox->addItem(m_ch78ValueToTextList[i].second);
}
initConnections();
}
void ArduCopterPidConfig::lockCheckBoxClicked(bool checked)
{
m_pitchRollLocked = checked;
}
void ArduCopterPidConfig::stabilLockedChanged(double value)
{
if (m_pitchRollLocked)
{
disconnect(ui.stabilPitchPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
disconnect(ui.stabilRollPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
disconnect(ui.stabilYawPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
ui.stabilPitchPSpinBox->setValue(value);
ui.stabilRollPSpinBox->setValue(value);
ui.stabilYawPSpinBox->setValue(value);
connect(ui.stabilPitchPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
connect(ui.stabilRollPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
connect(ui.stabilYawPSpinBox,SIGNAL(valueChanged(double)),this,SLOT(stabilLockedChanged(double)));
}
}
ArduCopterPidConfig::~ArduCopterPidConfig()
{
}
void ArduCopterPidConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
Q_UNUSED(uas);
Q_UNUSED(component);
if (m_nameToBoxMap.contains(parameterName))
{
m_nameToBoxMap[parameterName]->setValue(value.toDouble());
}
else if (parameterName == "TUNE")
{
for (int i=0;i<m_ch6ValueToTextList.size();i++)
{
if (m_ch6ValueToTextList[i].first == value.toInt())
{
ui.ch6OptComboBox->setCurrentIndex(i);
}
}
}
else if (parameterName == "CH7_OPT")
{
for (int i=0;i<m_ch78ValueToTextList.size();i++)
{
if (m_ch78ValueToTextList[i].first == value.toInt())
{
ui.ch7OptComboBox->setCurrentIndex(i);
}
}
}
else if (parameterName == "CH8_OPT")
{
for (int i=0;i<m_ch78ValueToTextList.size();i++)
{
if (m_ch78ValueToTextList[i].first == value.toInt())
{
ui.ch8OptComboBox->setCurrentIndex(i);
}
}
}
}
void ArduCopterPidConfig::writeButtonClicked()
{
if (!m_uas)
{
showNullMAVErrorMessageBox();
return;
}
for (QMap<QString,QDoubleSpinBox*>::const_iterator i=m_nameToBoxMap.constBegin();i!=m_nameToBoxMap.constEnd();i++)
{
m_uas->getParamManager()->setParameter(1,i.key(),i.value()->value());
}
m_uas->getParamManager()->setParameter(1,"TUNE",m_ch78ValueToTextList[ui.ch6OptComboBox->currentIndex()].first);
m_uas->getParamManager()->setParameter(1,"CH7_OPT",m_ch78ValueToTextList[ui.ch7OptComboBox->currentIndex()].first);
m_uas->getParamManager()->setParameter(1,"CH8_OPT",m_ch78ValueToTextList[ui.ch8OptComboBox->currentIndex()].first);
}
void ArduCopterPidConfig::refreshButtonClicked()
{
if (!m_uas)
{
showNullMAVErrorMessageBox();
return;
}
for (QMap<QString,QDoubleSpinBox*>::const_iterator i=m_nameToBoxMap.constBegin();i!=m_nameToBoxMap.constEnd();i++)
{
m_uas->getParamManager()->requestParameterUpdate(1,i.key());
}
m_uas->getParamManager()->requestParameterUpdate(1,"TUNE");
m_uas->getParamManager()->requestParameterUpdate(1,"CH7_OPT");
m_uas->getParamManager()->requestParameterUpdate(1,"CH8_OPT");
}
#ifndef ARDUCOPTERPIDCONFIG_H
#define ARDUCOPTERPIDCONFIG_H
#include <QWidget>
#include "ui_ArduCopterPidConfig.h"
#include "AP2ConfigWidget.h"
class ArduCopterPidConfig : public AP2ConfigWidget
{
Q_OBJECT
public:
explicit ArduCopterPidConfig(QWidget *parent = 0);
~ArduCopterPidConfig();
private slots:
void writeButtonClicked();
void refreshButtonClicked();
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
void lockCheckBoxClicked(bool checked);
void stabilLockedChanged(double value);
private:
bool m_pitchRollLocked;
QList<QPair<int,QString> > m_ch6ValueToTextList;
QList<QPair<int,QString> > m_ch78ValueToTextList;
QMap<QString,QDoubleSpinBox*> m_nameToBoxMap;
Ui::ArduCopterPidConfig ui;
};
#endif // ARDUCOPTERPIDCONFIG_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment