提交 3e2ab3c9 作者: 翁进城

fix: 修正航线数据结构混乱

上级 d06c9a1d
...@@ -126,10 +126,17 @@ export default { ...@@ -126,10 +126,17 @@ export default {
total: 0, total: 0,
}; };
this.airwayData.records?.map((item) => { this.airwayData.records = this.airwayData.records?.map((item) => {
let content = [];
try{
content = JSON.parse(item.content).content
}catch(e){
console.log(e);
}
return { return {
...item, ...item,
status: statusMap[item.status], status: statusMap[item.status],
content
}; };
}) })
} }
......
...@@ -87,9 +87,9 @@ export default { ...@@ -87,9 +87,9 @@ export default {
this.clearAirwayEntities(); this.clearAirwayEntities();
if (this.selectedAirway.id !== -1) { if (this.selectedAirway.id !== -1) {
try { try {
let airway = JSON.parse(this.selectedAirway.content); let airway = this.selectedAirway.content;
this.createAirwayEntities({ this.createAirwayEntities({
polyline: airway.content, polyline: airway,
id: airway.id, id: airway.id,
}); });
} catch (e) { } catch (e) {
...@@ -188,11 +188,11 @@ export default { ...@@ -188,11 +188,11 @@ export default {
}); });
// 当前机库状态是否空闲 // 当前机库状态是否空闲
if ([0, 8].includes(this.hangarRealTimeData.processStatus)) { if ([0, 8].includes(this.hangarRealTimeData.processStatus)) {
this.$store.commit("MMCFlightControlCenter/hangar/setState", { this.$store.commit("MMCFlightControlCenter/uav/setState", {
key: "airlineData", key: "airlineData",
value: this.selectedAirway, value: this.selectedAirway,
}); });
this.$store.dispatch("MMCFlightControlCenter/hangar/takeOff", { this.$store.dispatch("MMCFlightControlCenter/uav/takeOff", {
callback: (status) => { callback: (status) => {
if (status) { if (status) {
this.$message.success("一键任务指令发送成功"); this.$message.success("一键任务指令发送成功");
......
...@@ -125,10 +125,17 @@ export default { ...@@ -125,10 +125,17 @@ export default {
total: 0, total: 0,
}; };
this.airwayData.records?.map((item) => { this.airwayData.records = this.airwayData.records?.map((item) => {
let content = [];
try{
content = JSON.parse(item.content).content
}catch(e){
console.log(e);
}
return { return {
...item, ...item,
status: statusMap[item.status], status: statusMap[item.status],
content
}; };
}) })
} }
......
...@@ -111,7 +111,11 @@ export default { ...@@ -111,7 +111,11 @@ export default {
this.clearAirwayEntities(); this.clearAirwayEntities();
if (this.selectedAirway.id !== -1) { if (this.selectedAirway.id !== -1) {
try { try {
this.createAirwayEntities(JSON.parse(this.selectedAirway.content)); let airway = this.selectedAirway.content;
this.createAirwayEntities({
polyline: airway,
id: airway.id,
});
} catch (e) { } catch (e) {
console.log("绘制航线失败", e); console.log("绘制航线失败", e);
} }
...@@ -125,6 +129,10 @@ export default { ...@@ -125,6 +129,10 @@ export default {
this.clearAirwayEntities(); this.clearAirwayEntities();
}, },
methods: { methods: {
...mapActions("MMCFlightControlCenter", [
"createAirwayEntities",
"clearAirwayEntities",
]),
...mapActions("MMCFlightControlCenter/uav", ["isTakeOver"]), ...mapActions("MMCFlightControlCenter/uav", ["isTakeOver"]),
/** /**
* 更改航线事件 * 更改航线事件
...@@ -206,135 +214,6 @@ export default { ...@@ -206,135 +214,6 @@ export default {
}) })
} }
}, },
// 两点距离
create_label(before, after) {
const before_wgs84 = Utils.transformCartesian2WGS84(before);
const after_wgs84 = Utils.transformCartesian2WGS84(after);
const center_lng = (before_wgs84.lng + after_wgs84.lng) / 2;
const cetner_lat = (before_wgs84.lat + after_wgs84.lat) / 2;
const alt = (after_wgs84.alt + before_wgs84.alt) / 2;
const position = Utils.transformWGS842Cartesian({
lng: center_lng,
lat: cetner_lat,
alt: alt,
});
const text = `${Cesium.Cartesian3.distance(before, after).toFixed(2)} m`;
let label_entity = this.cesiumViewer.entities.add({
id: `label_${before}`,
position: position,
label: {
text: text,
scale: 0.5,
font: "bold 30px Microsoft YaHei",
fillColor: Cesium.Color.fromCssColorString("#fff"),
horizontalOrigin: Cesium.VerticalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
showBackground: true,
backgroundPadding: new Cesium.Cartesian2(10, 10),
},
});
airwayEntities.push(label_entity);
},
// 清除航线
clearAirwayEntities() {
airwayEntities.forEach((item) => {
this.cesiumViewer.entities.remove(item);
});
},
createAirwayEntities(polyline) {
let pointPositions = [];
const label_arr = [];
polyline.content.forEach((item, index) => {
item.longitude = Number(item.longitude);
item.latitude = Number(item.latitude);
item.alt = Number(item.alt);
pointPositions.push(item.longitude, item.latitude, item.alt);
label_arr.push(
Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude, item.alt)
);
point_entity = this.cesiumViewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(
item.longitude,
item.latitude,
item.alt
),
name: "show_airline_point",
point: {
pixelSize: 20,
color: Cesium.Color.RED,
color: Cesium.Color.fromCssColorString("#1890FF"),
// fillColor: Cesium.Color.RED,
outlineWidth: 2,
outlineColor: Cesium.Color.fromCssColorString("#FFF"),
// heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
},
label: {
// text: String(item.altitude) + 'm',
text: String(index + 1),
scale: 0.5,
font: "bold 24px Microsoft YaHei",
// fillColor: Cesium.Color.BLUE,
fillColor: Cesium.Color.fromCssColorString("#fff"),
horizontalOrigin: Cesium.VerticalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.CENTER,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
outlineWidth: 0,
// showBackground: true,
// backgroundColor: Cesium.Color.fromCssColorString("#1890FF")
// pixelOffset: new Cesium.Cartesian2(25, -10),
// backgroundPadding: new Cesium.Cartesian2(10, 10)
},
id: JSON.stringify({
...item,
type: "flight_point",
index: index,
}),
});
airwayEntities.push(point_entity);
if (label_arr.length > 1 && !this.isEditting) {
const before = label_arr[label_arr.length - 2];
const after = label_arr[label_arr.length - 1];
this.create_label(before, after);
}
});
pointPositions =
Cesium.Cartesian3.fromDegreesArrayHeights(pointPositions);
const redLine = this.cesiumViewer.entities.add({
name: "Red line on terrain",
polyline: {
positions: new Cesium.CallbackProperty(() => {
return pointPositions;
}, false),
width: 4,
// clampToGround: true,
// zIndex: -99,
material: Cesium.Color.fromCssColorString("#1890FF"),
// material: ({
// // material: Cesium.Color.fromCssColorString('#1890FF'),
// color: Cesium.Color.RED,
// outlineWidth: 2,
// outlineColor: Cesium.Color.fromCssColorString('#FFF')
// })
// // clampToGround: true,
// material: new Cesium.PolylineOutlineMaterialProperty({
// color: Cesium.Color.fromCssColorString('#1890FF'),
// // outlineWidth: 2,
// // outlineColor: Cesium.Color.fromCssColorString('#FFF'),
// }),
},
});
this.cesiumViewer.flyTo(redLine);
airwayEntities.push(redLine);
},
}, },
}; };
</script> </script>
......
...@@ -48,7 +48,6 @@ const state = { ...@@ -48,7 +48,6 @@ const state = {
hangar: null, // 选择中的机库信息 hangar: null, // 选择中的机库信息
showPanel: false, //显示数据面板 showPanel: false, //显示数据面板
hangarRealTimeData, // 实时数据 hangarRealTimeData, // 实时数据
airlineData: null, // 当前选择的航线数据
}; };
const mutations = { const mutations = {
...@@ -252,57 +251,6 @@ const actions = { ...@@ -252,57 +251,6 @@ const actions = {
}, },
}); });
}, },
/**
* 一键起飞
* @param {function} data.callback //完成回调
*/
async takeOff({ state }, data) {
try {
let uavHardId =
window.$mmc.$store.state.MMCFlightControlCenter.uav.uav.hardId;
// 生成架次号
const getFlightSortic = await Control_API.getFlightSortic({
taskId: state.airlineData.id,
deviceHardId: uavHardId,
});
// 上传航线指令
const flightObj = JSON.parse(state.airlineData.content);
const waypointList = flightObj.map((v) => ({
altitude: v.alt,
coordinate: {
latitude: v.latitude,
longitude: v.longitude,
},
frame: 3,
stay: 0.0,
speed: v.speed,
waypointActions: v.actions,
}));
this.$store.dispatch("MMCMQTT/publish", {
topic: "PROCESS/OBTAIN/" + state.hangar.hardId,
data: {
cmdControlType: 100004,
uavDeviceId: uavHardId,
wayLineObj: {
taskId: state.airlineData.id,
flightSortiesID: getFlightSortic.data,
autoFlightSpeed: state.airlineData.line.baseSpeed,
waypointList,
finishedAction: "GO_HOME",
headingMode: "AUTO",
isExitMissionOnRCSignalLostEnabled: true,
maxFlightSpeed: 12,
},
},
callback() {
data.callback && data.callback(true);
},
});
} catch (e) {
console.log(e);
data.callback && data.callback(false, e);
}
},
}; };
export default { export default {
......
...@@ -607,7 +607,7 @@ const actions = { ...@@ -607,7 +607,7 @@ const actions = {
deviceHardId: state.uav.hardId, deviceHardId: state.uav.hardId,
}); });
// 上传航线指令 // 上传航线指令
const waypointList = JSON.parse(state.airlineData?.content); const waypointList = state.airlineData?.content;
window.$mmc.$store.dispatch("MMCMQTT/publish", { window.$mmc.$store.dispatch("MMCMQTT/publish", {
topic: "PX4/OBTAIN/" + state.uav.hardId, topic: "PX4/OBTAIN/" + state.uav.hardId,
data: { data: {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<el-switch v-model="devMode" active-text="测试环境" inactive-text="正式环境"></el-switch> <el-switch v-model="devMode" active-text="测试环境" inactive-text="正式环境"></el-switch>
</el-form-item> </el-form-item>
<el-form-item label="场景"> <el-form-item label="场景">
<el-switch v-model="scene" active-text="无人机" inactive-text="机库"></el-switch> <el-switch v-model="scene1" active-text="无人机" inactive-text="机库"></el-switch>
</el-form-item> </el-form-item>
<el-form-item label="使用标准航线库"> <el-form-item label="使用标准航线库">
<el-switch v-model="useSTLAirway" active-text="启用" inactive-text="关闭"></el-switch> <el-switch v-model="useSTLAirway" active-text="启用" inactive-text="关闭"></el-switch>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
:uavTaskList="uavTaskList" :uavTaskList="uavTaskList"
:hangarTaskList="hangarTaskList" :hangarTaskList="hangarTaskList"
:airwayList="airwayList" :airwayList="airwayList"
:scene="scene ? 0 : 1" :scene="scene"
:useSTLAirway="useSTLAirway" :useSTLAirway="useSTLAirway"
@uavTaskStart="onUAVTaskStart" @uavTaskStart="onUAVTaskStart"
@uavTaskAdd="onUAVTaskAdd" @uavTaskAdd="onUAVTaskAdd"
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
useSTLAirway: null, useSTLAirway: null,
baseUrl: "https://test.tmj.mmcuav.cn", baseUrl: "https://test.tmj.mmcuav.cn",
devMode: false, devMode: false,
_scene: false, // 场景类型 true: 无人机 false: 机库 scene1: false, // 场景类型 true: 无人机 false: 机库
account: "mmctest@admin", account: "mmctest@admin",
password: "test@Admin001", password: "test@Admin001",
userInfo: null, userInfo: null,
...@@ -159,7 +159,7 @@ export default { ...@@ -159,7 +159,7 @@ export default {
}, },
computed: { computed: {
scene(){ scene(){
return _this.scene ? 1 : 2; return this.scene1 ? 1 : 2;
} }
}, },
watch: { watch: {
...@@ -183,7 +183,7 @@ export default { ...@@ -183,7 +183,7 @@ export default {
/** /**
* 无人机通过航线创建任务 * 无人机通过航线创建任务
*/ */
onUavTaskAdd({ airway }) { onUAVTaskAdd({ airway }) {
console.log("无人机通过航线创建任务", airway); console.log("无人机通过航线创建任务", airway);
let id = Date.now(); let id = Date.now();
this.uavTaskList.push({ this.uavTaskList.push({
...@@ -193,7 +193,7 @@ export default { ...@@ -193,7 +193,7 @@ export default {
airway, airway,
}); });
}, },
onUAVStartTask(uav, selectedTask, selectedAirway) { onUAVTaskStart(uav, selectedTask, selectedAirway) {
console.log("一键任务事件", uav, selectedTask, selectedAirway); console.log("一键任务事件", uav, selectedTask, selectedAirway);
// alert("一键任务事件"); // alert("一键任务事件");
}, },
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<el-switch v-model="devMode" active-text="测试环境" inactive-text="正式环境"></el-switch> <el-switch v-model="devMode" active-text="测试环境" inactive-text="正式环境"></el-switch>
</el-form-item> </el-form-item>
<el-form-item label="场景"> <el-form-item label="场景">
<el-switch v-model="scene" active-text="无人机" inactive-text="机库"></el-switch> <el-switch v-model="scene1" active-text="无人机" inactive-text="机库"></el-switch>
</el-form-item> </el-form-item>
<el-form-item label="使用标准航线库"> <el-form-item label="使用标准航线库">
<el-switch v-model="useSTLAirway" active-text="启用" inactive-text="关闭"></el-switch> <el-switch v-model="useSTLAirway" active-text="启用" inactive-text="关闭"></el-switch>
...@@ -33,6 +33,49 @@ ...@@ -33,6 +33,49 @@
<script> <script>
import { Base64 } from "js-base64"; import { Base64 } from "js-base64";
//航线数据
const airway = [
{
uuid: "1nmI-Fo18IagbcVJsia7Q",
latitude: 23.178153411812204,
longitude: 112.57807281336807,
alt: 100,
yawAngle: 0,
pitchAngle: 0,
speed: 3,
actions: [],
},
{
uuid: "9pTbBPlF8iIwbUNqusyHK",
latitude: 23.17783116525969,
longitude: 112.57797543441967,
alt: 100,
yawAngle: 0,
pitchAngle: 0,
speed: 3,
actions: [],
},
{
uuid: "s91IhN22wuaeyG-UQs0XR",
latitude: 23.17786413506686,
longitude: 112.57824336604547,
alt: 100,
yawAngle: 0,
pitchAngle: 0,
speed: 3,
actions: [],
},
{
uuid: "xS_JIl3wxQrhMPdpcjcSn",
latitude: 23.17820934975604,
longitude: 112.5781357731637,
alt: 100,
yawAngle: 0,
pitchAngle: 0,
speed: 3,
actions: [],
},
];
export default { export default {
name: "fkzxIframe", name: "fkzxIframe",
...@@ -41,7 +84,7 @@ export default { ...@@ -41,7 +84,7 @@ export default {
isIframeReady: false, //是否接收到iframe里的ready事件 isIframeReady: false, //是否接收到iframe里的ready事件
baseUrl: "https://test.tmj.mmcuav.cn", baseUrl: "https://test.tmj.mmcuav.cn",
devMode: false, devMode: false,
_scene: null, // 场景类型 true: 无人机 false: 机库 scene1: null, // 场景类型 true: 无人机 false: 机库
useSTLAirway: null, // 使用标准航线库 useSTLAirway: null, // 使用标准航线库
account: "mmctest@admin", account: "mmctest@admin",
password: "test@Admin001", password: "test@Admin001",
...@@ -65,7 +108,7 @@ export default { ...@@ -65,7 +108,7 @@ export default {
name: "航线名称1", name: "航线名称1",
id: 1, id: 1,
content: content:
'{"filename":"肇庆航线20240318","line":{"baseSpeed":3},"content":[{"uuid":"1nmI-Fo18IagbcVJsia7Q","latitude":23.178153411812204,"longitude":112.57807281336807,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"9pTbBPlF8iIwbUNqusyHK","latitude":23.17783116525969,"longitude":112.57797543441967,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"s91IhN22wuaeyG-UQs0XR","latitude":23.17786413506686,"longitude":112.57824336604547,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"xS_JIl3wxQrhMPdpcjcSn","latitude":23.17820934975604,"longitude":112.5781357731637,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]}],"baseSpeed":3,"gimbalYaw":0,"gimbalPitch":0,"alt":100}', airway,
}, },
}, },
{ {
...@@ -75,9 +118,8 @@ export default { ...@@ -75,9 +118,8 @@ export default {
airway: { airway: {
name: "航线名称2", name: "航线名称2",
id: 2, id: 2,
content: content: airway
'{"filename":"肇庆航线20240318","line":{"baseSpeed":3},"content":[{"uuid":"1nmI-Fo18IagbcVJsia7Q","latitude":23.178153411812204,"longitude":112.57807281336807,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"9pTbBPlF8iIwbUNqusyHK","latitude":23.17783116525969,"longitude":112.57797543441967,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"s91IhN22wuaeyG-UQs0XR","latitude":23.17786413506686,"longitude":112.57824336604547,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"xS_JIl3wxQrhMPdpcjcSn","latitude":23.17820934975604,"longitude":112.5781357731637,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]}],"baseSpeed":3,"gimbalYaw":0,"gimbalPitch":0,"alt":100}', },
},
}, */ }, */
], ],
hangarTaskList: { hangarTaskList: {
...@@ -123,7 +165,7 @@ export default { ...@@ -123,7 +165,7 @@ export default {
}, },
computed: { computed: {
scene() { scene() {
return _this.scene ? 1 : 2; return this.scene1 ? 1 : 2;
}, },
}, },
watch: { watch: {
...@@ -290,8 +332,7 @@ export default { ...@@ -290,8 +332,7 @@ export default {
data: { data: {
name: "获取航线" + airwayId, name: "获取航线" + airwayId,
id: airwayId, id: airwayId,
content: content: airway,
'{"filename":"肇庆航线20240318","line":{"baseSpeed":3},"content":[{"uuid":"1nmI-Fo18IagbcVJsia7Q","latitude":23.178153411812204,"longitude":112.57807281336807,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"9pTbBPlF8iIwbUNqusyHK","latitude":23.17783116525969,"longitude":112.57797543441967,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"s91IhN22wuaeyG-UQs0XR","latitude":23.17786413506686,"longitude":112.57824336604547,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]},{"uuid":"xS_JIl3wxQrhMPdpcjcSn","latitude":23.17820934975604,"longitude":112.5781357731637,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[]}],"baseSpeed":3,"gimbalYaw":0,"gimbalPitch":0,"alt":100}',
}, },
}); });
}, },
...@@ -314,8 +355,7 @@ export default { ...@@ -314,8 +355,7 @@ export default {
isSafe: 1, // 安全状态1: 安全 , 0: 待确定, isSafe: 1, // 安全状态1: 安全 , 0: 待确定,
labelName: "航线标签", labelName: "航线标签",
//航线数据 //航线数据
content: content: airway,
'{"filename":"盐城基地拍照录像","line":{"baseSpeed":6},"content":[{"uuid":"1uamoBnUN8je_2s5O7LAI","latitude":33.326034986025924,"longitude":120.2855868204341,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[{"id":2,"label":"拍照","key":"photo","checked":true,"value":1,"unit":"张"}]},{"uuid":"0V_BPu2m3u-zsCIVKRR7v","latitude":33.32572118330467,"longitude":120.28452270932941,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[{"id":2,"label":"拍照","key":"photo","checked":true,"value":1,"unit":"张"}]},{"uuid":"vXX0IkeE-z0BjMcQEG3f1","latitude":33.32483291531692,"longitude":120.28544172335158,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[{"id":3,"label":"录像","key":"video","checked":true,"value":0,"unit":"s"}]},{"uuid":"L32qDDlAiMtyKjoaySxHW","latitude":33.32576947678917,"longitude":120.28641994886797,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[{"id":3,"label":"录像","key":"video","checked":true,"value":0,"unit":"s"}]},{"uuid":"FYnNBx-i3bHkbEgt3QCWF","latitude":33.326686239734364,"longitude":120.28572577154279,"alt":100,"yawAngle":0,"pitchAngle":0,"speed":3,"actions":[{"id":3,"label":"录像","key":"video","checked":true,"value":0,"unit":"s"}]}],"baseSpeed":6,"gimbalYaw":0,"gimbalPitch":0,"alt":100}',
}, },
], ],
size: 10, // 当前页记录数 size: 10, // 当前页记录数
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论