This commit is contained in:
ywb
2026-06-01 18:27:36 +08:00
parent 74ec30ba3f
commit e7c9621c65
7 changed files with 39 additions and 12 deletions
+16 -3
View File
@@ -858,12 +858,24 @@ createApp({
})
},
async applyAngles(angles = null) {
const targetAngles = angles || this.angleInputs
await fetch(API + '/api/arm/set_angles', {
const targetAngles = Array.isArray(angles) ? angles : this.angleInputs
if (!Array.isArray(targetAngles) || targetAngles.length !== 6) {
alert('角度数据无效,请先刷新角度')
return false
}
const res = await fetch(API + '/api/arm/set_angles', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ angles: targetAngles, speed: 500 })
})
const data = await res.json()
if (!data.ok) {
alert('应用角度失败: ' + (data.error || '机械臂未响应'))
return false
}
this.angleInputs = [...targetAngles]
setTimeout(() => this.refreshAngles(), 2000)
return true
},
async mirrorAngles() {
// 镜像角度:只取反 J1,其它不变
@@ -872,7 +884,8 @@ createApp({
// 应用到机械臂
try {
await this.applyAngles(mirrored)
const ok = await this.applyAngles(mirrored)
if (!ok) return
this.angleInputs = mirrored // 只有在成功后才更新显示
alert('✅ 角度已镜像并应用(仅 J1 取反)')
} catch (e) {