@@ -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;
}
}
-
\ No newline at end of file
+
diff --git a/src/views/flow/config.js b/src/views/flow/config.js
index a82eafe..3684e9a 100644
--- a/src/views/flow/config.js
+++ b/src/views/flow/config.js
@@ -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: "开始监听报警事件",