42 lines
5.1 KiB
HTML
42 lines
5.1 KiB
HTML
|
|
<!doctype html><html lang="zh-CN"><meta charset="UTF-8"><title>机械臂单位检查</title>
|
||
|
|
<style>body{font:14px Arial;margin:24px;background:#f5f7fa;color:#303133}main{width:min(760px,95vw);margin:auto;background:white;padding:24px}.qa-nav{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:16px}pre{white-space:pre-wrap;background:#f5f7fa;padding:12px}</style>
|
||
|
|
<main><h2>机械臂位置与单位</h2><p>模拟读取 SDK 数据,仅检查单位与参数;不连接设备,不执行运动。</p><label>坐标系场景 <select id="frame-case"><option>正常列表</option><option>空列表</option><option>读取失败</option></select></label><div id="app"></div><pre id="result"></pre><pre id="queries"></pre></main>
|
||
|
|
<script type="module">
|
||
|
|
import {createApp,h,ref} from 'vue'
|
||
|
|
import ElementPlus from 'element-plus'
|
||
|
|
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||
|
|
import 'element-plus/dist/index.css'
|
||
|
|
import Basic from '/src/cmvr/common/views/flow/components/params/BasicNodeParams.vue'
|
||
|
|
import Queue from '/src/cmvr/common/views/flow/components/params/ActionQueueParams.vue'
|
||
|
|
import {setupStore} from '/src/store/index.ts'
|
||
|
|
import {setupI18n} from '/src/plugins/vueI18n/index.ts'
|
||
|
|
import {setupGlobCom} from '/src/components/index.ts'
|
||
|
|
import request from '/src/cmvr/request.ts'
|
||
|
|
import {service} from '/src/config/axios/service.ts'
|
||
|
|
const report=value=>document.querySelector('#result').textContent=JSON.stringify(value,null,2)
|
||
|
|
const queries=[]
|
||
|
|
const response=(config,data)=>({data:{code:200,data},status:200,statusText:'OK',headers:{},config})
|
||
|
|
request.defaults.adapter=async config=>{
|
||
|
|
if(config.method!=='get')throw Error('禁止设备控制与业务写入')
|
||
|
|
if(config.url==='/resource/robots')return {...response(config,null),data:{code:200,rows:[{robotId:'QA-UNITS',robotName:'单位检查工位'}]}}
|
||
|
|
if(config.url==='/resource/robots/QA-UNITS/devices')return response(config,[{deviceId:'qa-arm',deviceKind:2,deviceName:'模拟机械臂'}])
|
||
|
|
if(config.url==='/api/arm/frames'&&config.params?.robotId==='QA-UNITS'){
|
||
|
|
const scene=document.querySelector('#frame-case').value
|
||
|
|
if(scene==='读取失败')throw Error('模拟:当前机械臂未返回坐标系')
|
||
|
|
return response(config,scene==='空列表'?{baseFrames:[],tcpFrames:[]}:{baseFrames:['机械臂基座','夹具坐标系'],tcpFrames:['法兰','扫描头_TCP']})
|
||
|
|
}
|
||
|
|
if(config.url==='/api/arm/getPose'&&config.params?.robotId==='QA-UNITS'){queries.push(config.params);document.querySelector('#queries').textContent=JSON.stringify(queries,null,2);return response(config,{x:0.123,y:-0.045,z:0.6,rx:Math.PI/2,ry:0,rz:-Math.PI})}
|
||
|
|
if(config.url==='/api/arm/getJointState'&&config.params?.robotId==='QA-UNITS')return response(config,{position:[0,Math.PI/2,-Math.PI,0,0,0]})
|
||
|
|
throw Error('未声明的设备请求已拒绝:'+config.url)
|
||
|
|
}
|
||
|
|
service.defaults.adapter=async()=>{throw Error('禁止业务请求')}
|
||
|
|
const input=(name,value)=>({name,type:'input',input:value,disabled:true})
|
||
|
|
const linear={id:'qa-linear',type:'serviceNode',properties:{name:'原有机械臂运动',action:'ARM_MOVE_TO_POINT',nodeType:'EDGE',executionTarget:{roleKey:'arm',deviceSlotKey:'arm'},nodeParams:[...['x','y','z','rx','ry','rz'].map(k=>input(k,0)),{...input('velocity',0.1),componentType:'number'},{...input('acceleration',0.2),componentType:'number'}],outputParams:[]}}
|
||
|
|
const joint={id:'qa-joint',type:'serviceNode',properties:{name:'原有关节运动',action:'ARM_MOVE_TO_J',nodeType:'EDGE',executionTarget:{roleKey:'arm',deviceSlotKey:'arm'},nodeParams:[input('target','[0,0,0,0,0,0]'),{...input('velocity',0.1),componentType:'number'},{...input('acceleration',0.2),componentType:'number'}],outputParams:[]}}
|
||
|
|
const queue={id:'qa-queue',type:'actionQueue',properties:{action:'SYSTEM_EXECUTE_ACTION_QUEUE',executionTarget:{roleKey:'arm'},nodeParams:[input('steps',[{type:'ARM_MOVE_L',stepName:'直线运动',deviceSlotKey:'arm',timeoutMs:60000,params:{x:.123,y:0,z:0,rx:Math.PI/2,ry:0,rz:0,velocity:.1,acceleration:.2}},{type:'ARM_MOVE_J',stepName:'关节运动',deviceSlotKey:'arm',timeoutMs:60000,params:{positions:[0,Math.PI/2,0,0,0,0],velocity:.1,acceleration:.2}}])]}}
|
||
|
|
const graph={nodes:[{id:'start',type:'start',properties:{name:'开始',resourceRoles:[{roleKey:'arm',displayName:'机械臂工位',deviceSlots:[{slotKey:'arm',deviceKind:2,displayName:'机械臂'}]}]}},linear,joint,queue],edges:[]}
|
||
|
|
window.lf={getGraphData:()=>graph,setProperties:(id,value)=>{graph.nodes.find(n=>n.id===id).properties=value;if(!value.nodeParams)return;report({id,values:Object.fromEntries(value.nodeParams.map(p=>[p.name,p.input])),labels:value.nodeParams.map(p=>p.label),target:value.executionTarget})}}
|
||
|
|
const app=createApp({setup(){const page=ref('linear'),editor=ref(),node=()=>page.value==='joint'?joint:linear;return()=>h('div',[h('nav',{class:'qa-nav'},[...['linear','joint','queue'].map((key,i)=>h('button',{onClick:()=>page.value=key},['普通运动','关节运动','动作队列'][i])),h('button',{onClick:()=>editor.value.validateAndSave()},'保存并查看参数')]),page.value==='queue'?h(Queue,{ref:editor,data:queue,key:'queue'}):h(Basic,{ref:editor,data:node(),key:page.value})])}})
|
||
|
|
setupStore(app);await setupI18n(app);setupGlobCom(app);app.use(ElementPlus,{locale:zhCn});app.mount('#app')
|
||
|
|
</script></html>
|