Commit 8e3ebca8 authored by pixhawk's avatar pixhawk

Bugfixed log replaying, still working on it

parent b35d8614
...@@ -250,9 +250,9 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw) ...@@ -250,9 +250,9 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
} }
//planeLoc.setLatitude(lat); planeLoc.setLatitude(lat);
//planeLoc.setLongitude(lon); planeLoc.setLongitude(lon);
//planeLoc.setAltitude(alt); planeLoc.setAltitude(alt);
} }
...@@ -297,13 +297,7 @@ function updateFollowAircraft() ...@@ -297,13 +297,7 @@ function updateFollowAircraft()
currView.setRange(currViewRange); currView.setRange(currViewRange);
currView.setTilt(currFollowTilt); currView.setTilt(currFollowTilt);
currFollowHeading = 0;// 0.9*currFollowHeading+0.1*((Math.atan2(lastLat-currLat, lastLon-currLon)/M_PI)+1.0)*360.0; currView.setHeading(currFollowHeading-90.0);
currView.setHeading(currFollowHeading-0.0);
// FIXME Shouldn't update aircraft in here, but works for now
planeLoc.setLatitude(lastLat);
planeLoc.setLongitude(lastLon);
planeLoc.setAltitude(lastAlt);
ge.getView().setAbstractView(currView); ge.getView().setAbstractView(currView);
} }
......
...@@ -189,6 +189,15 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) ...@@ -189,6 +189,15 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv)
QTimer::singleShot(200, mainWindow, SLOT(close())); QTimer::singleShot(200, mainWindow, SLOT(close()));
} }
} }
// forever
// {
// QGC::SLEEP::msleep(5000);
// }
// mainWindow->close();
// mainWindow->deleteLater();
// QGC::SLEEP::msleep(200);
} }
/** /**
......
...@@ -143,11 +143,9 @@ bool LinkManager::disconnectLink(LinkInterface* link) ...@@ -143,11 +143,9 @@ bool LinkManager::disconnectLink(LinkInterface* link)
void LinkManager::removeLink(QObject* link) void LinkManager::removeLink(QObject* link)
{ {
LinkInterface* linkInterface = dynamic_cast<LinkInterface*>(link); LinkInterface* linkInterface = dynamic_cast<LinkInterface*>(link);
// Add link to link list if (linkInterface)
if (links.contains(linkInterface))
{ {
int linkIndex = links.indexOf(linkInterface); removeLink(linkInterface);
links.removeAt(linkIndex);
} }
} }
...@@ -162,6 +160,12 @@ bool LinkManager::removeLink(LinkInterface* link) ...@@ -162,6 +160,12 @@ bool LinkManager::removeLink(LinkInterface* link)
links.removeAt(i); //remove from link list links.removeAt(i); //remove from link list
} }
} }
// Remove link from protocol map
QList<ProtocolInterface* > protocols = protocolLinks.keys(link);
foreach (ProtocolInterface* proto, protocols)
{
protocolLinks.remove(proto, link);
}
return true; return true;
} }
return false; return false;
......
...@@ -34,7 +34,7 @@ This file is part of the PIXHAWK project ...@@ -34,7 +34,7 @@ This file is part of the PIXHAWK project
#include <QThread> #include <QThread>
#include <QList> #include <QList>
#include <QMap> #include <QMultiMap>
#include <LinkInterface.h> #include <LinkInterface.h>
#include <ProtocolInterface.h> #include <ProtocolInterface.h>
...@@ -79,7 +79,7 @@ public slots: ...@@ -79,7 +79,7 @@ public slots:
protected: protected:
LinkManager(); LinkManager();
QList<LinkInterface*> links; QList<LinkInterface*> links;
QMap<ProtocolInterface*,LinkInterface*> protocolLinks; QMultiMap<ProtocolInterface*,LinkInterface*> protocolLinks;
private: private:
static LinkManager* _instance; static LinkManager* _instance;
......
...@@ -97,6 +97,7 @@ MAVLinkSimulationLink::MAVLinkSimulationLink(QString readFile, QString writeFile ...@@ -97,6 +97,7 @@ MAVLinkSimulationLink::MAVLinkSimulationLink(QString readFile, QString writeFile
maxTimeNoise = 0; maxTimeNoise = 0;
this->id = getNextLinkId(); this->id = getNextLinkId();
LinkManager::instance()->add(this); LinkManager::instance()->add(this);
QObject::connect(this, SIGNAL(destroyed(QObject*)), LinkManager::instance(), SLOT(removeLink(QObject*)));
} }
MAVLinkSimulationLink::~MAVLinkSimulationLink() MAVLinkSimulationLink::~MAVLinkSimulationLink()
......
...@@ -956,18 +956,22 @@ void UAS::forwardMessage(mavlink_message_t message) ...@@ -956,18 +956,22 @@ void UAS::forwardMessage(mavlink_message_t message)
{ {
// Emit message on all links that are currently connected // Emit message on all links that are currently connected
QList<LinkInterface*>link_list = LinkManager::instance()->getLinksForProtocol(mavlink); QList<LinkInterface*>link_list = LinkManager::instance()->getLinksForProtocol(mavlink);
foreach(LinkInterface* link, link_list) foreach(LinkInterface* link, link_list)
{ {
SerialLink* serial = dynamic_cast<SerialLink*>(link); if (link)
if(serial != 0)
{ {
SerialLink* serial = dynamic_cast<SerialLink*>(link);
for(int i=0;i<links->size();i++) if(serial != 0)
{ {
if(serial != links->at(i))
for(int i=0;i<links->size();i++)
{ {
qDebug()<<"Forwarding Over link: "<<serial->getName()<<" "<<serial; if(serial != links->at(i))
sendMessage(serial, message); {
qDebug()<<"Forwarding Over link: "<<serial->getName()<<" "<<serial;
sendMessage(serial, message);
}
} }
} }
} }
...@@ -1671,11 +1675,21 @@ void UAS::addLink(LinkInterface* link) ...@@ -1671,11 +1675,21 @@ void UAS::addLink(LinkInterface* link)
if (!links->contains(link)) if (!links->contains(link))
{ {
links->append(link); links->append(link);
connect(link, SIGNAL(destroyed(QObject*)), this, SLOT(removeLink(QObject*)));
} }
//links->append(link); //links->append(link);
//qDebug() << link<<" ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK"; //qDebug() << link<<" ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK ADDED LINK";
} }
void UAS::removeLink(QObject* object)
{
LinkInterface* link = dynamic_cast<LinkInterface*>(object);
if (link)
{
links->removeAt(links->indexOf(link));
}
}
/** /**
* @brief Get the links associated with this robot * @brief Get the links associated with this robot
* *
......
...@@ -223,6 +223,8 @@ public slots: ...@@ -223,6 +223,8 @@ public slots:
/** @brief Add a link associated with this robot */ /** @brief Add a link associated with this robot */
void addLink(LinkInterface* link); void addLink(LinkInterface* link);
/** @brief Remove a link associated with this robot */
void removeLink(QObject* object);
/** @brief Receive a message from one of the communication links. */ /** @brief Receive a message from one of the communication links. */
virtual void receiveMessage(LinkInterface* link, mavlink_message_t message); virtual void receiveMessage(LinkInterface* link, mavlink_message_t message);
......
...@@ -142,9 +142,9 @@ HUD::HUD(int width, int height, QWidget* parent) ...@@ -142,9 +142,9 @@ HUD::HUD(int width, int height, QWidget* parent)
fill.setColor(2, qRgb(0, 0, 0)); fill.setColor(2, qRgb(0, 0, 0));
fill.fill(0); fill.fill(0);
//QString imagePath = MG::DIR::getIconDirectory() + "hud-template.png"; QString imagePath = "/Users/user/Desktop/frame0000.png";
//qDebug() << __FILE__ << __LINE__ << "template image:" << imagePath; qDebug() << __FILE__ << __LINE__ << "template image:" << imagePath;
//fill = QImage(imagePath); fill = QImage(imagePath);
glImage = QGLWidget::convertToGLFormat(fill); glImage = QGLWidget::convertToGLFormat(fill);
......
...@@ -136,5 +136,5 @@ void JoystickWidget::pressKey(int key) ...@@ -136,5 +136,5 @@ void JoystickWidget::pressKey(int key)
void JoystickWidget::updateStatus(const QString& status) void JoystickWidget::updateStatus(const QString& status)
{ {
m_ui->statusLabel->setText(status);
} }
...@@ -23,6 +23,9 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(MAVLinkProtocol* mavlink, QWidget *pare ...@@ -23,6 +23,9 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(MAVLinkProtocol* mavlink, QWidget *pare
ui->setupUi(this); ui->setupUi(this);
ui->gridLayout->setAlignment(Qt::AlignTop); ui->gridLayout->setAlignment(Qt::AlignTop);
// Connect protocol
connect(this, SIGNAL(bytesReady(LinkInterface*,QByteArray)), mavlink, SLOT(receiveBytes(LinkInterface*,QByteArray)));
// Setup timer // Setup timer
connect(&loopTimer, SIGNAL(timeout()), this, SLOT(logLoop())); connect(&loopTimer, SIGNAL(timeout()), this, SLOT(logLoop()));
...@@ -31,9 +34,12 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(MAVLinkProtocol* mavlink, QWidget *pare ...@@ -31,9 +34,12 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(MAVLinkProtocol* mavlink, QWidget *pare
connect(ui->pauseButton, SIGNAL(clicked()), this, SLOT(pause())); connect(ui->pauseButton, SIGNAL(clicked()), this, SLOT(pause()));
connect(ui->playButton, SIGNAL(clicked()), this, SLOT(play())); connect(ui->playButton, SIGNAL(clicked()), this, SLOT(play()));
connect(ui->speedSlider, SIGNAL(valueChanged(int)), this, SLOT(setAccelerationFactorInt(int))); connect(ui->speedSlider, SIGNAL(valueChanged(int)), this, SLOT(setAccelerationFactorInt(int)));
connect(ui->positionSlider, SIGNAL(valueChanged(int)), this, SLOT(jumpToSliderVal(int)));
connect(ui->positionSlider, SIGNAL(sliderPressed()), this, SLOT(pause()));
setAccelerationFactorInt(49); setAccelerationFactorInt(49);
ui->speedSlider->setValue(49); ui->speedSlider->setValue(49);
ui->positionSlider->setValue(ui->positionSlider->minimum());
} }
QGCMAVLinkLogPlayer::~QGCMAVLinkLogPlayer() QGCMAVLinkLogPlayer::~QGCMAVLinkLogPlayer()
...@@ -47,8 +53,10 @@ void QGCMAVLinkLogPlayer::play() ...@@ -47,8 +53,10 @@ void QGCMAVLinkLogPlayer::play()
{ {
ui->pauseButton->setChecked(false); ui->pauseButton->setChecked(false);
ui->selectFileButton->setEnabled(false); ui->selectFileButton->setEnabled(false);
if (logLink != NULL) if (logLink)
{ {
logLink->disconnect();
LinkManager::instance()->removeLink(logLink);
delete logLink; delete logLink;
} }
logLink = new MAVLinkSimulationLink(""); logLink = new MAVLinkSimulationLink("");
...@@ -74,18 +82,44 @@ void QGCMAVLinkLogPlayer::pause() ...@@ -74,18 +82,44 @@ void QGCMAVLinkLogPlayer::pause()
loopTimer.stop(); loopTimer.stop();
ui->playButton->setChecked(false); ui->playButton->setChecked(false);
ui->selectFileButton->setEnabled(true); ui->selectFileButton->setEnabled(true);
delete logLink; if (logLink)
logLink = NULL; {
logLink->disconnect();
LinkManager::instance()->removeLink(logLink);
delete logLink;
logLink = NULL;
}
} }
void QGCMAVLinkLogPlayer::reset() bool QGCMAVLinkLogPlayer::reset(int packetIndex)
{ {
pause(); // Reset only for valid values
loopCounter = 0; if (packetIndex >= 0 && packetIndex <= logFile.size() - (packetLen+timeLen))
logFile.reset(); {
ui->pauseButton->setChecked(true); bool result = true;
ui->progressBar->setValue(0); pause();
startTime = 0; loopCounter = 0;
logFile.reset();
if (!logFile.seek(packetIndex*(timeLen + packetLen)))
{
// Fallback: Start from scratch
logFile.reset();
ui->logStatsLabel->setText(tr("Changing packet index failed, back to start."));
result = false;
}
ui->pauseButton->setChecked(true);
ui->positionSlider->blockSignals(true);
int sliderVal = (packetIndex / (double)(logFile.size()/(packetLen+timeLen))) * (ui->positionSlider->maximum() - ui->positionSlider->minimum());
ui->positionSlider->setValue(sliderVal);
ui->positionSlider->blockSignals(false);
startTime = 0;
return result;
}
else
{
return false;
}
} }
void QGCMAVLinkLogPlayer::selectLogFile() void QGCMAVLinkLogPlayer::selectLogFile()
...@@ -129,8 +163,7 @@ void QGCMAVLinkLogPlayer::loadLogFile(const QString& file) ...@@ -129,8 +163,7 @@ void QGCMAVLinkLogPlayer::loadLogFile(const QString& file)
// Ensure that the playback process is stopped // Ensure that the playback process is stopped
if (logFile.isOpen()) if (logFile.isOpen())
{ {
loopTimer.stop(); pause();
logFile.reset();
logFile.close(); logFile.close();
} }
logFile.setFileName(file); logFile.setFileName(file);
...@@ -146,15 +179,52 @@ void QGCMAVLinkLogPlayer::loadLogFile(const QString& file) ...@@ -146,15 +179,52 @@ void QGCMAVLinkLogPlayer::loadLogFile(const QString& file)
logFile.reset(); logFile.reset();
startTime = 0; startTime = 0;
ui->logFileNameLabel->setText(tr("%1").arg(logFileInfo.baseName())); ui->logFileNameLabel->setText(tr("%1").arg(logFileInfo.baseName()));
ui->logStatsLabel->setText(tr("Log: %2 MB, %3 packets").arg(logFileInfo.size()/1000000.0f, 0, 'f', 2).arg(logFileInfo.size()/(MAVLINK_MAX_PACKET_LEN+sizeof(quint64))));
// Get the time interval from the logfile
QByteArray timestamp = logFile.read(timeLen);
// First timestamp
quint64 starttime = *((quint64*)(timestamp.constData()));
// Last timestamp
logFile.seek(logFile.size()-packetLen-timeLen);
QByteArray timestamp2 = logFile.read(timeLen);
quint64 endtime = *((quint64*)(timestamp2.constData()));
// Reset everything
logFile.reset();
qDebug() << "Starttime:" << starttime << "End:" << endtime;
// WARNING: Order matters in this computation
int seconds = (endtime - starttime)/1000000;
int minutes = seconds / 60;
int hours = minutes / 60;
seconds -= 60*minutes;
minutes -= 60*hours;
QString timelabel = tr("%1h:%2m:%3s").arg(hours, 2).arg(minutes, 2).arg(seconds, 2);
ui->logStatsLabel->setText(tr("%2 MB, %3 packets, %4").arg(logFileInfo.size()/1000000.0f, 0, 'f', 2).arg(logFileInfo.size()/(MAVLINK_MAX_PACKET_LEN+sizeof(quint64))).arg(timelabel));
} }
} }
union log64 /**
* Jumps to the current percentage of the position slider
*/
void QGCMAVLinkLogPlayer::jumpToSliderVal(int slidervalue)
{ {
quint64 q; loopTimer.stop();
const char* b; // Set the logfile to the correct percentage and
}; // align to the timestamp values
int packetCount = logFile.size() / (packetLen + timeLen);
int packetIndex = (packetCount - 1) * (slidervalue / (double)(ui->positionSlider->maximum() - ui->positionSlider->minimum()));
// Do only accept valid jumps
if (reset(packetIndex))
{
ui->logStatsLabel->setText(tr("Jumped to packet %1").arg(packetIndex));
//qDebug() << "SET POSITION TO PACKET:" << packetIndex;
}
}
/** /**
* This function is the "mainloop" of the log player, reading one line * This function is the "mainloop" of the log player, reading one line
...@@ -166,8 +236,6 @@ union log64 ...@@ -166,8 +236,6 @@ union log64
*/ */
void QGCMAVLinkLogPlayer::logLoop() void QGCMAVLinkLogPlayer::logLoop()
{ {
const int packetLen = MAVLINK_MAX_PACKET_LEN;
const int timeLen = sizeof(quint64);
bool ok; bool ok;
// First check initialization // First check initialization
...@@ -207,7 +275,7 @@ void QGCMAVLinkLogPlayer::logLoop() ...@@ -207,7 +275,7 @@ void QGCMAVLinkLogPlayer::logLoop()
QByteArray packet = chunk.mid(0, packetLen); QByteArray packet = chunk.mid(0, packetLen);
// Emit this packet // Emit this packet
mavlink->receiveBytes(logLink, packet); emit bytesReady(logLink, packet);
// Check if reached end of file before reading next timestamp // Check if reached end of file before reading next timestamp
if (chunk.length() < timeLen+packetLen || logFile.atEnd()) if (chunk.length() < timeLen+packetLen || logFile.atEnd())
...@@ -217,7 +285,6 @@ void QGCMAVLinkLogPlayer::logLoop() ...@@ -217,7 +285,6 @@ void QGCMAVLinkLogPlayer::logLoop()
QString status = tr("Reached end of MAVLink log file."); QString status = tr("Reached end of MAVLink log file.");
ui->logStatsLabel->setText(status); ui->logStatsLabel->setText(status);
ui->progressBar->setValue(100);
MainWindow::instance()->showStatusMessage(status); MainWindow::instance()->showStatusMessage(status);
return; return;
} }
...@@ -265,9 +332,11 @@ void QGCMAVLinkLogPlayer::logLoop() ...@@ -265,9 +332,11 @@ void QGCMAVLinkLogPlayer::logLoop()
if (loopCounter % 40 == 0) if (loopCounter % 40 == 0)
{ {
QFileInfo logFileInfo(logFile); QFileInfo logFileInfo(logFile);
int progress = 100.0f*(loopCounter/(float)(logFileInfo.size()/(MAVLINK_MAX_PACKET_LEN+sizeof(quint64)))); int progress = (ui->positionSlider->maximum()-ui->positionSlider->minimum())*(logFile.pos()/static_cast<float>(logFileInfo.size()));
//qDebug() << "Progress:" << progress; //qDebug() << "Progress:" << progress;
ui->progressBar->setValue(progress); ui->positionSlider->blockSignals(true);
ui->positionSlider->setValue(progress);
ui->positionSlider->blockSignals(false);
} }
loopCounter++; loopCounter++;
// Ui update: Only every 20 messages // Ui update: Only every 20 messages
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <QFile> #include <QFile>
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
#include "LinkInterface.h"
#include "MAVLinkSimulationLink.h" #include "MAVLinkSimulationLink.h"
namespace Ui { namespace Ui {
...@@ -32,16 +33,22 @@ public slots: ...@@ -32,16 +33,22 @@ public slots:
/** @brief Pause the logfile */ /** @brief Pause the logfile */
void pause(); void pause();
/** @brief Reset the logfile */ /** @brief Reset the logfile */
void reset(); bool reset(int packetIndex=0);
/** @brief Select logfile */ /** @brief Select logfile */
void selectLogFile(); void selectLogFile();
/** @brief Load log file */ /** @brief Load log file */
void loadLogFile(const QString& file); void loadLogFile(const QString& file);
/** @brief Jump to a position in the logfile */
void jumpToSliderVal(int slidervalue);
/** @brief The logging mainloop */ /** @brief The logging mainloop */
void logLoop(); void logLoop();
/** @brief Set acceleration factor in percent */ /** @brief Set acceleration factor in percent */
void setAccelerationFactorInt(int factor); void setAccelerationFactorInt(int factor);
signals:
/** @brief Send ready bytes */
void bytesReady(LinkInterface* link, const QByteArray& bytes);
protected: protected:
int lineCounter; int lineCounter;
int totalLines; int totalLines;
...@@ -54,6 +61,8 @@ protected: ...@@ -54,6 +61,8 @@ protected:
QFile logFile; QFile logFile;
QTimer loopTimer; QTimer loopTimer;
int loopCounter; int loopCounter;
static const int packetLen = MAVLINK_MAX_PACKET_LEN;
static const int timeLen = sizeof(quint64);
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
private: private:
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>407</width> <width>407</width>
<height>144</height> <height>152</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,10,10,1,1,0"> <layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0,0,0">
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>12</number> <number>12</number>
</property> </property>
...@@ -101,22 +101,6 @@ ...@@ -101,22 +101,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="6">
<widget class="QProgressBar" name="progressBar">
<property name="toolTip">
<string>Percent of the logfile replayed</string>
</property>
<property name="statusTip">
<string>Percent of the logfile replayed</string>
</property>
<property name="whatsThis">
<string>Percent of the logfile replayed</string>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="speedLabel"> <widget class="QLabel" name="speedLabel">
<property name="toolTip"> <property name="toolTip">
...@@ -156,6 +140,22 @@ ...@@ -156,6 +140,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="6">
<widget class="QSlider" name="positionSlider">
<property name="maximum">
<number>10000</number>
</property>
<property name="pageStep">
<number>100</number>
</property>
<property name="tracking">
<bool>false</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>
......
...@@ -46,50 +46,50 @@ void MAV2DIcon::setYaw(float yaw) ...@@ -46,50 +46,50 @@ void MAV2DIcon::setYaw(float yaw)
void MAV2DIcon::drawIcon(QPen* pen) void MAV2DIcon::drawIcon(QPen* pen)
{ {
mypixmap = new QPixmap(radius+1, radius+1); // mypixmap = new QPixmap(radius+1, radius+1);
mypixmap->fill(Qt::transparent); // mypixmap->fill(Qt::transparent);
QPainter painter(mypixmap); // QPainter painter(mypixmap);
// DRAW WAYPOINT // // DRAW WAYPOINT
QPointF p(radius/2, radius/2); // QPointF p(radius/2, radius/2);
float waypointSize = radius; // float waypointSize = radius;
QPolygonF poly(4); // QPolygonF poly(4);
// Top point // // Top point
poly.replace(0, QPointF(p.x(), p.y()-waypointSize/2.0f)); // poly.replace(0, QPointF(p.x(), p.y()-waypointSize/2.0f));
// Right point // // Right point
poly.replace(1, QPointF(p.x()+waypointSize/2.0f, p.y())); // poly.replace(1, QPointF(p.x()+waypointSize/2.0f, p.y()));
// Bottom point // // Bottom point
poly.replace(2, QPointF(p.x(), p.y() + waypointSize/2.0f)); // poly.replace(2, QPointF(p.x(), p.y() + waypointSize/2.0f));
poly.replace(3, QPointF(p.x() - waypointSize/2.0f, p.y())); // poly.replace(3, QPointF(p.x() - waypointSize/2.0f, p.y()));
// // Select color based on if this is the current waypoint //// // Select color based on if this is the current waypoint
// if (list.at(i)->getCurrent()) //// if (list.at(i)->getCurrent())
//// {
//// color = QGC::colorCyan;//uas->getColor();
//// pen.setWidthF(refLineWidthToPen(0.8f));
//// }
//// else
//// {
//// color = uas->getColor();
//// pen.setWidthF(refLineWidthToPen(0.4f));
//// }
// //pen.setColor(color);
// if (pen)
// { // {
// color = QGC::colorCyan;//uas->getColor(); // pen->setWidthF(2);
// pen.setWidthF(refLineWidthToPen(0.8f)); // painter.setPen(*pen);
// } // }
// else // else
// { // {
// color = uas->getColor(); // QPen pen2(Qt::red);
// pen.setWidthF(refLineWidthToPen(0.4f)); // pen2.setWidth(2);
// painter.setPen(pen2);
// } // }
// painter.setBrush(Qt::NoBrush);
//pen.setColor(color); // float rad = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f));
if (pen) // painter.drawLine(p.x(), p.y(), p.x()+sin(yaw) * radius, p.y()-cos(yaw) * rad);
{ // painter.drawPolygon(poly);
pen->setWidthF(2);
painter.setPen(*pen);
}
else
{
QPen pen2(Qt::red);
pen2.setWidth(2);
painter.setPen(pen2);
}
painter.setBrush(Qt::NoBrush);
float rad = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f));
painter.drawLine(p.x(), p.y(), p.x()+sin(yaw) * radius, p.y()-cos(yaw) * rad);
painter.drawPolygon(poly);
} }
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