feat(flow): 添加机械臂关节运动节点支持
- 在BasicNodeParams.vue中为ARM_MOVE_TO_J操作添加按钮显示逻辑 - 从设备API导入getArmJointState方法用于获取机械臂关节状态 - 实现ARM_MOVE_TO_J操作的表单验证和位置获取逻辑 - 在config.js中添加booleanOptions选项配置 - 添加机械臂关节运动节点配置,包括参数定义和属性设置
This commit is contained in:
parent
bffa17a6a2
commit
9715101faf
@ -76,4 +76,12 @@ export function getAgvStatus(params) {
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function getArmJointState(params) {
|
||||
return request({
|
||||
url: '/api/arm/getJointState',
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
</el-button>
|
||||
</template>
|
||||
<div class="form__container">
|
||||
<el-button type="primary" v-if="['AGV_MOVE_TO_POINT', 'ARM_MOVE_TO_POINT'].includes(props.data.properties.action)" size="small" @click="openRobotForm(props.data.properties.action)">获取位置</el-button>
|
||||
<el-button type="primary" v-if="['AGV_MOVE_TO_POINT', 'ARM_MOVE_TO_POINT', 'ARM_MOVE_TO_J'].includes(props.data.properties.action)" size="small" @click="openRobotForm(props.data.properties.action)">获取位置</el-button>
|
||||
<el-form :inline="true" :model="formData" :rules="rules" ref="dynamicFormRef" label-position="top"
|
||||
label-width="auto">
|
||||
<div v-for="(property, index) in formData.nodeParams" :key="index">
|
||||
@ -106,7 +106,7 @@ import { Plus, Minus } from '@element-plus/icons-vue'
|
||||
import FormItemRecursive from '../FormItemRecursive.vue'
|
||||
import { getInput } from '@/utils/flow'
|
||||
import { useQuote } from './useQuote.js'
|
||||
import { getArmStatus, getAgvStatus } from '@/api/device/flow'
|
||||
import { getArmStatus, getArmJointState, getAgvStatus } from '@/api/device/flow'
|
||||
import { de } from 'element-plus/es/locale/index.mjs'
|
||||
|
||||
const props = defineProps({
|
||||
@ -298,6 +298,30 @@ const submitRobotForm = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
} else if (robotFormAction.value === 'ARM_MOVE_TO_J') {
|
||||
robotFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
const response = await getArmJointState({
|
||||
deviceId: robotForm.deviceId,
|
||||
terminalId: robotForm.terminalId
|
||||
})
|
||||
if (response && response.data) {
|
||||
const target = response.data.position || response.data.positions
|
||||
if (!Array.isArray(target) || target.length === 0) {
|
||||
throw new Error('机械臂未返回有效的关节位置')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
const targetParam = formData.nodeParams.find(param => param.name === 'target')
|
||||
const deviceParam = formData.nodeParams.find(param => param.name === 'deviceId')
|
||||
if (targetParam) targetParam.input = JSON.stringify(target)
|
||||
if (deviceParam) deviceParam.input = robotForm.deviceId
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取机械臂关节位置失败:', error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,4 +407,4 @@ defineExpose({ validateAndSave })
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -37,6 +37,11 @@ const audioOptions = () => {
|
||||
}]
|
||||
}
|
||||
|
||||
const booleanOptions = () => [
|
||||
{ value: false, label: '否' },
|
||||
{ value: true, label: '是' }
|
||||
]
|
||||
|
||||
const httpMethodOptions = () => {
|
||||
return [{
|
||||
value: 'POST',
|
||||
@ -360,6 +365,24 @@ function handler(params) {
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: videoSvg,
|
||||
name: "机械臂关节运动",
|
||||
type: "serviceNode",
|
||||
desc: "通过关节空间插值运动到目标关节位置",
|
||||
action: 'ARM_MOVE_TO_J',
|
||||
nodeType: 'EDGE',
|
||||
nodeParams: [
|
||||
{ name: "deviceId", type: "input", input: "", disabled: true },
|
||||
{ name: "target", type: "input", input: "[0, 0, 0, 0, 0, 0]", disabled: true },
|
||||
{ name: "velocity", type: "input", componentType: 'number', max: 5, step: 0.1, input: 0.5, disabled: true },
|
||||
{ name: "acceleration", type: "input", componentType: 'number', max: 5, step: 0.1, input: 1, disabled: true },
|
||||
{ name: "blendRadius", type: "input", componentType: 'number', max: 5, step: 0.01, input: 0, required: false, disabled: true },
|
||||
{ name: "jointVelocityLimits", type: "input", input: "", required: false, disabled: true },
|
||||
{ name: "asynchronous", type: "input", input: false, componentType: 'select', selectOptions: booleanOptions(), required: false, disabled: true }
|
||||
],
|
||||
outputType: 'json'
|
||||
},
|
||||
{
|
||||
icon: cameraSvg,
|
||||
name: "开始监听报警事件",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user