修改航线从缓存读取,多任务模式

This commit is contained in:
hm
2022-06-09 17:50:48 +08:00
parent 51b5ba03ff
commit aa199e173c
22 changed files with 989 additions and 688 deletions
+14 -14
View File
@@ -93,67 +93,67 @@ Please first select the area of the map to rip with <CTRL>+Left mouse clic
<translation></translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2195"/>
<location filename="mapwidget/opmapwidget.cpp" line="2201"/>
<source>Load Geo Fence File :%1</source>
<translation>%1</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2285"/>
<location filename="mapwidget/opmapwidget.cpp" line="2291"/>
<source>Load Mission File:Group %1,%2</source>
<translation>线%1线%2</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2381"/>
<location filename="mapwidget/opmapwidget.cpp" line="2387"/>
<source>Save Fence File:%1</source>
<translation>%1</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2456"/>
<location filename="mapwidget/opmapwidget.cpp" line="2462"/>
<source>Save Mission File:Group %1,%2</source>
<translation>线%1线%2</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2662"/>
<location filename="mapwidget/opmapwidget.cpp" line="2668"/>
<source>please load fence first</source>
<translation></translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2667"/>
<location filename="mapwidget/opmapwidget.cpp" line="2673"/>
<source>start upload fence,total:%1</source>
<translation>%1</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2705"/>
<location filename="mapwidget/opmapwidget.cpp" line="2711"/>
<source>please load mission first</source>
<translation>线</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2710"/>
<location filename="mapwidget/opmapwidget.cpp" line="2716"/>
<source>start upload mission %1,total %2</source>
<translation>线%1%2</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2923"/>
<location filename="mapwidget/opmapwidget.cpp" line="2929"/>
<source>upload fail %1</source>
<translation> %1</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2951"/>
<location filename="mapwidget/opmapwidget.cpp" line="2957"/>
<source>recieve fence polygon inclusion: %1</source>
<translation> %1</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="2998"/>
<location filename="mapwidget/opmapwidget.cpp" line="3004"/>
<source>recieve fence polygon exclusion: %1</source>
<translation> %1</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="3047"/>
<location filename="mapwidget/opmapwidget.cpp" line="3053"/>
<source>recieve fence circle inclusion: %1</source>
<translation> %1</translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="3060"/>
<location filename="mapwidget/opmapwidget.cpp" line="3066"/>
<source>recieve fence circle exclusion: %1</source>
<translation> %1</translation>
</message>
@@ -162,7 +162,7 @@ Please first select the area of the map to rip with &lt;CTRL&gt;+Left mouse clic
<translation type="vanished"></translation>
</message>
<message>
<location filename="mapwidget/opmapwidget.cpp" line="3078"/>
<location filename="mapwidget/opmapwidget.cpp" line="3084"/>
<source>recieve way point group:%1 seq:%2</source>
<translation>%1%2</translation>
</message>
+278
View File
@@ -347,6 +347,12 @@ void OPMapWidget::addUAV(int sysid,int compid)
connect(uavItem,SIGNAL(selected(int,int)),
this,SIGNAL(uav_selected(int,int)));
connect(uavItem,SIGNAL(vehicleChanged(int,int)),
this,SLOT(checkoutVehicle(int,int)));
uavItem->setOpacity(overlayOpacity);
//检测,如果只有一个飞机,那么就选中
@@ -3178,6 +3184,278 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
}
void OPMapWidget::checkoutVehicle(int sys,int comp)
{
//检查并发送读取航线的信号
//删除一个组
foreach(QGraphicsItem * i, map->childItems()) {
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
if (w) {
emit WPDeleted(w->Number(), w);
delete w;
}
}
foreach(QGraphicsItem * i, map->childItems()) {
geoFencecircle *w = qgraphicsitem_cast<geoFencecircle *>(i);
if (w) {
delete w;
}
}
foreach(QGraphicsItem * i, map->childItems()) {
geoFenceitem *w = qgraphicsitem_cast<geoFenceitem *>(i);
if (w) {
delete w;
}
}
//发送信号清除表格所有东西
emit clearTable();
//发送切换的信号,从缓存读取航线
emit getMissionFromVehicle(sys);
}
//这个有可能是其他线程运行,导致生成的航点不对,下载得到
void OPMapWidget::vehicleChanged(float param1,float param2,float param3,float param4,
int32_t x,int32_t y,float z,
uint16_t seq,
uint16_t group,
uint16_t command,
uint8_t target_system,
uint8_t target_component,
uint8_t frame,
uint8_t current,
uint8_t autocontinue,
uint8_t mission_type)
{
if((mission_type - 2) == -1)
{
qDebug() << command << seq << param1 << param2 << param3 << param4 << x << y;
if(command == MAV_CMD_NAV_FENCE_POLYGON_VERTEX_INCLUSION )
{
static int PolygonCount = 0;
static QList<internals::PointLatLng> PolygonPoints;
PolygonCount ++;
bool inclusion = true;
PolygonPoints.push_back(internals::PointLatLng(x * 10e-8,y * 10e-8));
if(PolygonCount >= param1)
{
QList<QPointF> latlng;
qreal lat_sum = 0;
qreal lng_sum = 0;
for (internals::PointLatLng point: PolygonPoints) {
qreal lat = point.Lat();
qreal lng = point.Lng();
lat_sum += lat;
lng_sum += lng;
latlng.push_back(QPointF(lat,lng));
}
internals::PointLatLng center;
center.SetLat(lat_sum/latlng.size());
center.SetLng(lng_sum/latlng.size());
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,0,center,QColor("#FF8000"),map);
polyitem->setPoints(PolygonPoints);
emit createFencePolygon(fenceCount++,PolygonPoints.size(),inclusion,latlng);
connect(polyitem,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)),
this,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)));
PolygonCount = 0;
PolygonPoints.clear();
}
}
else if(command == MAV_CMD_NAV_FENCE_POLYGON_VERTEX_EXCLUSION )
{
static int PolygonCount = 0;
static QList<internals::PointLatLng> PolygonPoints;
PolygonCount ++;
bool inclusion = false;
PolygonPoints.push_back(internals::PointLatLng(x * 10e-8,y * 10e-8));
if(PolygonCount >= param1)
{
QList<QPointF> latlng;
qreal lat_sum = 0;
qreal lng_sum = 0;
for (internals::PointLatLng point: PolygonPoints) {
qreal lat = point.Lat();
qreal lng = point.Lng();
lat_sum += lat;
lng_sum += lng;
latlng.push_back(QPointF(lat,lng));
}
internals::PointLatLng center;
center.SetLat(lat_sum/latlng.size());
center.SetLng(lng_sum/latlng.size());
geoFenceitem *polyitem = new geoFenceitem(fenceCount,inclusion,0,center,QColor("#FF8000"),map);
polyitem->setPoints(PolygonPoints);
emit createFencePolygon(fenceCount++,PolygonPoints.size(),inclusion,latlng);
connect(polyitem,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)),
this,SIGNAL(updateFencePolygon(int,qreal,bool,QList<QPointF>)));
PolygonCount = 0;
PolygonPoints.clear();
}
}
else if(command == MAV_CMD_NAV_FENCE_CIRCLE_INCLUSION )
{
bool inclusion = true;
qreal radius = param1;
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
emit createFenceCircle(fenceCount++,radius,inclusion,x * 10e-8,y * 10e-8);
connect(c,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)),
this,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)));
}
else if(command == MAV_CMD_NAV_FENCE_CIRCLE_EXCLUSION )
{
bool inclusion = false;
qreal radius = param1;
geoFencecircle *c = new geoFencecircle(fenceCount,inclusion,0,internals::PointLatLng(x * 10e-8,y * 10e-8),radius,QColor("#FF8000"),map);
emit createFenceCircle(fenceCount++,radius,inclusion,x * 10e-8,y * 10e-8);
connect(c,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)),
this,SIGNAL(updateFenceCircle(int,qreal,bool,qreal,qreal)));
}
else if(command == MAV_CMD_NAV_RALLY_POINT )
{
}
}
else
{
bool isExist = false;
foreach(QGraphicsItem * i, map->childItems()) {
WayPointItem *w = qgraphicsitem_cast<WayPointItem *>(i);
if (w) {
if(w->MissionType() == mission_type)//如果组别一样,那么就赋值
{
if(w->Number() == (seq+1))
{
isExist = true;
internals::PointLatLng LatLng;
LatLng.SetLat(x * 10e-8);
LatLng.SetLng(y * 10e-8);
w->SetLat(LatLng.Lat());
LatLng.SetLng(LatLng.Lng());
w->SetNumber(seq+1);
emit setWPProperty(param1,param2,param3,param4,
x,y,z,
seq+1,
group,
command,
target_system,
target_component,
frame,
current,
autocontinue,
mission_type);
w->emitWPProperty();
}
}
}
}
if(!isExist)
{
internals::PointLatLng LatLng;
LatLng.SetLat(x * 10e-8);
LatLng.SetLng(y * 10e-8);
//获取当前组下面的seq最大值
WayPointItem *Item = new WayPointItem(LatLng, z,seq+1,mission_type, map);
ConnectWP(Item);
Item->setParentItem(map);
Item->SetMissionType(mission_type);
int position = Item->Number();
emit WPCreated(position, Item);
setOverlayOpacity(overlayOpacity);
emit setWPProperty(param1,param2,param3,param4,
x,y,z,
seq+1,
group,
command,
target_system,
target_component,
frame,
current,
autocontinue,
mission_type);
Item->emitWPProperty();
Item->setisShowTip(isShowTip);
//===========连线
WayPointItem *w_last = WPFind(Item->MissionType(),Item->Number() - 1);
if(w_last)
{
WPLineCreate(w_last,Item,Qt::green,false,2);
}
}
}
}
void OPMapWidget::getMapTypes(void)
{
emit MapTypes(Helper::MapTypes());
+22
View File
@@ -675,6 +675,11 @@ signals:
void FenceGroupChanged(int old,int cur);
void getMissionFromVehicle(int sys);
void clearTable();
public slots:
void getAllPoints(int group);
@@ -713,6 +718,23 @@ public slots:
uint8_t mission_type);
void vehicleChanged(float param1,float param2,float param3,float param4,
int32_t x,int32_t y,float z,
uint16_t seq,
uint16_t group,
uint16_t command,
uint8_t target_system,
uint8_t target_component,
uint8_t frame,
uint8_t current,
uint8_t autocontinue,
uint8_t mission_type);
void checkoutVehicle(int sys,int comp);
void WPLineDelete(WayPointItem *from, WayPointItem *to);
WayPointLine *WPLineFind(WayPointItem *from, WayPointItem *to);
+24 -19
View File
@@ -49,7 +49,7 @@ UAVItem::UAVItem(MapGraphicItem *map, OPMapWidget *parent, QString uavPic ,uint8
localposition = map->FromLatLngToLocal(mapwidget->CurrentPosition());
this->setPos(localposition.X(), localposition.Y());
this->setZValue(4);
this->setZValue(7);
trail = new QGraphicsItemGroup(this);
trail->setParentItem(map);
trailLine = new QGraphicsItemGroup(this);
@@ -99,11 +99,11 @@ void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
{
if (isSelected)
{
this->setZValue(5);
this->setZValue(6);
}
else
{
this->setZValue(4);
this->setZValue(7);
}
}
@@ -200,11 +200,11 @@ void UAVItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
}
/*
painter->save();
painter->drawRect(boundingRect());
painter->restore();
*/
}
@@ -230,23 +230,28 @@ void UAVItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
isSelected = true;
//查找所有
foreach(QGraphicsItem * i, map->childItems()) {
UAVItem *uav = qgraphicsitem_cast<UAVItem *>(i);
if (uav) {
if(uav != this)
{
uav->setSelect(false);
if(isSelected == false)
{
isSelected = true;
//查找所有
foreach(QGraphicsItem * i, map->childItems()) {
UAVItem *uav = qgraphicsitem_cast<UAVItem *>(i);
if (uav) {
if(uav != this)
{
uav->setSelect(false);
}
}
}
}
qDebug() << "emit select" << sysid << compid;
emit selected(sysid,compid);
qDebug() << "emit select" << sysid << compid;
emit selected(sysid,compid);
isShowTip = (isShowTip)?(false):(true);
isShowTip = (isShowTip)?(false):(true);
update();
emit vehicleChanged(sysid,compid);
update();
}
}
//QGraphicsItem::mouseReleaseEvent(event);
@@ -284,7 +289,7 @@ void UAVItem::setEdit(bool value)
}
else
{
this->setZValue(4);
this->setZValue(7);
}
}
+2
View File
@@ -286,6 +286,8 @@ signals:
void selected(int sys,int comp);
void vehicleChanged(int sys,int comp);
void UAVReachedWayPoint(int const & waypointnumber, WayPointItem *waypoint);
void UAVLeftSafetyBouble(internals::PointLatLng const & position);
void setChildPosition();