坐标问题

This commit is contained in:
ywb
2026-05-26 14:26:43 +08:00
parent c7042b1bba
commit 9e90b68bf1
7 changed files with 535 additions and 45 deletions
+14 -3
View File
@@ -162,20 +162,30 @@ createApp({
if (res.ok) {
const data = await res.json()
this.nav2Available = data.nav2_available
if (data.current_pos) {
this.navCurrentPos = data.current_pos
if (data.current_position) {
this.navCurrentPos = data.current_position
}
}
} catch (e) {}
},
async onMapClick(e) {
if (!this.mapMeta || !this.agvConnected) return
if (!this.mapMeta) {
this.mapMsg = '❌ 地图未加载'
setTimeout(() => { this.mapMsg = '' }, 3000)
return
}
if (!this.agvConnected) {
this.mapMsg = '❌ AGV 未连接,无法导航'
setTimeout(() => { this.mapMsg = '' }, 3000)
return
}
const rect = e.target.getBoundingClientRect()
const px = (e.clientX - rect.left) / rect.width
const py = (e.clientY - rect.top) / rect.height
const { resolution, origin } = this.mapMeta
const wx = origin[0] + px * resolution * this.mapMeta.width
const wy = origin[1] + (1 - py) * resolution * this.mapMeta.height
if (!confirm(`是否导航到该坐标?\nX: ${wx.toFixed(3)}\nY: ${wy.toFixed(3)}`)) return
try {
const res = await fetch(API + '/api/navigate/to', {
method: 'POST',
@@ -325,6 +335,7 @@ createApp({
} catch (e) { alert('保存失败: ' + e.message) }
},
async navigateToPoint() {
if (!confirm(`确认导航到该点位?\nX: ${this.pointEditor.x} Y: ${this.pointEditor.y} Yaw: ${this.pointEditor.yaw}`)) return
try {
const res = await fetch(API + '/api/navigate/to', {
method: 'POST',