修改回放

This commit is contained in:
hm
2020-12-15 13:47:14 +08:00
parent 543dd019f9
commit 5018a2ab56
18 changed files with 1629 additions and 804 deletions
+6
View File
@@ -286,6 +286,12 @@ void CommandBox::commandAccepted(bool flag,uint16_t command,uint8_t result)
case MAV_RESULT_IN_PROGRESS:
string.append(tr("%1,%2 being executed").arg(command).arg(m_name));
break;
case 0xFE:
string.append(tr("%1,%2 time out").arg(command).arg(m_name));
break;
case 0xFF:
string.append(tr("Please do not operate too fast, the last instruction has not been sent"));
break;
default:
break;
}
+11
View File
@@ -323,6 +323,8 @@ void CommandUI::setSecondConfirm(QVariant value)
btn->setProperty("state",state::failure);
btn->style()->unpolish(btn);
btn->style()->polish(btn);
emit showMessage(tr("发送指令 %1 %2").arg(btn->Command().toString()).arg(btn->text()));
}
}
}
@@ -377,6 +379,9 @@ void CommandUI::setSecondValue(QVariant value)
btn->setProperty("state",state::failure);
btn->style()->unpolish(btn);
btn->style()->polish(btn);
emit showMessage(tr("发送指令 %1 %2").arg(btn->Command().toString()).arg(btn->text()));
}
}
}
@@ -613,6 +618,12 @@ void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
case MAV_RESULT_IN_PROGRESS:
string.append(tr("%1,%2 being executed").arg(command).arg(btn_name));
break;
case 0xFE:
string.append(tr("%1,%2 time out").arg(command).arg(btn_name));
break;
case 0xFF:
string.append(tr("Please do not operate too fast, the last instruction has not been sent"));
break;
default:
break;
}
BIN
View File
Binary file not shown.
+1239 -738
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -266,9 +266,9 @@ void MenuBarUI::setTargetPoint(int Value)
ui->label_TargetPoint->setText(QString::number(Value,'f',0));
}
void MenuBarUI::setTargetAlt(float Value)
void MenuBarUI::setTargetAlt(QVariant Value)
{
ui->label_TargteAlt->setText(QString::number(Value));
ui->label_TargteAlt->setText(Value.toString());
}
void MenuBarUI::setX(float Value)
@@ -281,9 +281,9 @@ void MenuBarUI::setwp_Dist(float Value)
ui->label_wp_Dist->setText(QString::number(Value,'f',2));
}
void MenuBarUI::setTagetAirspeed(float Value)
void MenuBarUI::setTagetAirspeed(QVariant Value)
{
ui->label_TargetAirSpeed->setText(QString::number(Value,'f',1));
ui->label_TargetAirSpeed->setText(Value.toString());
}
void MenuBarUI::setFlightTime(QTime Value)
+2 -2
View File
@@ -45,10 +45,10 @@ public slots:
void setTargetPoint(int Value);
void setTargetAlt(float Value);
void setTargetAlt(QVariant Value);
void setX(float Value);
void setwp_Dist(float Value);
void setTagetAirspeed(float Value);
void setTagetAirspeed(QVariant Value);
void setFlightTime(QTime Value);
signals:
+2 -2
View File
@@ -308,7 +308,7 @@
<item row="1" column="4">
<widget class="QLabel" name="label_5">
<property name="text">
<string>INS2时间</string>
<string>INS2日期</string>
</property>
</widget>
</item>
@@ -328,7 +328,7 @@
<item row="2" column="4">
<widget class="QLabel" name="label_9">
<property name="text">
<string>目标空速</string>
<string>INS2时间</string>
</property>
</widget>
</item>
+43
View File
@@ -21,6 +21,16 @@ Tools_Index2::Tools_Index2(QWidget *parent) :
ui->pushButton_Play->setFixedSize(150,50);
ui->pushButton_LastFrame->setFixedSize(150,50);
ui->pushButton_NextFrame->setFixedSize(150,50);
ui->comboBox_MultiSpeed->addItem("X1",1000);
ui->comboBox_MultiSpeed->addItem("X2",500);
ui->comboBox_MultiSpeed->addItem("X5",200);
ui->comboBox_MultiSpeed->addItem("X10",100);
//ui->comboBox_MultiSpeed->addItem("X100",10);
}
@@ -91,6 +101,7 @@ void Tools_Index2::on_pushButton_file_clicked()
ui->pushButton_file->setText(fileName);
PlayState = false;
emit setPlay(PlayState);//暂停播放,跟底层关联起来
emit setFileName(fileName);
@@ -109,6 +120,7 @@ void Tools_Index2::resizeEvent(QResizeEvent *event)
void Tools_Index2::setCurrentPercentage(float value)
{
ui->horizontalSlider->setValue(value * ui->horizontalSlider->maximum());
ui->doubleSpinBox_Percent->setValue(value * 100);
}
void Tools_Index2::ReplayComplete()
@@ -149,6 +161,7 @@ void Tools_Index2::on_horizontalSlider_sliderMoved(int position)
{
isMove = true;
//设置比例
//qDebug() << (float)position/ui->horizontalSlider->maximum();
emit setPercentage((float)position/ui->horizontalSlider->maximum());
}
@@ -169,3 +182,33 @@ void Tools_Index2::on_pushButton_Play_clicked()
}
}
void Tools_Index2::on_comboBox_MultiSpeed_currentIndexChanged(int index)
{
//qDebug() << ui->comboBox_MultiSpeed->currentData(Qt::UserRole).toDouble();
emit setMultiple(ui->comboBox_MultiSpeed->currentData(Qt::UserRole).toDouble());
}
void Tools_Index2::on_pushButton_NextFrame_clicked()
{
}
void Tools_Index2::on_pushButton_LastFrame_clicked()
{
}
void Tools_Index2::on_doubleSpinBox_Percent_valueChanged(double arg1)
{
//emit setPercentage(arg1);
}
void Tools_Index2::on_pushButton_setPercent_clicked()
{
double p = ui->doubleSpinBox_setPercent->value() * 0.01;
qDebug() << "p" << p;
emit setPercentage(p);
}
+15
View File
@@ -55,6 +55,16 @@ private slots:
void on_pushButton_Play_clicked();
void on_comboBox_MultiSpeed_currentIndexChanged(int index);
void on_pushButton_NextFrame_clicked();
void on_pushButton_LastFrame_clicked();
void on_doubleSpinBox_Percent_valueChanged(double arg1);
void on_pushButton_setPercent_clicked();
signals:
void setFileName(QString name);
@@ -67,6 +77,11 @@ signals:
void setPosition(int position);
void setPercentage(float p);
void setMultiple(double times);
void setFrame(int index);
private:
Ui::Tools_Index2 *ui;
QWidget *m_parent;
+116 -14
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>520</width>
<height>174</height>
<width>387</width>
<height>355</height>
</rect>
</property>
<property name="windowTitle">
@@ -35,8 +35,8 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_Play">
<item row="4" column="1">
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>150</width>
@@ -44,11 +44,34 @@
</size>
</property>
<property name="text">
<string>Play</string>
<string>倍速</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="1" colspan="3">
<widget class="QSlider" name="horizontalSlider">
<property name="maximum">
<number>10000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBox_setPercent">
<property name="decimals">
<number>6</number>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.000001000000000</double>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -61,17 +84,20 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QSlider" name="horizontalSlider">
<property name="maximum">
<number>10000</number>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_LastFrame">
<property name="maximumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="text">
<string>上一帧</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<item row="0" column="0" colspan="5">
<widget class="QPushButton" name="pushButton_file">
<property name="minimumSize">
<size>
@@ -84,7 +110,36 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="3" column="3">
<widget class="QPushButton" name="pushButton_NextFrame">
<property name="maximumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>下一帧</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<widget class="QComboBox" name="comboBox_MultiSpeed">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
</widget>
</item>
<item row="1" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -97,6 +152,53 @@
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pushButton_Play">
<property name="maximumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>Play</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBox_Percent">
<property name="decimals">
<number>6</number>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep">
<double>0.000001000000000</double>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QPushButton" name="pushButton_setPercent">
<property name="text">
<string>setPercent</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>百分比</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>设置百分比</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
+18 -3
View File
@@ -211,12 +211,22 @@ MainWindow::MainWindow(QWidget *parent)
connect(toolsui->index2,SIGNAL(setPercentage(float)),
dlink->mavlinknode->replay,SLOT(setPercentage(float)),Qt::DirectConnection);
connect(toolsui->index2,SIGNAL(setMultiple(double)),
dlink->mavlinknode->replay,SLOT(setMultiple(double)),Qt::DirectConnection);
connect(dlink->mavlinknode->replay,SIGNAL(currentPercentage(float)),
toolsui->index2,SLOT(setCurrentPercentage(float)),Qt::DirectConnection);
connect(dlink->mavlinknode->replay,SIGNAL(replayComplete()),
toolsui->index2,SLOT(ReplayComplete()),Qt::DirectConnection);
//setting ----- map
connect(setting->index0->mapsetting,SIGNAL(getMapTypes()),
map,SLOT(getMapTypes()));
@@ -1153,14 +1163,19 @@ void MainWindow::updateUI()//事件驱动式更新数据
dlink->mavlinknode->vehicle.attitude.yaw * 57.3);
menuBarUI->setTargetAlt(dlink->mavlinknode->vehicle.ins2.time);
uint64_t time = ((uint64_t)dlink->mavlinknode->vehicle.ins2.time)% 1000000;
uint64_t date = ((uint64_t)dlink->mavlinknode->vehicle.ins2.time)/ 1000000;
//qDebug() << time << date << (uint64_t)dlink->mavlinknode->vehicle.ins2.time;
menuBarUI->setTargetAlt(date);
menuBarUI->setTagetAirspeed(time);
menuBarUI->setX(dlink->mavlinknode->vehicle.nav_controller_output.xtrack_error);
menuBarUI->setwp_Dist(((float)dlink->mavlinknode->vehicle.nav_controller_output.wp_dist) * 0.001);
menuBarUI->setTagetAirspeed(dlink->mavlinknode->vehicle.emb_atom_com.Airspeed
+dlink->mavlinknode->vehicle.nav_controller_output.aspd_error);
+36 -17
View File
@@ -7,6 +7,9 @@
commandprocess::commandprocess(QObject *parent) : QObject(parent)
{
setRunFrq(10);
status.m_Mode = Nop_Mode;
}
@@ -105,6 +108,8 @@ void commandprocess::WriteCmd_int(uint8_t m_sysid, uint8_t m_compid ,
int32_t y,
float z, uint16_t command, uint8_t frame, uint8_t current, uint8_t autocontinue)
{
if(status.m_Mode == Nop_Mode)
{
//给指令赋值
cmd_int.param1 = param1;
cmd_int.param2 = param2;
@@ -123,7 +128,13 @@ void commandprocess::WriteCmd_int(uint8_t m_sysid, uint8_t m_compid ,
status.transmit.type = 0;
status.m_Mode = TransmitMode;//发送模式
//start();//开启线程
start();//开启线程
}
else
{
emit commandAccepted(true,command,0xFF);//广播指令反馈
//emit showMessage("Please do not operate too fast");
}
}
@@ -131,22 +142,30 @@ void commandprocess::WriteCmd_int(uint8_t m_sysid, uint8_t m_compid ,
void commandprocess::WriteCmd_long(float param1, float param2, float param3, float param4, float param5, float param6, float param7, uint16_t command, uint8_t confirmation)
{
//给指令赋值
cmd_long.param1 = param1;
cmd_long.param2 = param2;
cmd_long.param3 = param3;
cmd_long.param4 = param4;
cmd_long.param5 = param5;
cmd_long.param6 = param6;
cmd_long.param7 = param7;
if(status.m_Mode == Nop_Mode)
{
//给指令赋值
cmd_long.param1 = param1;
cmd_long.param2 = param2;
cmd_long.param3 = param3;
cmd_long.param4 = param4;
cmd_long.param5 = param5;
cmd_long.param6 = param6;
cmd_long.param7 = param7;
cmd_long.command = command;
cmd_long.confirmation = confirmation;
cmd_long.command = command;
cmd_long.confirmation = confirmation;
//开启线程开始传输
status.m_Mode = TransmitMode;//发送模式
status.transmit.type = 1;
start();//开启线程
//开启线程开始传输
status.m_Mode = TransmitMode;//发送模式
status.transmit.type = 1;
start();//开启线程
}
else
{
emit commandAccepted(true,command,0xFF);//广播指令反馈
//emit showMessage("Please do not operate too fast");
}
}
//这个函数类似中断,专门处理接收到的状态
@@ -262,7 +281,7 @@ void commandprocess::WriteStateMachine(void)
//清除指令
if(status.transmit.type == 0)
{
emit commandAccepted(false,cmd_int.command,MAV_RESULT::MAV_RESULT_FAILED);
emit commandAccepted(false,cmd_int.command,0xFE);//超时
cmd_int.param1 = 0;
cmd_int.param2 = 0;
@@ -278,7 +297,7 @@ void commandprocess::WriteStateMachine(void)
}
else if(status.transmit.type == 1)
{
emit commandAccepted(false,cmd_long.command,MAV_RESULT::MAV_RESULT_FAILED);
emit commandAccepted(false,cmd_long.command,0xFE);//超时
cmd_long.param1 = 0;
cmd_long.param2 = 0;
+50 -10
View File
@@ -121,13 +121,26 @@ MavLinkNode::~MavLinkNode()
logTimer = nullptr;
}
if(timer_1s)
{
timer_1s->stop();
delete timer_1s;
timer_1s = nullptr;
}
//停止回放
if(replay)
{
replay->stop();
delete replay;
replay = nullptr;
if(replay->isActive())
{
replay->stop();
QThread::msleep(10);
delete replay;
replay = nullptr;
}
}
//停止任务
@@ -136,6 +149,7 @@ MavLinkNode::~MavLinkNode()
if(Mission->isActive())
{
Mission->stop();
QThread::msleep(10);
delete Mission;
Mission = nullptr;
}
@@ -147,6 +161,7 @@ MavLinkNode::~MavLinkNode()
if(Parameter->isActive())
{
Parameter->stop();
QThread::msleep(10);
delete Parameter;
Parameter = nullptr;
}
@@ -157,6 +172,7 @@ MavLinkNode::~MavLinkNode()
if(Commander->isActive())
{
Commander->stop();//可能还没停止线程,后面不能紧跟着删除
QThread::msleep(10);
delete Commander;
Commander = nullptr;
}
@@ -167,6 +183,7 @@ MavLinkNode::~MavLinkNode()
if(Status->isActive())
{
Status->stop();//可能还没停止线程,后面不能紧跟着删除
QThread::msleep(10);
delete Status;
Status = nullptr;
}
@@ -186,8 +203,8 @@ MavLinkNode::~MavLinkNode()
}
QThread::msleep(200);
QThread::msleep(50);
delete thread;
thread = nullptr;
@@ -258,7 +275,7 @@ void MavLinkNode::start()
logTimer = new QTimer();
logTimer->setInterval(1 * 60 * 1000);//5min
logTimer->setInterval(2 * 10 * 1000);//10s
connect(logTimer,&QTimer::timeout,
this,&MavLinkNode::LogTimerOut,Qt::DirectConnection);
@@ -434,10 +451,11 @@ void MavLinkNode::LogTimerOut(void)
//mavLogFile->bytesToWrite();
//if(!mavLogFile->flush())
{
//{
//qDebug() << "bittotal" << bittotal;
mavLogFile->close();
mavLogFile->open(QIODevice::Append);
}
//}
}
}
@@ -606,12 +624,33 @@ void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram)
uint16_t len = mavlink_msg_to_send_buffer(buff+sizeof(quint64), &msg);
if (mavLogFile)
{
mavLogFile->write((const char *)buff, len+sizeof(quint64));
if(mavLogFile->isOpen())
{
if(databuff.size() > 0)
{
mavLogFile->write(databuff);
mavLogFile->write((const char *)buff, len+sizeof(quint64));
qDebug() << "buff size > 0,write buff to file ;"
<< databuff.size();
databuff.clear();
}
else
{
mavLogFile->write((const char *)buff, len+sizeof(quint64));
}
}
else
{
databuff.append((const char *)buff, len+sizeof(quint64));
qDebug() << "file is open ,data write to buff";
}
}
//mavLogFile->size()
count++;
if(msg.sysid < 250) //过滤地面站发过来的数据
@@ -676,6 +715,7 @@ void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram)
case MAVLINK_PARSE_STATE_GOT_BAD_CRC1:{
parserFailure += 1;
qDebug() << "MAVLINK_PARSE_STATE_GOT_BAD_CRC1";
emit showMessage("mavlink parse CRC error");
}break;
case MAVLINK_PARSE_STATE_SIGNATURE_WAIT:{
qDebug() << "MAVLINK_PARSE_STATE_SIGNATURE_WAIT";
+6
View File
@@ -13,6 +13,9 @@
#include "commandprocess.h"
#include "statusprocess.h"
#ifdef QtMavlinkNode
#include <mavlinknodeglobal.h>
class MAVLINKNODESHARED_EXPORT MavLinkNode : public QObject {
@@ -201,6 +204,9 @@ protected:
QTimer *timer = nullptr;
QByteArray databuff;
_buffdef serial_buff;
_buffdef client_buff;
+49 -8
View File
@@ -71,7 +71,9 @@ void Replay::start()
}
else
{
qWarning() << "log file can't be fund";
running_flag = true;
thread->start();
qDebug() << "thread start" << running_flag;
}
}
else
@@ -167,7 +169,8 @@ void Replay::process()//线程函数
if((currentTimestamp - lastTimestamp) >0)
{
QThread::msleep(timeStamp);
QThread::usleep(timeStamp * multiple);
}
position += (uint8_t)raw.at(raw.indexOf(0xFD)+1) + 20;
@@ -240,11 +243,43 @@ QByteArray Replay::readAll(void)
void Replay::setLogfile(const QString name, float percent)
{
logFile = name;
//重置各种参数
percentage = percent;
ispause = false;
isplaying = false;
if(name != logFile)
{
logFile = name;
//重置各种参数
percentage = 0;
ispause = false;
isplaying = false;
//emit currentPercentage(percentage);
//emit readReady();
if(!file)
{
file = new QFile();
file->setFileName(logFile);
if(!file->open(QIODevice::ReadOnly))
{
if(!logFile.isEmpty())
{
QMessageBox::warning(nullptr,
tr("Error"),
tr("%1").arg(file->errorString()));
}
delete file;
file = nullptr;
}
}
}
else
{
logFile = name;
//重置各种参数
percentage = percent;
ispause = false;
isplaying = false;
}
qDebug() << name << percent;
}
@@ -290,7 +325,13 @@ void Replay::startReplay(bool flag)
}
void Replay::setMultiple(double value)
{
if(value != 0)
{
multiple = value;
}
}
+4 -2
View File
@@ -1,4 +1,4 @@
#ifndef REPLAY_H
#ifndef REPLAY_H
#define REPLAY_H
#include <QObject>
@@ -59,7 +59,7 @@ public slots:
void setLogfile(const QString name,float percent = 0);
void setPercentage(float value);
void startReplay(bool flag);
void setMultiple(double value);
private slots:
//线程私有接口
void process();
@@ -83,6 +83,8 @@ protected:
QByteArray buff;
double multiple = 1000;
};
#endif // MAVLINKNODE_H
-4
View File
@@ -85,10 +85,6 @@ void statusprocess::process()//线程函数
//qDebug() << "heartbeat";
}
}
}
//退出线程
thread->quit();
+28
View File
@@ -75,6 +75,34 @@ Please first select the area of the map to rip with &lt;CTRL&gt;+Left mouse clic
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>mapcontrol::OPMapWidget</name>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="1645"/>
<source>please create a plan</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="1650"/>
<source>start to send mossion %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="1679"/>
<source>send way point %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="1686"/>
<source>fail to send %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="1770"/>
<source>recieve way point %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>mapcontrol::TrailItem</name>
<message>