初始化位置

This commit is contained in:
ywb
2026-05-18 09:07:56 +08:00
parent 0dfd20b17b
commit a4c8171c42
2 changed files with 71 additions and 15 deletions
+45
View File
@@ -45,6 +45,11 @@ createApp({
agvMoveInterval: null,
agvCameraUrl: API + '/api/camera/refresh',
agvCameraTimer: null,
// 初始化定位
initPoseLoading: false,
initPoseMsg: '',
initAmclPoseLoading: false,
initAmclPoseMsg: '',
}
},
mounted() {
@@ -146,6 +151,8 @@ createApp({
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(`确定导航到坐标 (${wx.toFixed(2)}, ${wy.toFixed(2)}) 吗?`)) return
try {
const res = await fetch(API + '/api/navigate/to', {
method: 'POST',
@@ -639,6 +646,44 @@ createApp({
alert('❌ 复位请求失败: ' + e.message)
}
},
async initPose() {
if (!this.agvConnected) { alert('AGV 未连接'); return }
if (!confirm('确定要将 AMCL 初始位置设为 (0,0,0) 吗?这会重置定位。')) return
this.initPoseLoading = true
this.initPoseMsg = ''
try {
const res = await fetch(API + '/api/mission/init_pose', { method: 'POST' })
const data = await res.json()
if (data.ok) {
this.initPoseMsg = '✅ ' + (data.message || '初始化成功')
} else {
this.initPoseMsg = '❌ ' + (data.error || '初始化失败')
}
} catch (e) {
this.initPoseMsg = '❌ 请求失败: ' + e.message
}
this.initPoseLoading = false
setTimeout(() => { this.initPoseMsg = '' }, 5000)
},
async initAmclPose() {
if (!this.agvConnected) { alert('AGV 未连接'); return }
if (!confirm('确定要将 AMCL 初始位置设为 (0,0,0) 吗?这会重置定位。')) return
this.initAmclPoseLoading = true
this.initAmclPoseMsg = ''
try {
const res = await fetch(API + '/api/mission/init_pose', { method: 'POST' })
const data = await res.json()
if (data.ok) {
this.initAmclPoseMsg = '✅ ' + (data.message || '初始化成功')
} else {
this.initAmclPoseMsg = '❌ ' + (data.error || '初始化失败')
}
} catch (e) {
this.initAmclPoseMsg = '❌ 请求失败: ' + e.message
}
this.initAmclPoseLoading = false
setTimeout(() => { this.initAmclPoseMsg = '' }, 5000)
},
getPointAt(pointRow, col) {
var positions = this.missionConfig.positions || []