From dfac8531d4ed65183ebffcbc7f88aea16f6ac64b Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Fri, 18 Apr 2025 19:53:09 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/drone/command-center-dashboard

---
 src/components/CurrentTaskDetails/ControlPanel/ControlPanel.vue |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 103 insertions(+), 14 deletions(-)

diff --git a/src/components/CurrentTaskDetails/ControlPanel/ControlPanel.vue b/src/components/CurrentTaskDetails/ControlPanel/ControlPanel.vue
index 546ab80..901d30d 100644
--- a/src/components/CurrentTaskDetails/ControlPanel/ControlPanel.vue
+++ b/src/components/CurrentTaskDetails/ControlPanel/ControlPanel.vue
@@ -126,7 +126,7 @@
 	</div>
 </template>
 <script setup>
-import ControlComPass from '../ControlComPass/ControlComPass.vue'
+import ControlComPass from '@/components/CurrentTaskDetails/ControlPanel/ControlComPass/ControlComPass.vue'
 import { KeyCode, useManualControl } from '@/hooks/controlDrone/useManualControl'
 import { droneController, exitController, postDrc, returnHome, returnHomeCancel } from '@/api/drc'
 import { ElMessage } from 'element-plus'
@@ -144,12 +144,13 @@
 	RefreshLeft,
 	RefreshRight,
 } from '@element-plus/icons-vue'
-
+import _ from 'lodash'
 import BaseControl from '@/components/CurrentTaskDetails/ControlPanel/BaseControl.vue'
 import EventBus from '@/event-bus'
 import { getPayloadControlApi, ptzControlApi } from '@/api/payload'
 
 const deviceOsdInfo = inject('deviceOsdInfo')
+const host = computed(() => deviceOsdInfo?.value?.data?.host || {})
 const taskDetails = inject('taskDetails')
 const dockSn = inject('dockSn')
 const droneSn = inject('droneSn')
@@ -183,18 +184,106 @@
 	{ name: '左', key: KeyCode.ARROW_LEFT, operate: 'left', style: { left: '-70%' } },
 ]
 
-const list4 = [
-	[
-		{ name: '焦距倍数', value: '0' },
-		{ name: '俯仰角度', value: '0.0°' },
-		{ name: '横向角度', value: '0.0°' },
-	],
-	[
-		{ name: '储存', value: '64.5G' },
-		{ name: '方向', value: '正北' },
-		{ name: '方向', value: '正北' },
-	],
-]
+const list4 = computed(() => {
+	const { longitude, latitude, height, payloads } = host?.value || {}
+	const { gimbal_pitch } = payloads?.[0] || {} //俯仰角度
+	return [
+		[
+			{ name: '焦距倍数', value: '0' },
+			{ name: '俯仰角度', value: pitchAngle.value.angle },
+			{ name: '横向角度', value: yawAngle.value.angle },
+		],
+		[
+			{ name: '储存', value: '64.5G' },
+			{ name: '方向', value: pitchAngle.value.direction },
+			{ name: '方向', value: yawAngle.value.direction },
+		],
+	]
+})
+const pitchAngle = computed(() => {
+	const { longitude, latitude, height, payloads } = host?.value || {}
+	const gimbal_pitch = payloads?.[0]?.gimbal_pitch || 0
+	let direction = ''
+	if (gimbal_pitch > -2 && gimbal_pitch < 2) {
+		direction = '正前'
+	} else if (gimbal_pitch >= 2 && gimbal_pitch < 90) {
+		direction = '斜上'
+	} else if (gimbal_pitch === 90) {
+		direction = '正上'
+	} else if (gimbal_pitch <= -2 && gimbal_pitch > -90) {
+		direction = '斜下'
+	} else if (gimbal_pitch === -90 || gimbal_pitch < -90) {
+		direction = '正下'
+	}
+	return {
+		angle: _.round(gimbal_pitch || 0, 1) + '°',
+		direction,
+	}
+})
+
+const yawAngle = computed(() => {
+	let { longitude, latitude, height, payloads, attitude_head } = host?.value || {}
+	const gimbal_pitch = payloads?.[0]?.gimbal_pitch || 0
+	const gimbal_yaw = payloads?.[0]?.gimbal_yaw || 0
+	attitude_head = attitude_head || 0
+	let yaw = ''
+	if (gimbal_yaw > 180) {
+		yaw = gimbal_yaw
+	} else {
+		yaw = gimbal_yaw - attitude_head
+	}
+	let result = 0
+	if (yaw < 0) {
+		result = yaw + 360
+	}
+	if (yaw > 0) {
+		result = yaw
+	}
+	if ((yaw > -2 && yaw < 2) || parseInt(attitude_head) === parseInt(gimbal_yaw)) {
+		result = attitude_head < 0 ? 180 + (180 + attitude_head) : attitude_head
+	}
+	let direction = ''
+	const roundResult = Math.round(result)
+	if (roundResult === 0) {
+		direction = '正北'
+	} else if (roundResult > 0 && roundResult < 45) {
+		direction = '北偏东'
+	} else if (roundResult === 45) {
+		direction = '东北'
+	} else if (roundResult > 45 && roundResult < 90) {
+		direction = '北偏东'
+	} else if (roundResult === 90) {
+		direction = '正东'
+	} else if (roundResult > 90 && roundResult < 135) {
+		direction = '东偏南'
+	} else if (roundResult === 135) {
+		direction = '东南'
+	} else if (roundResult > 135 && roundResult < 180) {
+		direction = '南偏东'
+	} else if (roundResult === 180) {
+		direction = '正南'
+	} else if (roundResult > 180 && roundResult < 225) {
+		direction = '南偏西'
+	} else if (roundResult === 225) {
+		direction = '西南'
+	} else if (roundResult > 225 && roundResult < 270) {
+		direction = '西偏南'
+	} else if (roundResult === 270) {
+		direction = '正西'
+	} else if (roundResult > 270 && roundResult < 315) {
+		direction = '西偏北'
+	} else if (roundResult === 315) {
+		direction = '西北'
+	} else if (roundResult > 315 && roundResult < 360) {
+		direction = '北偏西'
+	} else if (roundResult === 360) {
+		direction = '正北'
+	}
+	return {
+		angle: _.round(result, 1) + '°',
+		direction,
+	}
+})
 
 const deviceTopicInfo = ref({
 	pubTopic: '',

--
Gitblit v1.9.3