Commit 5e89b4eb authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #977 from DonLakeFlyer/RemovePixhawkAutopilot

Remove PIXHAWK specific board support
parents d712b105 22aacd61
......@@ -31,12 +31,6 @@ else:exists(user_config.pri):infile(user_config.pri, MAVLINK_CONF) {
message($$sprintf("Using MAVLink dialect '%1' specified in user_config.pri", $$MAVLINK_CONF))
}
}
# If no valid user selection is found, default to the pixhawk if it's available.
# Note: This can be a list of several dialects.
else {
MAVLINK_CONF=pixhawk
message($$sprintf("Using default MAVLink dialect '%1'.", $$MAVLINK_CONF))
}
# Then we add the proper include paths dependent on the dialect.
INCLUDEPATH += $$MAVLINKPATH
......
......@@ -245,7 +245,6 @@ INCLUDEPATH += \
src/lib/qmapcontrol \
src/ui/mavlink \
src/ui/param \
src/ui/watchdog \
src/ui/map3D \
src/ui/mission \
src/ui/designer \
......@@ -266,16 +265,12 @@ FORMS += \
src/ui/UASView.ui \
src/ui/ParameterInterface.ui \
src/ui/WaypointList.ui \
src/ui/ObjectDetectionView.ui \
src/ui/JoystickWidget.ui \
src/ui/DebugConsole.ui \
src/ui/HDDisplay.ui \
src/ui/MAVLinkSettingsWidget.ui \
src/ui/AudioOutputWidget.ui \
src/ui/QGCSensorSettingsWidget.ui \
src/ui/watchdog/WatchdogControl.ui \
src/ui/watchdog/WatchdogProcessView.ui \
src/ui/watchdog/WatchdogView.ui \
src/ui/QGCDataPlot2D.ui \
src/ui/QGCRemoteControlView.ui \
src/ui/QMap3D.ui \
......@@ -372,7 +367,6 @@ HEADERS += \
src/ui/ParameterInterface.h \
src/ui/WaypointList.h \
src/Waypoint.h \
src/ui/ObjectDetectionView.h \
src/input/JoystickInput.h \
src/ui/JoystickWidget.h \
src/ui/DebugConsole.h \
......@@ -384,10 +378,6 @@ HEADERS += \
src/ui/QGCParamWidget.h \
src/ui/QGCSensorSettingsWidget.h \
src/ui/linechart/Linecharts.h \
src/uas/PxQuadMAV.h \
src/ui/watchdog/WatchdogControl.h \
src/ui/watchdog/WatchdogProcessView.h \
src/ui/watchdog/WatchdogView.h \
src/uas/UASWaypointManager.h \
src/ui/HSIDisplay.h \
src/QGC.h \
......@@ -528,7 +518,6 @@ SOURCES += \
src/ui/ParameterInterface.cc \
src/ui/WaypointList.cc \
src/Waypoint.cc \
src/ui/ObjectDetectionView.cc \
src/input/JoystickInput.cc \
src/ui/JoystickWidget.cc \
src/ui/DebugConsole.cc \
......@@ -540,10 +529,6 @@ SOURCES += \
src/ui/QGCParamWidget.cc \
src/ui/QGCSensorSettingsWidget.cc \
src/ui/linechart/Linecharts.cc \
src/uas/PxQuadMAV.cc \
src/ui/watchdog/WatchdogControl.cc \
src/ui/watchdog/WatchdogProcessView.cc \
src/ui/watchdog/WatchdogView.cc \
src/uas/UASWaypointManager.cc \
src/ui/HSIDisplay.cc \
src/QGC.cc \
......
......@@ -24,7 +24,6 @@
#include "UASManager.h"
#include "UASInterface.h"
#include "UAS.h"
#include "PxQuadMAV.h"
#include "configuration.h"
#include "LinkManager.h"
#include "QGCMAVLink.h"
......
......@@ -197,10 +197,6 @@ void MAVLinkSimulationLink::mainloop()
mavlink_attitude_t attitude;
memset(&attitude, 0, sizeof(mavlink_attitude_t));
#ifdef MAVLINK_ENABLED_PIXHAWK
mavlink_raw_aux_t rawAuxValues;
memset(&rawAuxValues, 0, sizeof(mavlink_raw_aux_t));
#endif
mavlink_raw_imu_t rawImuValues;
memset(&rawImuValues, 0, sizeof(mavlink_raw_imu_t));
......@@ -301,15 +297,6 @@ void MAVLinkSimulationLink::mainloop()
rawImuValues.zgyro = d;
attitude.yawspeed = ((d-29.000)/3000.0)*2.7-2.7-2.65;
}
#ifdef MAVLINK_ENABLED_PIXHAWK
if (keys.value(i, "") == "Pressure") {
rawAuxValues.baro = d;
}
if (keys.value(i, "") == "Battery") {
rawAuxValues.vbat = d;
}
#endif
if (keys.value(i, "") == "roll_IMU") {
attitude.roll = d;
}
......@@ -473,46 +460,6 @@ void MAVLinkSimulationLink::mainloop()
static int detectionCounter = 6;
if (detectionCounter % 10 == 0) {
#ifdef MAVLINK_ENABLED_PIXHAWK
mavlink_pattern_detected_t detected;
detected.confidence = 5.0f;
detected.type = 0; // compiler confused into thinking type is used unitialized, bogus init to silence
if (detectionCounter == 10) {
char fileName[] = "patterns/face5.png";
memcpy(detected.file, fileName, sizeof(fileName));
detected.type = 0; // 0: Pattern, 1: Letter
} else if (detectionCounter == 20) {
char fileName[] = "7";
memcpy(detected.file, fileName, sizeof(fileName));
detected.type = 1; // 0: Pattern, 1: Letter
} else if (detectionCounter == 30) {
char fileName[] = "patterns/einstein.bmp";
memcpy(detected.file, fileName, sizeof(fileName));
detected.type = 0; // 0: Pattern, 1: Letter
} else if (detectionCounter == 40) {
char fileName[] = "F";
memcpy(detected.file, fileName, sizeof(fileName));
detected.type = 1; // 0: Pattern, 1: Letter
} else if (detectionCounter == 50) {
char fileName[] = "patterns/face2.png";
memcpy(detected.file, fileName, sizeof(fileName));
detected.type = 0; // 0: Pattern, 1: Letter
} else if (detectionCounter == 60) {
char fileName[] = "H";
memcpy(detected.file, fileName, sizeof(fileName));
detected.type = 1; // 0: Pattern, 1: Letter
detectionCounter = 0;
}
detected.detected = 1;
mavlink_msg_pattern_detected_encode(systemId, componentId, &msg, &detected);
// Allocate buffer with packet data
bufferlength = mavlink_msg_to_send_buffer(buffer, &msg);
//add data into datastream
memcpy(stream+streampointer,buffer, bufferlength);
streampointer += bufferlength;
//detectionCounter = 0;
#endif
}
detectionCounter++;
......@@ -701,14 +648,6 @@ void MAVLinkSimulationLink::writeBytes(const char* data, qint64 size)
// }
}
break;
#ifdef MAVLINK_ENABLED_PIXHAWK
case MAVLINK_MSG_ID_MANUAL_CONTROL: {
mavlink_manual_control_t control;
mavlink_msg_manual_control_decode(&msg, &control);
// qDebug() << "\n" << "ROLL:" << control.x << "PITCH:" << control.y;
}
break;
#endif
case MAVLINK_MSG_ID_PARAM_REQUEST_LIST:
{
// qDebug() << "GCS REQUESTED PARAM LIST FROM SIMULATION";
......
......@@ -199,47 +199,6 @@ void OpalLink::writeBytes(const char *bytes, qint64 length)
params->getParameter(OpalRT::SERVO_INPUTS, "PIT_SET4_IN").setValue(((radio.pitch[4]>900 /*in us?*/)?radio.pitch[4]/1000:radio.pitch[4]));
}
break;
#endif
#ifdef MAVLINK_ENABLED_PIXHAWK
case MAVLINK_MSG_ID_REQUEST_DATA_STREAM: {
mavlink_request_data_stream_t stream;
mavlink_msg_request_data_stream_decode(&msg, &stream);
switch (stream.req_stream_id) {
case 0: // All data types
break;
case 1: // Raw Sensor Data
break;
case 2: // extended system status
break;
case 3: // rc channel data
sendRCValues = (stream.start_stop == 1?true:false);
break;
case 4: // raw controller
if (stream.start_stop == 1)
sendRawController = true;
else
sendRawController = false;
break;
case 5: // raw sensor fusion
break;
case 6: // position
sendPosition = (stream.start_stop == 1?true:false);
break;
case 7: // extra 1
break;
case 8: // extra 2
break;
case 9: // extra 3
break;
default:
qDebug() << __FILE__ << __LINE__ << "Received Unknown Data Strem Request with ID" << stream.req_stream_id;
}
}
break;
default: {
qDebug() << "OpalLink::writeBytes(): Unknown mavlink packet";
}
}
#endif
}
......
......@@ -32,12 +32,5 @@ This file is part of the QGROUNDCONTROL project
#include <mavlink.h>
//#ifdef MAVLINK_CONF
//#define MY_MACRO(x) <x>
//#include MY_MACRO(MAVLINK_CONF)
//#include MAVLINK_CONF
//#endif
#endif // QGCMAVLINK_H
This diff is collapsed.
/*=====================================================================
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 PXQUADMAV_H
#define PXQUADMAV_H
#include "UAS.h"
class PxQuadMAV : public UAS
{
Q_OBJECT
Q_INTERFACES(UASInterface)
public:
PxQuadMAV(MAVLinkProtocol* mavlink, QThread* thread, int id);
public slots:
/** @brief Receive a MAVLink message from this MAV */
void receiveMessage(LinkInterface* link, mavlink_message_t message);
/** @brief Send a command to an onboard process */
void sendProcessCommand(int watchdogId, int processId, unsigned int command);
signals:
void watchdogReceived(int systemId, int watchdogId, unsigned int processCount);
void processReceived(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout);
void processChanged(int systemId, int watchdogId, int processId, int state, bool muted, int crashed, int pid);
};
#endif // PXQUADMAV_H
......@@ -39,20 +39,6 @@ UASInterface* QGCMAVLinkUASFactory::createUAS(MAVLinkProtocol* mavlink, LinkInte
uas = mav;
}
break;
case MAV_AUTOPILOT_PIXHAWK:
{
PxQuadMAV* mav = new PxQuadMAV(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;
case MAV_AUTOPILOT_PX4:
{
QGXPX4UAS* px4 = new QGXPX4UAS(mavlink, worker, sysid);
......
......@@ -10,7 +10,6 @@
// INCLUDE ALL MAV/UAS CLASSES USING MAVLINK
#include "UAS.h"
#include "PxQuadMAV.h"
class QGCMAVLinkUASFactory : public QObject
{
......
......@@ -334,65 +334,6 @@ public:
bool isRotaryWing();
bool isFixedWing();
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
px::GLOverlay getOverlay()
{
QMutexLocker locker(&overlayMutex);
return overlay;
}
px::GLOverlay getOverlay(qreal& receivedTimestamp)
{
receivedTimestamp = receivedOverlayTimestamp;
QMutexLocker locker(&overlayMutex);
return overlay;
}
px::ObstacleList getObstacleList() {
QMutexLocker locker(&obstacleListMutex);
return obstacleList;
}
px::ObstacleList getObstacleList(qreal& receivedTimestamp) {
receivedTimestamp = receivedObstacleListTimestamp;
QMutexLocker locker(&obstacleListMutex);
return obstacleList;
}
px::Path getPath() {
QMutexLocker locker(&pathMutex);
return path;
}
px::Path getPath(qreal& receivedTimestamp) {
receivedTimestamp = receivedPathTimestamp;
QMutexLocker locker(&pathMutex);
return path;
}
px::PointCloudXYZRGB getPointCloud() {
QMutexLocker locker(&pointCloudMutex);
return pointCloud;
}
px::PointCloudXYZRGB getPointCloud(qreal& receivedTimestamp) {
receivedTimestamp = receivedPointCloudTimestamp;
QMutexLocker locker(&pointCloudMutex);
return pointCloud;
}
px::RGBDImage getRGBDImage() {
QMutexLocker locker(&rgbdImageMutex);
return rgbdImage;
}
px::RGBDImage getRGBDImage(qreal& receivedTimestamp) {
receivedTimestamp = receivedRGBDImageTimestamp;
QMutexLocker locker(&rgbdImageMutex);
return rgbdImage;
}
#endif
friend class UASWaypointManager;
friend class QGCUASFileManager;
......@@ -525,28 +466,6 @@ protected: //COMMENTS FOR TEST UNIT
bool blockHomePositionChanges; ///< Block changes to the home position
bool receivedMode; ///< True if mode was retrieved from current conenction to UAS
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
px::GLOverlay overlay;
QMutex overlayMutex;
qreal receivedOverlayTimestamp;
px::ObstacleList obstacleList;
QMutex obstacleListMutex;
qreal receivedObstacleListTimestamp;
px::Path path;
QMutex pathMutex;
qreal receivedPathTimestamp;
px::PointCloudXYZRGB pointCloud;
QMutex pointCloudMutex;
qreal receivedPointCloudTimestamp;
px::RGBDImage rgbdImage;
QMutex rgbdImageMutex;
qreal receivedRGBDImageTimestamp;
#endif
/// PARAMETERS
QMap<int, QMap<QString, QVariant>* > parameters; ///< All parameters
bool paramsOnceRequested; ///< If the parameter list has been read at least once
......
......@@ -75,9 +75,6 @@ This file is part of the QGROUNDCONTROL project
#include "Q3DWidgetFactory.h"
#endif
// FIXME Move
#include "PxQuadMAV.h"
#include "LogCompressor.h"
// Set up some constants
......@@ -1541,25 +1538,6 @@ void MainWindow::UASCreated(UASInterface* uas)
// Load default custom widgets for this autopilot type
loadCustomWidgetsFromDefaults(uas->getSystemTypeName(), uas->getAutopilotTypeName());
if (uas->getAutopilotType() == MAV_AUTOPILOT_PIXHAWK)
{
// Dock widgets
if (!detectionDockWidget)
{
detectionDockWidget = new QDockWidget(tr("Object Recognition"), this);
detectionDockWidget->setWidget( new ObjectDetectionView("files/images/patterns", this) );
detectionDockWidget->setObjectName("OBJECT_DETECTION_DOCK_WIDGET");
}
if (!watchdogControlDockWidget)
{
watchdogControlDockWidget = new QDockWidget(tr("Process Control"), this);
watchdogControlDockWidget->setWidget( new WatchdogControl(this) );
watchdogControlDockWidget->setObjectName("WATCHDOG_CONTROL_DOCKWIDGET");
}
}
// Reload view state in case new widgets were added
loadViewState();
}
......
......@@ -48,7 +48,6 @@ This file is part of the QGROUNDCONTROL project
#include "UASListWidget.h"
#include "MAVLinkProtocol.h"
#include "MAVLinkSimulationLink.h"
#include "ObjectDetectionView.h"
#include "submainwindow.h"
#include "input/JoystickInput.h"
#if (defined QGC_MOUSE_ENABLED_WIN) | (defined QGC_MOUSE_ENABLED_LINUX)
......@@ -57,7 +56,6 @@ This file is part of the QGROUNDCONTROL project
#include "DebugConsole.h"
#include "ParameterInterface.h"
#include "HDDisplay.h"
#include "WatchdogControl.h"
#include "HSIDisplay.h"
#include "QGCRemoteControlView.h"
#include "opmapcontrol.h"
......
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK 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.
PIXHAWK 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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief List of detected objects
* @author Benjamin Knecht <mavteam@student.ethz.ch>
* @author Lorenz Meier <mavteam@student.ethz.ch>
* @author Fabian Landau <mavteam@student.ethz.ch>
*
*/
#include <QListView>
#include <QPixmap>
#include "ObjectDetectionView.h"
#include "ui_ObjectDetectionView.h"
#include "UASManager.h"
#include "GAudioOutput.h"
#include <QDebug>
#include <QMap>
ObjectDetectionView::ObjectDetectionView(QString folder, QWidget *parent) :
QWidget(parent),
patternList(),
letterList(),
letterTimer(),
uas(NULL),
patternFolder(folder),
separator(" "),
m_ui(new Ui::ObjectDetectionView)
{
m_ui->setupUi(this);
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setUAS(UASInterface*)));
letterTimer.start(1000);
connect(&letterTimer, SIGNAL(timeout()), this, SLOT(decreaseLetterTime()));
connect(m_ui->clearButton, SIGNAL(clicked()), this, SLOT(clearLists()));
this->setVisible(false);
}
ObjectDetectionView::~ObjectDetectionView()
{
delete m_ui;
}
void ObjectDetectionView::changeEvent(QEvent *e)
{
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
void ObjectDetectionView::setUAS(UASInterface* uas)
{
if (this->uas != NULL) {
disconnect(this->uas, SIGNAL(patternDetected(int, QString, float, bool)), this, SLOT(newPattern(int, QString, float, bool)));
disconnect(this->uas, SIGNAL(letterDetected(int, QString, float, bool)), this, SLOT(newLetter(int, QString, float, bool)));
}
this->uas = uas;
connect(uas, SIGNAL(patternDetected(int, QString, float, bool)), this, SLOT(newPattern(int, QString, float, bool)));
connect(uas, SIGNAL(letterDetected(int, QString, float, bool)), this, SLOT(newLetter(int, QString, float, bool)));
}
void ObjectDetectionView::newPattern(int uasId, QString patternPath, float confidence, bool detected)
{
if (detected) {
if (!patternList.contains(patternPath)) {
// Emit audio message on detection
if (detected) GAudioOutput::instance()->say("System " + QString::number(uasId) + " detected pattern " + QString(patternPath.split("/", QString::SkipEmptyParts).last()).split(".", QString::SkipEmptyParts).first());
patternList.insert(patternPath, Pattern(patternPath, confidence));
} else {
Pattern pattern = patternList.value(patternPath);
if (confidence > pattern.confidence)
pattern.confidence = confidence;
++pattern.count;
patternList.insert(patternPath, pattern);
}
// set list items
QList<Pattern> templist;
foreach (Pattern pattern, patternList)
templist.push_back(pattern);
qSort(templist);
m_ui->listWidget->clear();
foreach (Pattern pattern, templist)
m_ui->listWidget->addItem(pattern.name + separator + "(" + QString::number(pattern.count) + ")" + separator + QString::number(pattern.confidence));
// load image
QString filePath = patternFolder + "/" + patternPath.split("/", QString::SkipEmptyParts).last();
QPixmap image = QPixmap(filePath);
if (image.width() > image.height())
image = image.scaledToWidth(m_ui->imageLabel->width());
else
image = image.scaledToHeight(m_ui->imageLabel->height());
m_ui->imageLabel->setPixmap(image);
// set textlabel
QString patternName = patternPath.split("/", QString::SkipEmptyParts).last(); // Remove preceding folder names
patternName = patternName.split(".", QString::SkipEmptyParts).first(); // Remove file ending
m_ui->nameLabel->setText("Pattern: " + patternName);
}
}
void ObjectDetectionView::newLetter(int uasId, QString letter, float confidence, bool detected)
{
Q_UNUSED(confidence);
if (detected) {
if (!letterList.contains(letter)) {
// Emit audio message on detection
if (detected) GAudioOutput::instance()->say("System " + QString::number(uasId) + " detected letter " + letter);
letterList.insert(letter, Pattern(letter, 0));
} else {
Pattern pattern = letterList.value(letter);
pattern.confidence = 0;
++pattern.count;
letterList.insert(letter, pattern);
}
updateLetterList();
// display letter
m_ui->letterLabel->setText(letter);
// set textlabel
m_ui->nameLabel->setText("Letter: " + letter);
}
}
void ObjectDetectionView::decreaseLetterTime()
{
foreach (Pattern pattern, letterList) {
pattern.confidence -= 1;
letterList.insert(pattern.name, pattern);
}
updateLetterList();
}
void ObjectDetectionView::updateLetterList()
{
// set list items
QList<Pattern> templist;
foreach (Pattern pattern, letterList)
templist.push_back(pattern);
qSort(templist);
m_ui->letterListWidget->clear();
foreach (Pattern pattern, templist)
m_ui->letterListWidget->addItem(pattern.name + separator + "(" + QString::number(pattern.count) + ")" + separator + QString::number(pattern.confidence));
}
void ObjectDetectionView::clearLists()
{
patternList.clear();
letterList.clear();
m_ui->listWidget->clear();
m_ui->letterListWidget->clear();
m_ui->imageLabel->clear();;
m_ui->letterLabel->clear();
m_ui->nameLabel->clear();
}
void ObjectDetectionView::takeAction()
{
QAction* act = dynamic_cast<QAction*>(sender());
if (act) {
QString patternPath = act->text().trimmed().split(separator, QString::SkipEmptyParts).first(); // Remove additional information
QString patternName = patternPath.split("//", QString::SkipEmptyParts).last(); // Remove preceding folder names
patternName = patternName.split(".", QString::SkipEmptyParts).first(); // Remove file ending
// Set name and label
m_ui->nameLabel->setText(patternName);
m_ui->imageLabel->setPixmap(act->icon().pixmap(64, 64));
}
}
void ObjectDetectionView::resizeEvent(QResizeEvent * event )
{
if (event->isAccepted()) {
// Enforce square shape of image label
m_ui->imageLabel->resize(m_ui->imageLabel->width(), m_ui->imageLabel->width());
}
}
/*=====================================================================
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 List of detected objects
* @author Benjamin Knecht <mavteam@student.ethz.ch>
* @author Lorenz Meier <mavteam@student.ethz.ch>
* @author Fabian Landau <mavteam@student.ethz.ch>
*
*/
#ifndef _OBJECTDETECTIONVIEW_H_
#define _OBJECTDETECTIONVIEW_H_
#include <QWidget>
#include <QResizeEvent>
#include <QMap>
#include "UASInterface.h"
namespace Ui
{
class ObjectDetectionView;
}
/**
* @brief Lists the detected objects and their confidence
*/
class ObjectDetectionView : public QWidget
{
Q_OBJECT
Q_DISABLE_COPY(ObjectDetectionView)
struct Pattern {
Pattern() : name(QString()), confidence(0.0f), count(0) {}
Pattern(QString name, float confidence) : name(name), confidence(confidence), count(1) {}
bool operator<(const Pattern& other) const {
return this->confidence > other.confidence; // this comparison is intentionally wrong to sort the QList from highest confidence to lowest
}
QString name;
float confidence;
unsigned int count;
};
public:
explicit ObjectDetectionView(QString folder="files/images/patterns", QWidget *parent = 0);
virtual ~ObjectDetectionView();
/** @brief Resize widget contents */
void resizeEvent(QResizeEvent * event );
public slots:
/** @brief Set the UAS this view is currently associated to */
void setUAS(UASInterface* uas);
/** @brief Report new detection */
void newPattern(int uasId, QString patternPath, float confidence, bool detected);
void newLetter(int uasId, QString letter, float confidence, bool detected);
void decreaseLetterTime();
void updateLetterList();
void clearLists();
/** @brief Accept an internal action, update name and preview image label */
void takeAction();
protected:
virtual void changeEvent(QEvent *e);
QMap<QString, Pattern> patternList; ///< The detected patterns with their confidence and detection count
QMap<QString, Pattern> letterList; ///< The detected letters with their confidence and detection count
QTimer letterTimer; ///< A timer to "forget" old letters
UASInterface* uas; ///< The monitored UAS
QString patternFolder; ///< The base folder where pattern images are stored in
const QString separator;
private:
Ui::ObjectDetectionView *m_ui;
};
#endif // _OBJECTDETECTIONVIEW_H_
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ObjectDetectionView</class>
<widget class="QWidget" name="ObjectDetectionView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>246</width>
<height>403</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="1" column="0" colspan="3">
<widget class="QListWidget" name="letterListWidget"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>10</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>110</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>2</width>
<height>2</height>
</size>
</property>
<property name="baseSize">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLabel" name="letterLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>10</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>110</width>
<height>110</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>2</width>
<height>2</height>
</size>
</property>
<property name="baseSize">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 72pt;
color: white;</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>No objects recognized</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="clearButton">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -247,76 +247,5 @@ float colormapJet[128][3] = {
void QGCRGBDView::updateData(UASInterface *uas)
{
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
px::RGBDImage rgbdImage = uas->getRGBDImage();
if (rgbdImage.rows() == 0 || rgbdImage.cols() == 0 || (!rgbEnabled && !depthEnabled))
{
return;
}
QImage fill;
if (rgbEnabled)
{
// fill = QImage(reinterpret_cast<const unsigned char*>(rgbdImage.imagedata1().c_str()),
// rgbdImage.cols(), rgbdImage.rows(), QImage::Format_Mono);
// Construct PGM header
QString header("P5\n%1 %2\n%3\n");
int imgColors = 255;
header = header.arg(rgbdImage.cols()).arg(rgbdImage.rows()).arg(imgColors);
//QByteArray tmpImage(rgbdImage.imagedata1().c_str(), rgbdImage.cols()*rgbdImage.rows());
QByteArray tmpImage(header.toStdString().c_str(), header.toStdString().size());
tmpImage.append(rgbdImage.imagedata1().c_str(), rgbdImage.cols()*rgbdImage.rows());
//qDebug() << "IMAGE SIZE:" << tmpImage.size() << "HEADER SIZE: (15):" << header.size() << "HEADER: " << header;
// if (imageRecBuffer.isNull())
// {
// qDebug()<< "could not convertToPGM()";
// return QImage();
// }
if (!fill.loadFromData(tmpImage, "PGM"))
{
qDebug()<< "could not create extracted image";
// return QImage();
}
}
if (depthEnabled)
{
QByteArray coloredDepth(rgbdImage.cols() * rgbdImage.rows() * 3, 0);
for (uint32_t r = 0; r < rgbdImage.rows(); ++r)
{
const float* depth = reinterpret_cast<const float*>(rgbdImage.imagedata2().c_str() + r * rgbdImage.step2());
uint8_t* pixel = reinterpret_cast<uint8_t*>(coloredDepth.data()) + r * rgbdImage.cols() * 3;
for (uint32_t c = 0; c < rgbdImage.cols(); ++c)
{
if (depth[c] != 0)
{
int idx = fminf(depth[c], 10.0f) / 10.0f * 127.0f;
idx = 127 - idx;
pixel[0] = colormapJet[idx][2] * 255.0f;
pixel[1] = colormapJet[idx][1] * 255.0f;
pixel[2] = colormapJet[idx][0] * 255.0f;
}
pixel += 3;
}
}
fill = QImage(reinterpret_cast<const uchar*>(coloredDepth.constData()),
rgbdImage.cols(), rgbdImage.rows(), QImage::Format_RGB888);
}
glImage = QGLWidget::convertToGLFormat(fill);
#else
Q_UNUSED(uas);
#endif
}
......@@ -78,11 +78,6 @@ WaypointEditableView::WaypointEditableView(Waypoint* wp, QWidget* parent) :
m_ui->comboBox_action->addItem(tr("IF: Delay over"),MAV_CMD_CONDITION_DELAY);
//m_ui->comboBox_action->addItem(tr("IF: Yaw angle is"),MAV_CMD_CONDITION_YAW);
m_ui->comboBox_action->addItem(tr("DO: Jump to Index"),MAV_CMD_DO_JUMP);
#ifdef MAVLINK_ENABLED_PIXHAWK
m_ui->comboBox_action->addItem(tr("NAV: Sweep"),MAV_CMD_NAV_SWEEP);
m_ui->comboBox_action->addItem(tr("Do: Start Search"),MAV_CMD_DO_START_SEARCH);
m_ui->comboBox_action->addItem(tr("Do: Finish Search"),MAV_CMD_DO_FINISH_SEARCH);
#endif
m_ui->comboBox_action->addItem(tr("Other"), MAV_CMD_ENUM_END);
// add frames
......@@ -191,17 +186,6 @@ void WaypointEditableView::updateActionView(int action)
case MAV_CMD_DO_JUMP:
if(MissionDoJumpWidget) MissionDoJumpWidget->show();
break;
#ifdef MAVLINK_ENABLED_PIXHAWK
case MAV_CMD_NAV_SWEEP:
if(MissionNavSweepWidget) MissionNavSweepWidget->show();
break;
case MAV_CMD_DO_START_SEARCH:
if(MissionDoStartSearchWidget) MissionDoStartSearchWidget->show();
break;
case MAV_CMD_DO_FINISH_SEARCH:
if(MissionDoFinishSearchWidget) MissionDoFinishSearchWidget->show();
break;
#endif
default:
if(MissionOtherWidget) MissionOtherWidget->show();
......@@ -305,29 +289,6 @@ void WaypointEditableView::initializeActionView(int actionID)
m_ui->customActionWidget->layout()->addWidget(MissionDoJumpWidget);
}
break;
#ifdef MAVLINK_ENABLED_PIXHAWK
case MAV_CMD_NAV_SWEEP:
if (!MissionNavSweepWidget)
{
MissionNavSweepWidget = new QGCMissionNavSweep(this);
m_ui->customActionWidget->layout()->addWidget(MissionNavSweepWidget);
}
break;
case MAV_CMD_DO_START_SEARCH:
if (!MissionDoStartSearchWidget)
{
MissionDoStartSearchWidget = new QGCMissionDoStartSearch(this);
m_ui->customActionWidget->layout()->addWidget(MissionDoStartSearchWidget);
}
break;
case MAV_CMD_DO_FINISH_SEARCH:
if (!MissionDoFinishSearchWidget)
{
MissionDoFinishSearchWidget = new QGCMissionDoFinishSearch(this);
m_ui->customActionWidget->layout()->addWidget(MissionDoFinishSearchWidget);
}
break;
#endif
case MAV_CMD_ENUM_END:
default:
if (!MissionOtherWidget)
......
......@@ -350,37 +350,6 @@ void WaypointViewOnlyView::updateValues()
m_ui->displayBar->setText(QString("Delay: %1 sec").arg(wp->getParam1()));
break;
}
#ifdef MAVLINK_ENABLED_PIXHAWK
case MAV_CMD_DO_START_SEARCH:
{
m_ui->displayBar->setText(QString("Start searching for pattern. Success when got more than %2 detections with confidence %1").arg(wp->getParam1()).arg(wp->getParam2()));
break;
}
case MAV_CMD_DO_FINISH_SEARCH:
{
m_ui->displayBar->setText(QString("Check if search was successful. yes -> jump to %1, no -> jump to %2. Jumps left: %3").arg(wp->getParam1()).arg(wp->getParam2()).arg(wp->getParam3()));
break;
}
case MAV_CMD_NAV_SWEEP:
{
switch (wp->getFrame())
{
case MAV_FRAME_GLOBAL_RELATIVE_ALT:
case MAV_FRAME_GLOBAL:
{
m_ui->displayBar->setText(QString("Sweep. Corners: <b>(</b>lat <b>%1<sup>o</sup></b>, lon <b>%2<sup>o</sup>)</b> and <b>(</b>lat <b>%3<sup>o</sup></b>, lon <b>%4<sup>o</sup>)</b>; alt: <b>%5</b>; scan radius: %6").arg(wp->getParam3(),0, 'f', 7).arg(wp->getParam4(),0, 'f', 7).arg(wp->getParam5(),0, 'f', 7).arg(wp->getParam6(),0, 'f', 7).arg(wp->getParam7(),0, 'f', 2).arg(wp->getParam1()));
break;
}
case MAV_FRAME_LOCAL_NED:
default:
{
m_ui->displayBar->setText(QString("Sweep. Corners: <b>(%1, %2)</b> and <b>(%3, %4)</b>; z: <b>%5</b>; scan radius: %6").arg(wp->getParam3()).arg(wp->getParam4()).arg(wp->getParam5()).arg(wp->getParam6()).arg(wp->getParam7()).arg(wp->getParam1()));
break;
}
} //end Frame switch
break;
}
#endif
default:
{
m_ui->displayBar->setText(QString("Unknown Command ID (%1) : %2, %3, %4, %5, %6, %7, %8").arg(wp->getAction()).arg(wp->getParam1()).arg(wp->getParam2()).arg(wp->getParam3()).arg(wp->getParam4()).arg(wp->getParam5()).arg(wp->getParam6()).arg(wp->getParam7()));
......
This diff is collapsed.
......@@ -78,10 +78,6 @@ private slots:
void setBirdEyeView(void);
void loadTerrainModel(void);
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
void addOverlay(UASInterface* uas);
#endif
void selectTargetHeading(void);
void selectTarget(void);
void setTarget(void);
......@@ -162,21 +158,6 @@ private:
QMap<int, int>& trailIndexMap);
void updateWaypoints(UASInterface* uas, MAV_FRAME frame,
osg::ref_ptr<WaypointGroupNode>& waypointGroupNode);
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
void updateRGBD(UASInterface* uas, MAV_FRAME frame,
osg::ref_ptr<ImageWindowGeode>& rgbImageNode,
osg::ref_ptr<ImageWindowGeode>& depthImageNode);
void updatePointCloud(UASInterface* uas, MAV_FRAME frame,
double robotX, double robotY, double robotZ,
osg::ref_ptr<osg::Geode>& pointCloudNode,
bool colorPointCloudByDistance);
void updateObstacles(UASInterface* uas, MAV_FRAME frame,
double robotX, double robotY, double robotZ,
osg::ref_ptr<ObstacleGroupNode>& obstacleGroupNode);
void updatePlannedPath(UASInterface* uas, MAV_FRAME frame,
double robotX, double robotY, double robotZ,
osg::ref_ptr<osg::Geode>& plannedPathNode);
#endif
int findWaypoint(const QPoint& mousePos);
bool findTarget(int mouseX, int mouseY);
......
......@@ -96,25 +96,3 @@ SystemContainer::waypointGroupNode(void)
{
return mWaypointGroupNode;
}
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
osg::ref_ptr<ObstacleGroupNode>&
SystemContainer::obstacleGroupNode(void)
{
return mObstacleGroupNode;
}
QMap<QString,osg::ref_ptr<GLOverlayGeode> >&
SystemContainer::overlayNodeMap(void)
{
return mOverlayNodeMap;
}
osg::ref_ptr<osg::Geode>&
SystemContainer::plannedPathNode(void)
{
return mPlannedPathNode;
}
#endif
......@@ -10,11 +10,6 @@
#include "ImageWindowGeode.h"
#include "WaypointGroupNode.h"
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
#include "GLOverlayGeode.h"
#include "ObstacleGroupNode.h"
#endif
class SystemContainer
{
public:
......@@ -39,11 +34,6 @@ public:
osg::ref_ptr<osg::Node>& targetNode(void);
osg::ref_ptr<osg::Geode>& trailNode(void);
osg::ref_ptr<WaypointGroupNode>& waypointGroupNode(void);
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
osg::ref_ptr<ObstacleGroupNode>& obstacleGroupNode(void);
QMap<QString,osg::ref_ptr<GLOverlayGeode> >& overlayNodeMap(void);
osg::ref_ptr<osg::Geode>& plannedPathNode(void);
#endif
private:
QVector3D mGPSLocalOrigin;
......@@ -66,11 +56,6 @@ private:
osg::ref_ptr<osg::Node> mTargetNode;
osg::ref_ptr<osg::Geode> mTrailNode;
osg::ref_ptr<WaypointGroupNode> mWaypointGroupNode;
#if defined(QGC_PROTOBUF_ENABLED) && defined(QGC_USE_PIXHAWK_MESSAGES)
osg::ref_ptr<ObstacleGroupNode> mObstacleGroupNode;
QMap<QString,osg::ref_ptr<GLOverlayGeode> > mOverlayNodeMap;
osg::ref_ptr<osg::Geode> mPlannedPathNode;
#endif
};
#endif // SYSTEMCONTAINER_H
/*=====================================================================
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 WatchdogControl
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include "WatchdogControl.h"
#include "WatchdogView.h"
#include "WatchdogProcessView.h"
#include "ui_WatchdogControl.h"
#include "PxQuadMAV.h"
#include "UASManager.h"
#include <QDebug>
WatchdogControl::WatchdogControl(QWidget *parent) :
QWidget(parent),
mav(NULL),
updateInterval(2000000),
ui(new Ui::WatchdogControl)
{
ui->setupUi(this);
// UI is initialized, setup layout
listLayout = new QVBoxLayout(ui->mainWidget);
listLayout->setSpacing(6);
listLayout->setMargin(0);
listLayout->setAlignment(Qt::AlignTop);
ui->mainWidget->setLayout(listLayout);
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(setUAS(UASInterface*)));
this->setVisible(false);
}
WatchdogControl::~WatchdogControl()
{
delete ui;
}
void WatchdogControl::setUAS(UASInterface* uas)
{
PxQuadMAV* qmav = dynamic_cast<PxQuadMAV*>(uas);
if (qmav) {
connect(qmav, SIGNAL(processReceived(int,int,int,QString,QString,int)), this, SLOT(addProcess(int,int,int,QString,QString,int)));
connect(qmav, SIGNAL(watchdogReceived(int,int,uint)), this, SLOT(updateWatchdog(int,int,uint)));
connect(qmav, SIGNAL(processChanged(int,int,int,int,bool,int,int)), this, SLOT(updateProcess(int,int,int,int,bool,int,int)));
}
}
void WatchdogControl::updateWatchdog(int systemId, int watchdogId, unsigned int processCount)
{
// request the watchdog with the given ID
// Get the watchdog and request the info for it
WatchdogInfo& watchdog = this->getWatchdog(systemId, watchdogId);
// if the proces count doesn't match, the watchdog is either new or has changed - create a new vector with new (and empty) ProcessInfo structs.
if (watchdog.processes_.size() != processCount) {
watchdog.processes_ = std::vector<ProcessInfo>(processCount);
// Create new UI widget
//WatchdogView* view = new WatchdogView(this);
}
// start the timeout timer
//watchdog.timeoutTimer_.reset();
qDebug() << "WATCHDOG RECEIVED";
//qDebug() << "<-- received mavlink_watchdog_heartbeat_t " << msg->sysid << " / " << payload.watchdog_id << " / " << payload.process_count << std::endl;
}
void WatchdogControl::addProcess(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout)
{
// request the watchdog and the process with the given IDs
WatchdogInfo& watchdog = this->getWatchdog(systemId, watchdogId);
ProcessInfo& process = watchdog.getProcess(processId);
// store the process information in the ProcessInfo struct
process.name_ = name.toStdString();
process.arguments_ = arguments.toStdString();
process.timeout_ = timeout;
qDebug() << "PROCESS RECEIVED";
qDebug() << "SYS" << systemId << "WD" << watchdogId << "PROCESS" << processId << name << "ARG" << arguments << "TO" << timeout;
//qDebug() << "<-- received mavlink_watchdog_process_info_t " << msg->sysid << " / " << (const char*)payload.name << " / " << (const char*)payload.arguments << " / " << payload.timeout << std::endl;
}
void WatchdogControl::updateProcess(int systemId, int watchdogId, int processId, int state, bool muted, int crashes, int pid)
{
// request the watchdog and the process with the given IDs
WatchdogInfo& watchdog = this->getWatchdog(systemId, watchdogId);
ProcessInfo& process = watchdog.getProcess(processId);
// store the status information in the ProcessInfo struct
process.state_ = static_cast<ProcessInfo::State::Enum>(state);
process.muted_ = muted;
process.crashes_ = crashes;
process.pid_ = pid;
qDebug() << "PROCESS UPDATED";
qDebug() << "SYS" << systemId << "WD" << watchdogId << "PROCESS" << processId << "STATE" << state << "CRASH" << crashes << "PID" << pid;
//process.updateTimer_.reset();
//qDebug() << "<-- received mavlink_watchdog_process_status_t " << msg->sysid << " / " << payload.state << " / " << payload.muted << " / " << payload.crashes << " / " << payload.pid << std::endl;
}
/**
@brief Returns a WatchdogInfo struct that belongs to the watchdog with the given system-ID and watchdog-ID
*/
WatchdogControl::WatchdogInfo& WatchdogControl::getWatchdog(uint8_t systemId, uint16_t watchdogId)
{
WatchdogID id(systemId, watchdogId);
std::map<WatchdogID, WatchdogInfo>::iterator it = this->watchdogs_.find(id);
if (it != this->watchdogs_.end()) {
// the WatchdogInfo struct already exists in the map, return it
return it->second;
} else {
// the WatchdogInfo struct doesn't exist - request info and status for all processes and create the struct
this->sendCommand(id, WatchdogControl::ALL, Command::RequestInfo);
this->sendCommand(id, WatchdogControl::ALL, Command::RequestStatus);
return this->watchdogs_[id];
}
}
/**
@brief Returns a ProcessInfo struct that belongs to the process with the given ID.
*/
WatchdogControl::ProcessInfo& WatchdogControl::WatchdogInfo::getProcess(uint16_t index)
{
// if the index is out of bounds, resize the vector
if (index >= this->processes_.size())
this->processes_.resize(index + 1);
return this->processes_[index];
}
/**
@brief Sends a watchdog command to a process on a given watchdog.
@param w_id The WatchdogID struct (containing system-ID and watchdog-ID) that identifies the watchdog
@param p_id The process-ID
@param command The command-ID
*/
void WatchdogControl::sendCommand(const WatchdogID& w_id, uint16_t p_id, Command::Enum command)
{
emit sendProcessCommand(w_id.watchdog_id_, p_id, command);
}
void WatchdogControl::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
/*=====================================================================
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 Definition of class WatchdogControl
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef WATCHDOGCONTROL_H
#define WATCHDOGCONTROL_H
#include <inttypes.h>
#include <QWidget>
#include <QTimer>
#include <QVBoxLayout>
#include <map>
#include <string>
#include <sstream>
#include "WatchdogView.h"
#include "UASInterface.h"
namespace Ui
{
class WatchdogControl;
}
/**
* @brief Overall widget for controlling all watchdogs of all connected MAVs
*/
class WatchdogControl : public QWidget
{
Q_OBJECT
public:
///! Command codes, used to send and receive commands over lcm
struct Command {
enum Enum {
Start = 0,
Restart = 1,
Stop = 2,
Mute = 3,
Unmute = 4,
RequestInfo = 254,
RequestStatus = 255
};
};
///! This struct represents a process on the watchdog. Used to store all values.
struct ProcessInfo {
///! Process state - each process is in exactly one of those states (except unknown, that's just to initialize it)
struct State {
enum Enum {
Unknown = 0,
Running = 1,
Stopped = 2,
Stopped_OK = 3,
Stopped_ERROR = 4
};
};
///! Constructor - initialize the values
ProcessInfo() : timeout_(0), state_(State::Unknown), muted_(false), crashes_(0), pid_(-1) {}
std::string name_; ///< The name of the process
std::string arguments_; ///< The arguments (argv of the process)
int32_t timeout_; ///< Heartbeat timeout value (in microseconds)
State::Enum state_; ///< The current state of the process
bool muted_; ///< True if the process is currently muted
uint16_t crashes_; ///< The number of crashes
int32_t pid_; ///< The PID of the process
//quint64_t requestTimeout;
// Timer requestTimer_; ///< Internal timer, used to repeat status and info requests after some time (in case of packet loss)
// Timer updateTimer_; ///< Internal timer, used to measure the time since the last update (used only for graphics)
};
///! This struct identifies a watchdog. It's a combination of system-ID and watchdog-ID. implements operator< to be used as key in a std::map
struct WatchdogID {
///! Constructor - initialize the values
WatchdogID(uint8_t system_id, uint16_t watchdog_id) : system_id_(system_id), watchdog_id_(watchdog_id) {}
uint8_t system_id_; ///< The system-ID
uint16_t watchdog_id_; ///< The watchdog-ID
///! Comparison operator which is used by std::map
inline bool operator<(const WatchdogID& other) const {
return (this->system_id_ != other.system_id_) ? (this->system_id_ < other.system_id_) : (this->watchdog_id_ < other.watchdog_id_);
}
};
///! This struct represents a watchdog
struct WatchdogInfo {
ProcessInfo& getProcess(uint16_t index);
std::vector<ProcessInfo> processes_; ///< A vector containing all processes running on this watchdog
uint64_t timeout;
QTimer* timeoutTimer_; ///< Internal timer, used to measure the time since the last heartbeat message
};
WatchdogControl(QWidget *parent = 0);
~WatchdogControl();
static const uint16_t ALL = (uint16_t)-1; ///< A magic value for a process-ID which addresses "all processes"
static const uint16_t ALL_RUNNING = (uint16_t)-2; ///< A magic value for a process-ID which addresses "all running processes"
static const uint16_t ALL_CRASHED = (uint16_t)-3; ///< A magic value for a process-ID which addresses "all crashed processes"
public slots:
void updateWatchdog(int systemId, int watchdogId, unsigned int processCount);
void addProcess(int systemId, int watchdogId, int processId, QString name, QString arguments, int timeout);
void updateProcess(int systemId, int watchdogId, int processId, int state, bool muted, int crashed, int pid);
void setUAS(UASInterface* uas);
signals:
void sendProcessCommand(int watchdogId, int processId, unsigned int command);
protected:
void changeEvent(QEvent *e);
UASInterface* mav;
QVBoxLayout* listLayout;
uint64_t updateInterval;
private:
Ui::WatchdogControl *ui;
void sendCommand(const WatchdogID& w_id, uint16_t p_id, Command::Enum command);
WatchdogInfo& getWatchdog(uint8_t system_id, uint16_t watchdog_id);
std::map<WatchdogID, WatchdogInfo> watchdogs_; ///< A map containing all watchdogs which are currently active
std::map<WatchdogID, WatchdogView> views;
QTimer updateTimer_;
};
#endif // WATCHDOGCONTROL_H
///! Convert a value to std::string
template <class T>
std::string convertToString(T value)
{
std::ostringstream oss;
oss << value;
return oss.str();
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WatchdogControl</class>
<widget class="QWidget" name="WatchdogControl">
<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>
<layout class="QVBoxLayout" name="verticalLayout" stretch="100,0">
<item>
<widget class="QWidget" name="mainWidget" native="true"/>
</item>
<item>
<widget class="QLabel" name="processInfoLabel">
<property name="text">
<string>0 Processes Core 1: 0% Core 2: 0%</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*=====================================================================
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 WatchdogControl
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include "WatchdogProcessView.h"
#include "ui_WatchdogProcessView.h"
WatchdogProcessView::WatchdogProcessView(int processid, QWidget *parent) :
QWidget(parent),
processid(processid),
m_ui(new Ui::WatchdogProcessView)
{
m_ui->setupUi(this);
}
WatchdogProcessView::~WatchdogProcessView()
{
delete m_ui;
}
void WatchdogProcessView::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
/*=====================================================================
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 Definition of class WatchdogProcessView
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef WATCHDOGPROCESSVIEW_H
#define WATCHDOGPROCESSVIEW_H
#include <QWidget>
#include <QMap>
namespace Ui
{
class WatchdogProcessView;
}
/**
* @brief Represents one process monitored by the linux onboard watchdog
*/
class WatchdogProcessView : public QWidget
{
Q_OBJECT
public:
WatchdogProcessView(int processid, QWidget *parent = 0);
~WatchdogProcessView();
protected:
void changeEvent(QEvent *e);
int processid;
private:
Ui::WatchdogProcessView *m_ui;
};
#endif // WATCHDOGPROCESSVIEW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WatchdogProcessView</class>
<widget class="QWidget" name="WatchdogProcessView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>44</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="pidLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="argumentsLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="startButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="restartButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*=====================================================================
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 WatchdogControl
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#include "WatchdogView.h"
#include "ui_WatchdogView.h"
WatchdogView::WatchdogView(QWidget *parent) :
QWidget(parent),
m_ui(new Ui::WatchdogView)
{
m_ui->setupUi(this);
}
WatchdogView::~WatchdogView()
{
delete m_ui;
}
void WatchdogView::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
/*=====================================================================
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 Definition of class WatchdogView
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef WATCHDOGVIEW_H
#define WATCHDOGVIEW_H
#include <QWidget>
namespace Ui
{
class WatchdogView;
}
/**
* @brief Represents one onboard watchdog
*/
class WatchdogView : public QWidget
{
Q_OBJECT
public:
WatchdogView(QWidget *parent = 0);
~WatchdogView();
protected:
void changeEvent(QEvent *e);
private:
Ui::WatchdogView *m_ui;
};
#endif // WATCHDOGVIEW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WatchdogView</class>
<widget class="QWidget" name="WatchdogView">
<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>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,100">
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Watchdog</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="processListWidget" native="true"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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