|
|
|
|
@ -31,67 +31,8 @@ import {
|
|
|
|
|
UpdateCData, DeleteCData
|
|
|
|
|
} from "@/api/api";
|
|
|
|
|
import {useRouter} from "vue-router";
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
import {ElMessage} from "element-plus";
|
|
|
|
|
|
|
|
|
|
const rulerRef = ref()
|
|
|
|
|
|
|
|
|
|
const getSocket = () => {
|
|
|
|
|
|
|
|
|
|
// const socket = new WebSocket("ws://192.168.1.123:7789/ws");
|
|
|
|
|
const socket = new WebSocket("ws://192.168.1.123:7789/ws");
|
|
|
|
|
|
|
|
|
|
// 2. 连接成功时触发
|
|
|
|
|
socket.addEventListener("open", () => {
|
|
|
|
|
console.log("✅ WebSocket 连接成功");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 3. 接收消息
|
|
|
|
|
socket.addEventListener("message", (event) => {
|
|
|
|
|
processData(JSON.parse(event.data))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 4. 连接关闭时触发
|
|
|
|
|
socket.addEventListener("close", () => {
|
|
|
|
|
console.log("❌ WebSocket 已关闭");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 5. 出错时触发
|
|
|
|
|
socket.addEventListener("error", (error) => {
|
|
|
|
|
console.error("⚠️ WebSocket 出错:", error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const processData = (data) => {
|
|
|
|
|
if (data.FodName === '雷达信息') {
|
|
|
|
|
radarWorkState.value = data.radar_work_state
|
|
|
|
|
}
|
|
|
|
|
if (data.FodName === '图像数据') {
|
|
|
|
|
}
|
|
|
|
|
if (data.FodName === 'fod信息') {
|
|
|
|
|
console.log('障碍物信息', data)
|
|
|
|
|
setDot(data)
|
|
|
|
|
}
|
|
|
|
|
if (data.ty === 3) {
|
|
|
|
|
}
|
|
|
|
|
if (data.FodName === '车辆信息') {
|
|
|
|
|
currentPosition.value = {
|
|
|
|
|
lon: data.Longitude,
|
|
|
|
|
lat: data.Latitude,
|
|
|
|
|
}
|
|
|
|
|
const rectInfo = calcRectangleFromPoints(areaPoints.value);
|
|
|
|
|
const point = {
|
|
|
|
|
lon: data.Longitude,
|
|
|
|
|
lat: data.Latitude,
|
|
|
|
|
rotate: data.HeadingAngle
|
|
|
|
|
};
|
|
|
|
|
const local = getLocalPositionRelativeToP4(point, areaPoints.value, rectInfo);
|
|
|
|
|
|
|
|
|
|
boxPos.value = local
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const TOP = defineComponent({
|
|
|
|
|
name: 'TOP',
|
|
|
|
|
setup() {
|
|
|
|
|
@ -634,6 +575,67 @@ const RIGHT = defineComponent({
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
const rulerRef = ref()
|
|
|
|
|
|
|
|
|
|
const getSocket = () => {
|
|
|
|
|
|
|
|
|
|
// const socket = new WebSocket("ws://192.168.1.123:7789/ws");
|
|
|
|
|
const socket = new WebSocket("ws://192.168.1.123:7789/ws");
|
|
|
|
|
|
|
|
|
|
// 2. 连接成功时触发
|
|
|
|
|
socket.addEventListener("open", () => {
|
|
|
|
|
console.log("✅ WebSocket 连接成功");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 3. 接收消息
|
|
|
|
|
socket.addEventListener("message", (event) => {
|
|
|
|
|
processData(JSON.parse(event.data))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 4. 连接关闭时触发
|
|
|
|
|
socket.addEventListener("close", () => {
|
|
|
|
|
console.log("❌ WebSocket 已关闭");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 5. 出错时触发
|
|
|
|
|
socket.addEventListener("error", (error) => {
|
|
|
|
|
console.error("⚠️ WebSocket 出错:", error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const processData = (data) => {
|
|
|
|
|
if (data.FodName === '雷达信息') {
|
|
|
|
|
radarWorkState.value = data.radar_work_state
|
|
|
|
|
}
|
|
|
|
|
if (data.FodName === '图像数据') {
|
|
|
|
|
}
|
|
|
|
|
if (data.FodName === 'fod信息') {
|
|
|
|
|
console.log('障碍物信息', data)
|
|
|
|
|
setDot(data)
|
|
|
|
|
}
|
|
|
|
|
if (data.ty === 3) {
|
|
|
|
|
}
|
|
|
|
|
if (data.FodName === '车辆信息') {
|
|
|
|
|
currentPosition.value = {
|
|
|
|
|
lon: data.Longitude,
|
|
|
|
|
lat: data.Latitude,
|
|
|
|
|
}
|
|
|
|
|
const rectInfo = calcRectangleFromPoints(areaPoints.value);
|
|
|
|
|
const point = {
|
|
|
|
|
lon: data.Longitude,
|
|
|
|
|
lat: data.Latitude,
|
|
|
|
|
rotate: data.HeadingAngle
|
|
|
|
|
};
|
|
|
|
|
const local = correctDeviation(getLocalPositionRelativeToP4(point, areaPoints.value, rectInfo))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boxPos.value = local
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 默认方法
|
|
|
|
|
const onSubmit = (e) => {
|
|
|
|
|
console.log(e)
|
|
|
|
|
@ -728,7 +730,6 @@ const saveParasSignalproForm = () => {
|
|
|
|
|
// 保存路线设置
|
|
|
|
|
const saveParasPosForm = () => {
|
|
|
|
|
setParasPos(parasPosForm.value).then(e => {
|
|
|
|
|
console.log(e)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 更新路线数量
|
|
|
|
|
@ -863,11 +864,6 @@ function calcRectangleFromPoints(points) {
|
|
|
|
|
|
|
|
|
|
const bottomAngleRad = Math.atan2(p1.y - p4.y, p1.x - p4.x);
|
|
|
|
|
const angleDeg = bottomAngleRad * 180 / Math.PI;
|
|
|
|
|
console.log({
|
|
|
|
|
width: Number(width.toFixed(2)),
|
|
|
|
|
height: Number(height.toFixed(2)),
|
|
|
|
|
angle: Number(angleDeg.toFixed(6))
|
|
|
|
|
})
|
|
|
|
|
return {
|
|
|
|
|
width: Number(width.toFixed(2)),
|
|
|
|
|
height: Number(height.toFixed(2)),
|
|
|
|
|
@ -902,6 +898,25 @@ function getLocalPositionRelativeToP4(point, rectPoints, rectInfo) {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 偏差值
|
|
|
|
|
const deviationValue = ref({})
|
|
|
|
|
// 设置偏差值
|
|
|
|
|
const getDeviationValue = (e) => {
|
|
|
|
|
if (!e) return
|
|
|
|
|
const rectInfo = calcRectangleFromPoints(areaPoints.value);
|
|
|
|
|
const local = getLocalPositionRelativeToP4(e, areaPoints.value, rectInfo);
|
|
|
|
|
deviationValue.value = local;
|
|
|
|
|
}
|
|
|
|
|
// 修正偏差
|
|
|
|
|
const correctDeviation = (e) => {
|
|
|
|
|
let numH = deviationValue.value.y
|
|
|
|
|
let numW = deviationValue.value.x
|
|
|
|
|
let Ratio = e.y / numH
|
|
|
|
|
return {
|
|
|
|
|
...e,
|
|
|
|
|
x: e.x - numW * Ratio
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const getPoint = (k) => {
|
|
|
|
|
regionLabeling.value[k].lon = currentPosition.value.lon || 0
|
|
|
|
|
regionLabeling.value[k].lat = currentPosition.value.lat || 0
|
|
|
|
|
@ -916,11 +931,10 @@ const setDot = (e) => {
|
|
|
|
|
lat: v.Lat,
|
|
|
|
|
rotate: 0
|
|
|
|
|
};
|
|
|
|
|
const local = getLocalPositionRelativeToP4(point, areaPoints.value, rectInfo);
|
|
|
|
|
const local = correctDeviation(getLocalPositionRelativeToP4(point, areaPoints.value, rectInfo))
|
|
|
|
|
|
|
|
|
|
return local
|
|
|
|
|
}).filter(v => v)]
|
|
|
|
|
console.log(dots.value)
|
|
|
|
|
tableData1.value = [...tableData1.value, ...fodInfo.map((v, k) => {
|
|
|
|
|
return {...v, index: tableData1.value.length + k}
|
|
|
|
|
})]
|
|
|
|
|
@ -932,7 +946,6 @@ const table1Current = (e, v) => {
|
|
|
|
|
} else {
|
|
|
|
|
dotIndex.value = e.index || 0
|
|
|
|
|
}
|
|
|
|
|
console.log(e)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -968,7 +981,28 @@ const getArea2 = () => {
|
|
|
|
|
// 区域标定信息
|
|
|
|
|
const regionLabeling = ref([])
|
|
|
|
|
// 区域点位信息
|
|
|
|
|
const areaPoints = ref([])
|
|
|
|
|
const areaPoints = ref([
|
|
|
|
|
{
|
|
|
|
|
name: '点位1',
|
|
|
|
|
lon: 120.263824,
|
|
|
|
|
lat: 36.985199,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '点位2',
|
|
|
|
|
lon: 120.271545,
|
|
|
|
|
lat: 36.9816399,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '点位3',
|
|
|
|
|
lon: 120.271736,
|
|
|
|
|
lat: 36.9818535,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '点位4',
|
|
|
|
|
lon: 120.264008,
|
|
|
|
|
lat: 36.985424,
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
// 保存区域信息
|
|
|
|
|
const saveAreaPoint = () => {
|
|
|
|
|
let arr = []
|
|
|
|
|
@ -980,6 +1014,8 @@ const saveAreaPoint = () => {
|
|
|
|
|
ElMessage.success('保存成功')
|
|
|
|
|
let data = calcRectangleFromPoints(areaPoints.value)
|
|
|
|
|
areaData.value = data
|
|
|
|
|
getDeviationValue(areaPoints.value.find(e => e.name === '点位3'))
|
|
|
|
|
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
ElMessage.error(err)
|
|
|
|
|
})
|
|
|
|
|
@ -991,15 +1027,44 @@ const getAreaData = () => {
|
|
|
|
|
areaPoints.value = res.data
|
|
|
|
|
let data = calcRectangleFromPoints(res.data)
|
|
|
|
|
areaData.value = data
|
|
|
|
|
getDeviationValue(res.data.find(e => e.name === '点位3'))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const testFun = () => {
|
|
|
|
|
let data = calcRectangleFromPoints(areaPoints.value)
|
|
|
|
|
areaData.value = data
|
|
|
|
|
getDeviationValue(areaPoints.value.find(e => e.name === '点位3'))
|
|
|
|
|
let data1 = {
|
|
|
|
|
lon: 120.2716405,
|
|
|
|
|
lat: 36.9817467,
|
|
|
|
|
rotate: 303
|
|
|
|
|
}
|
|
|
|
|
const getLocal = () => {
|
|
|
|
|
const rectInfo = calcRectangleFromPoints(areaPoints.value);
|
|
|
|
|
|
|
|
|
|
const local = correctDeviation(getLocalPositionRelativeToP4(data1, areaPoints.value, rectInfo))
|
|
|
|
|
boxPos.value = local
|
|
|
|
|
}
|
|
|
|
|
getLocal()
|
|
|
|
|
let fx = 1
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
data1.lon += fx * -0.0077245 * 0.01 / 60
|
|
|
|
|
data1.lat += fx * 0.0035648 * 0.01 / 60
|
|
|
|
|
getLocal()
|
|
|
|
|
}, 1000 / 60)
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
fx *= -1
|
|
|
|
|
}, 1000 * 80)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getTableData()
|
|
|
|
|
getSocket()
|
|
|
|
|
getOption()
|
|
|
|
|
getShildTableList()
|
|
|
|
|
// testFun()
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<style>
|
|
|
|
|
|