多航线可以上下传和修改,目前采用每次切换都要下载的方式
This commit is contained in:
@@ -116,6 +116,7 @@ propertyui::propertyui(QWidget *parent) :
|
||||
//ui->pushButton_2->hide();
|
||||
|
||||
ui->pushButton_Group->setText("1");
|
||||
m_mission_type = 3;
|
||||
emit WPGroup(m_mission_type);
|
||||
//载入json
|
||||
|
||||
@@ -192,7 +193,7 @@ void propertyui::rebuildUI(QString CMD)
|
||||
|
||||
//重新载入UI
|
||||
|
||||
ui->pushButton_Group->setText(QString::number(m_mission_type));
|
||||
//ui->pushButton_Group->setText(QString::number(m_mission_type - 2));
|
||||
|
||||
ui->pushButton_Seq->setText(QString::number(m_seq));
|
||||
ui->label_Descript->setText(description());
|
||||
@@ -604,9 +605,9 @@ void propertyui::WayPointPropertyUpdate(bool flag)
|
||||
|
||||
|
||||
//设置missiontype
|
||||
m_mission_type = ui->pushButton_Group->text().toInt() + 2;
|
||||
missionGroups = ui->pushButton_Group->text().toInt() + 2;
|
||||
|
||||
qDebug() << "m_misstiontype" << m_mission_type;
|
||||
qDebug() << "m_misstiontype" << missionGroups;
|
||||
//设置高度
|
||||
m_z = ui->pushButton_Alt->text().toDouble();
|
||||
|
||||
@@ -1915,13 +1916,13 @@ void propertyui::on_pushButton_Save_clicked()
|
||||
|
||||
void propertyui::on_pushButton_Upload_clicked()
|
||||
{
|
||||
emit WPGroup(m_mission_type);
|
||||
//emit WPGroup(missionGroups);
|
||||
emit WPUpload();
|
||||
}
|
||||
|
||||
void propertyui::on_pushButton_Download_clicked()
|
||||
{
|
||||
emit WPGroup(m_mission_type);
|
||||
//emit WPGroup(missionGroups);
|
||||
emit WPDownload();
|
||||
}
|
||||
|
||||
@@ -1955,7 +1956,7 @@ void propertyui::setGroup(QVariant value)
|
||||
//然后重置一下参数
|
||||
WayPointPropertyUpdate(false);
|
||||
|
||||
emit WPGroup(m_mission_type);
|
||||
emit WPGroup(missionGroups);
|
||||
|
||||
}
|
||||
|
||||
@@ -1971,7 +1972,7 @@ void propertyui::on_pushButton_Group_clicked()
|
||||
list.append("3");
|
||||
list.append("4");
|
||||
|
||||
selector->setList(list,ui->pushButton_friendlyName->text());
|
||||
selector->setList(list,ui->pushButton_Group->text());
|
||||
|
||||
connect(selector,SIGNAL(confirmValue(QVariant)),
|
||||
this,SLOT(setGroup(QVariant)));
|
||||
|
||||
@@ -404,6 +404,8 @@ private:
|
||||
QString param6_type = "QLineEdit";
|
||||
QString param7_type = "QLineEdit";
|
||||
|
||||
int missionGroups = 3;
|
||||
|
||||
|
||||
QMap<int,QVector<QString>> allPoint;//所有航点
|
||||
|
||||
|
||||
@@ -243,6 +243,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(map,SIGNAL(TotalDistanceUpdate(double)),
|
||||
this,SLOT(TotalDistance(double)));
|
||||
|
||||
|
||||
|
||||
connect(this,SIGNAL(currentGroup(int)),
|
||||
map,SLOT(groupchanged(int))),
|
||||
|
||||
|
||||
|
||||
//tools ----- map
|
||||
connect(dlink->mavlinknode,SIGNAL(recievemsg(mavlink_message_t)),
|
||||
toolsui->index0->mavlinkinspector,SLOT(receiveMessage(mavlink_message_t)));
|
||||
@@ -381,6 +388,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
connect(map,SIGNAL(allPoint(QMap<int,int>)),
|
||||
missionUI,SLOT(setallPoint(QMap<int,int>)));
|
||||
|
||||
@@ -804,6 +813,7 @@ void MainWindow::onTabIndexChanged(const int &index)//界面选择管理
|
||||
commandUI->show();
|
||||
//statusui->show();
|
||||
healthui->show();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -835,6 +845,14 @@ void MainWindow::onTabIndexChanged(const int &index)//界面选择管理
|
||||
statusui->hide();
|
||||
healthui->show();
|
||||
}
|
||||
|
||||
//发生界面切换,检查一下航线
|
||||
qDebug() << "zubie" << map->currentGroup << group;
|
||||
if(map->currentGroup != group)
|
||||
{
|
||||
emit currentGroup(group + 2);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1574,6 +1592,22 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
||||
healthui->setValueState(35,getBit(enable,7)?(tr("安控区内")):(tr("安控区外")));//sel
|
||||
|
||||
|
||||
|
||||
//get 9-10
|
||||
|
||||
//得到航线组数,数据为1,2,3,4
|
||||
group = (int)(getBit(enable,11) << 2) | (int)(getBit(enable,10) << 1) | (int)(getBit(enable,9));
|
||||
|
||||
if(group_old != group)//有变化的时候就发出去
|
||||
{
|
||||
emit currentGroup(group + 2);
|
||||
//qDebug() << "group change" << group;
|
||||
|
||||
showMessage(tr("mission group has changed, current group is %1").arg(group));
|
||||
}
|
||||
|
||||
group_old = group;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -117,6 +117,10 @@ signals:
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
int group_old;
|
||||
int group;
|
||||
|
||||
int MainIndex = 0;
|
||||
|
||||
Config *config = nullptr;
|
||||
|
||||
@@ -59,7 +59,7 @@ void MissionProcess::ReadCmd(uint8_t m_sysid, uint8_t m_compid,int m_group)
|
||||
mission_status.m_Mode = RecieveMode;//接收模式
|
||||
|
||||
mission_status.recieve.group = m_group;
|
||||
qDebug() << "read mission" << sysid << compid;
|
||||
qDebug() << "read mission" << sysid << compid << m_group;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ void MissionProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,uint32_t count
|
||||
mission_status.transmit.group = m_group;
|
||||
mission_status.m_Mode = TransmitMode;//发送模式
|
||||
|
||||
qDebug() << "write mission" << sysid << compid;
|
||||
qDebug() << "write mission" << m_sysid << m_compid << m_group;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@ void MissionProcess::transmitPoint(float param1,float param2,float param3,float
|
||||
|
||||
items.insert(item.seq,item);
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
foreach (mapcontrol::WayPointItem::_property item, items) {
|
||||
qDebug() << "Mission Thread: transmit seq"
|
||||
<< item.seq
|
||||
@@ -147,8 +147,8 @@ void MissionProcess::transmitPoint(float param1,float param2,float param3,float
|
||||
<< item.autocontinue
|
||||
<< item.mission_type;
|
||||
}
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
@@ -171,7 +171,7 @@ void MissionProcess::Parse(mavlink_message_t msg)
|
||||
case MAVLINK_MSG_ID_MISSION_REQUEST_INT: {
|
||||
mavlink_msg_mission_request_int_decode(&msg,&mission_request_int);
|
||||
|
||||
qDebug() << "recieve mission_request_int ";
|
||||
qDebug() << "recieve mission_request_int " << "mision type" << mission_request_int.mission_type;
|
||||
mission_item_int.seq ++;
|
||||
|
||||
emit sendItemOK(mission_item_int.seq,true);
|
||||
@@ -180,7 +180,7 @@ void MissionProcess::Parse(mavlink_message_t msg)
|
||||
case MAVLINK_MSG_ID_MISSION_REQUEST: {
|
||||
mavlink_msg_mission_request_decode(&msg,&mission_request);
|
||||
|
||||
qDebug() << "recieve mission_request ";
|
||||
qDebug() << "recieve mission_request " << "mission type" << mission_request.mission_type;
|
||||
|
||||
mission_item_int.seq ++;
|
||||
|
||||
@@ -209,6 +209,8 @@ void MissionProcess::Parse(mavlink_message_t msg)
|
||||
mission_item_int.autocontinue,
|
||||
mission_item_int.mission_type);
|
||||
|
||||
qDebug() << "recieve mission type" << mission_item_int.mission_type;
|
||||
|
||||
mission_status.recieve.isWaitingforItem = false;//已经收到航点,不用再等待
|
||||
}break;
|
||||
case MAVLINK_MSG_ID_MISSION_ITEM: {
|
||||
@@ -283,10 +285,23 @@ void MissionProcess::ReadStateMachine(void)
|
||||
qDebug() << "mission count reccieved";
|
||||
timeout_count = 0;
|
||||
|
||||
request_int(0,mission_status.recieve.group);//读取0点
|
||||
time = QTime::currentTime().msecsSinceStartOfDay();
|
||||
mission_status.recieve.isWaitingforItem = true;
|
||||
step ++;
|
||||
if(mission_count.count > 0)
|
||||
{
|
||||
request_int(0,mission_status.recieve.group);//读取0点
|
||||
time = QTime::currentTime().msecsSinceStartOfDay();
|
||||
mission_status.recieve.isWaitingforItem = true;
|
||||
step ++;
|
||||
|
||||
qDebug() << "group" << mission_status.recieve.group;
|
||||
}
|
||||
else
|
||||
{
|
||||
step = 0;
|
||||
mission_status.m_Mode = Nop_Mode;//切换到什么都不做
|
||||
timeout_count = 0;
|
||||
qDebug() << "no mission to read";
|
||||
emit showMessage(tr("this mission group is empty"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +483,8 @@ void MissionProcess::WriteStateMachine(void)
|
||||
<< i.x
|
||||
<< i.y
|
||||
<< i.z
|
||||
<< i.seq;
|
||||
<< i.seq
|
||||
<< i.mission_type;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
"Beep": true
|
||||
},
|
||||
"commandfile": {
|
||||
"path": "D:/2_Work/13_KB3/gcs_nf/bin/commands/KB3_FlightCommand(FCmode_gz)210722.json"
|
||||
"path": "D:/2_Work/13_KB3/gcs_nf/bin/commands/KB3_FlightCommand(FCmode_gz)_20220409_hm.json"
|
||||
},
|
||||
"数据链": {
|
||||
"auto": true,
|
||||
|
||||
@@ -397,6 +397,8 @@ public:
|
||||
int currentGroup = 0;//编辑情况
|
||||
int currentMissionType = 0;
|
||||
|
||||
QMap<int,QMap<int,WayPointItem *>> waypointgroups;//group index point
|
||||
|
||||
|
||||
void SetShowUAV(bool const & value);
|
||||
bool ShowUAV() const
|
||||
@@ -459,7 +461,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
QMap<int,WayPointItem *> waypointgroups;
|
||||
|
||||
|
||||
private:
|
||||
internals::Core *core;
|
||||
@@ -630,6 +632,9 @@ signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void groupchanged(int value);
|
||||
|
||||
|
||||
void find_PointNumber();
|
||||
|
||||
void updateMessage(void);
|
||||
|
||||
Binary file not shown.
+103
-19
@@ -804,6 +804,7 @@ WayPointItem *OPMapWidget::WPCreate()
|
||||
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
int position = item->Number();
|
||||
emit WPCreated(position, item);
|
||||
return item;
|
||||
@@ -814,12 +815,14 @@ WayPointItem *OPMapWidget::magicWPCreate()
|
||||
|
||||
item->SetShowNumber(false);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
return item;
|
||||
}
|
||||
void OPMapWidget::WPCreate(WayPointItem *item)
|
||||
{
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
int position = item->Number();
|
||||
emit WPCreated(position, item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
@@ -830,6 +833,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co
|
||||
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
int position = item->Number();
|
||||
emit WPCreated(position, item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
@@ -841,6 +845,7 @@ WayPointItem *OPMapWidget::WPCreate(internals::PointLatLng const & coord, int co
|
||||
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
int position = item->Number();
|
||||
emit WPCreated(position, item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
@@ -852,6 +857,7 @@ WayPointItem *OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, co
|
||||
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
int position = item->Number();
|
||||
emit WPCreated(position, item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
@@ -917,6 +923,7 @@ void OPMapWidget::WPInsert()
|
||||
ConnectWP(item);
|
||||
item->SetNumber(position);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
|
||||
setSelectedWP(item);
|
||||
@@ -988,6 +995,7 @@ void OPMapWidget::WPInsert(WayPointItem *item, const int &position)
|
||||
item->SetNumber(position);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
emit WPInserted(position, item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
}
|
||||
@@ -998,6 +1006,7 @@ WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int co
|
||||
item->SetNumber(position);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
emit WPInserted(position, item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
@@ -1017,6 +1026,7 @@ WayPointItem *OPMapWidget::WPInsert(internals::PointLatLng const & coord, int co
|
||||
item->SetNumber(position);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
emit WPInserted(position, item);
|
||||
if (reloc) {
|
||||
emit WPValuesChanged(item);
|
||||
@@ -1031,6 +1041,7 @@ WayPointItem *OPMapWidget::WPInsert(distBearingAltitude const & relative, QStrin
|
||||
item->SetNumber(position);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
item->SetMissionType(currentGroup);
|
||||
emit WPInserted(position, item);
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
return item;
|
||||
@@ -2000,23 +2011,6 @@ void OPMapWidget::WPUpload(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointLine *l = qgraphicsitem_cast<WayPointLine *>(i);
|
||||
if (l) {
|
||||
l->setVisible(false);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//qDebug() << "WPUpload" << list.size();
|
||||
|
||||
|
||||
if(list.size() <= 0)
|
||||
{
|
||||
emit showMessage("请先载入任务航线");
|
||||
@@ -2046,17 +2040,107 @@ void OPMapWidget::WPUpload(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OPMapWidget::groupchanged(int value)
|
||||
{
|
||||
//如果当前是在飞行界面,那么就下载,否则不动
|
||||
|
||||
if(isWPCreate == true)//编辑界面
|
||||
{
|
||||
|
||||
}
|
||||
else//飞行界面
|
||||
{
|
||||
WPDeleteAll();
|
||||
|
||||
int sysid = 0;
|
||||
int compid = 0;
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *u = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (u) {
|
||||
if(u->Select() == true)
|
||||
{
|
||||
sysid = u->SysID();
|
||||
compid = u->CompID();
|
||||
|
||||
emit signal_WPDownload(sysid,compid,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void OPMapWidget::WPGroup(int value)
|
||||
{
|
||||
currentGroup = value;
|
||||
|
||||
qDebug() << "group" << value;
|
||||
qDebug() << "group checkout" << value;
|
||||
|
||||
//切换当前航线,显示当前航线,其他都隐藏,或者高亮当前
|
||||
//切换当前航线,其他都隐藏,或者高亮当前
|
||||
|
||||
/*
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
|
||||
if (w) {
|
||||
|
||||
if(w->MissionType() != currentGroup)
|
||||
{
|
||||
w->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
w->setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
WayPointLine *l = qgraphicsitem_cast<WayPointLine *>(i);
|
||||
if (l) {
|
||||
|
||||
if(l->MissionType() != currentGroup)
|
||||
{
|
||||
l->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//按照当前的组生成新的航点和航线
|
||||
/*
|
||||
WPDeleteAll();
|
||||
|
||||
QMap<int,WayPointItem *> group;
|
||||
|
||||
group = waypointgroups.value(currentGroup);
|
||||
*/
|
||||
|
||||
|
||||
WPDeleteAll();
|
||||
|
||||
int sysid = 0;
|
||||
int compid = 0;
|
||||
|
||||
foreach(QGraphicsItem * i, map->childItems()) {
|
||||
UAVItem *u = qgraphicsitem_cast<UAVItem *>(i);
|
||||
if (u) {
|
||||
if(u->Select() == true)
|
||||
{
|
||||
sysid = u->SysID();
|
||||
compid = u->CompID();
|
||||
|
||||
emit signal_WPDownload(sysid,compid,currentGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -397,6 +397,8 @@ public:
|
||||
int currentGroup = 0;//编辑情况
|
||||
int currentMissionType = 0;
|
||||
|
||||
QMap<int,QMap<int,WayPointItem *>> waypointgroups;//group index point
|
||||
|
||||
|
||||
void SetShowUAV(bool const & value);
|
||||
bool ShowUAV() const
|
||||
@@ -459,7 +461,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
QMap<int,WayPointItem *> waypointgroups;
|
||||
|
||||
|
||||
private:
|
||||
internals::Core *core;
|
||||
@@ -630,6 +632,9 @@ signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void groupchanged(int value);
|
||||
|
||||
|
||||
void find_PointNumber();
|
||||
|
||||
void updateMessage(void);
|
||||
|
||||
@@ -774,14 +774,14 @@ void WayPointItem::SetDefault(double lat,double lng,float alt,uint16_t seq)
|
||||
property.y = lng * 10e6;
|
||||
property.z = alt;
|
||||
property.seq = seq;
|
||||
property.group = 0;
|
||||
property.group = 3;
|
||||
property.command = MAV_CMD::MAV_CMD_NAV_WAYPOINT;
|
||||
property.target_system = 0;
|
||||
property.target_component = 0;
|
||||
property.frame = MAV_FRAME::MAV_FRAME_GLOBAL;
|
||||
property.current = 0;
|
||||
property.autocontinue = true;
|
||||
property.mission_type = 0;
|
||||
property.mission_type = 3;
|
||||
|
||||
if(property.command > MAV_CMD::MAV_CMD_NAV_LAST)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user