feat(扫描): 发布Y退50低位副本并统一点间距默认0.7
独立副本采用RX=-2范围最低加200、最高加100,RX=-1.1最低减100、最高减300。 四站逐层工具Z正反90度,切换姿态Y退50毫米,X端余量100毫米。 13个已发布方案及任务、新扫描组件默认点间距统一0.7,激光亮度保持原值。 保留旧路径、显式任务参数和冻结版本,补充迁移保护、既有回归及中文发布记录。
This commit is contained in:
parent
6072308599
commit
ae84b872f8
@ -508,7 +508,7 @@ export const SCANNER_OPERATIONS = [
|
||||
"title": "修改扫描参数",
|
||||
"action": "SCANNER_PARAMETERS",
|
||||
"defaultBody": {
|
||||
"pointDistance": 0.5,
|
||||
"pointDistance": 0.7,
|
||||
"brightness": 17
|
||||
},
|
||||
"fields": [
|
||||
@ -522,7 +522,7 @@ export const SCANNER_OPERATIONS = [
|
||||
"min": 0.05,
|
||||
"max": 10,
|
||||
"step": 0.05,
|
||||
"hint": "0.05–10;默认0.5"
|
||||
"hint": "0.05–10;默认0.7"
|
||||
},
|
||||
{
|
||||
"key": "brightness",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export const SCANNER_PARAMETER_DEFAULTS = Object.freeze({ pointDistance: 0.5, brightness: 17 })
|
||||
export const SCANNER_PARAMETER_DEFAULTS = Object.freeze({ pointDistance: 0.7, brightness: 17 })
|
||||
export const SCANNER_PARAMETER_RUN_KEY = 'scannerParameters'
|
||||
|
||||
export function validateScannerParameters(values, required = false) {
|
||||
|
||||
@ -8,6 +8,8 @@ const node = body => ({ properties: { action: 'SCANNER_PARAMETERS', nodeParams:
|
||||
test('默认参数与两个数字控件的范围一致,点间距不能被当作整数', () => {
|
||||
const operation=getScannerOperation('SCANNER_PARAMETERS')
|
||||
assert.deepEqual(operation.defaultBody, SCANNER_PARAMETER_DEFAULTS)
|
||||
assert.equal(SCANNER_PARAMETER_DEFAULTS.pointDistance,0.7)
|
||||
assert.equal(SCANNER_PARAMETER_DEFAULTS.brightness,17)
|
||||
assert.equal(operation.advanced,false)
|
||||
const distance=operation.fields.find(field=>field.key==='pointDistance')
|
||||
const brightness=operation.fields.find(field=>field.key==='brightness')
|
||||
|
||||
23
deploy/windows11/RELEASE-20261127-frame-y50-lower-z.md
Normal file
23
deploy/windows11/RELEASE-20261127-frame-y50-lower-z.md
Normal file
@ -0,0 +1,23 @@
|
||||
# 独立四站逐层工具Z90°、Y退50低位版V1
|
||||
|
||||
按用户“新建一个,不要在原版上修改”“发布新副本”的明确要求,新建并发布方法“车架扫描方案-四站逐层工具Z90°-Y退50低位版”。方法ID `37402d4843664b82b17dc9501eb77cea`,流程ID `dc99345185f6d515afff8bd805c763c7`,发布V1 `a02ccea8e279e8c9caf0acb6d6cb1dc9`对应草稿修订2,291节点、15项输入。
|
||||
|
||||
原方法 `2c9de95b98b6451583a4366817a75ed5`、流程 `363d9d50f6a851bb914ffb71348c6748` 的V2 `a8d35fd445f5369261b8a842bd5e9fee`冻结保留。原流程暂存过的本轮路径草稿已通过正常版本恢复接口恢复为V2几何内容,原维护源码未修改。随后按用户全局要求,该原方案也仅将点间距改0.7并发布V3,路径仍为原V2;本副本发布期间再次核对该原方案完全不变。既有任务绑定和冻结执行保留。
|
||||
|
||||
本副本使用独立维护文件:`scripts/frame_scan/layered-y50-length-generator.js`、`layered-y50-tool-z-planner.js`和`build_layered_y50_scan.mjs`。旧维护文件不修改。
|
||||
|
||||
## 最终参数
|
||||
|
||||
- 四站LM302/304/306/308,各自长度A、距离2;X边界仍为±(A/2+100mm),Y=距离2−232mm;长边默认80、短边默认100mm/s。点间距默认0.7,原激光亮度保留。
|
||||
- 初始退让、首层衔接平面、扫描后退让三处均为Y−50mm;保持实际退出姿态,在退让位置切换RX。
|
||||
- 以输入参考最低Z为B、参考最高Z为T=B+H:RX=-2为[B+200,T+100],RX=-1.1为[B−100,T−300]。每站先RX=-2再RX=-1.1,有效高度分别H−100和H−200;T本身仍表示输入参考最高值,不把额外100mm累计回参考值。
|
||||
- N是实际横扫层数,包含上下边界;向上蛇形,每层工具自身Z正反90°交替,换Z保持角度,奇偶末角规则不变。按工具自身Z旋转控制,不承诺J6编码器恰好变化90°。
|
||||
- 输入参考最低Z≥−300mm,H>200,N为2至100整数,层距(H−200)/(N−1)≥2mm;layerStepMm取两组较小层距,具体值保留rx2StepMm/rx11StepMm。
|
||||
|
||||
用户明确要求RX=-1.1最低Z减100mm后,派生最低可到−400mm;默认B=−222时为−322mm。这是新的工作流几何范围,不是已证实的机械臂可达空间,未修改硬件限位、安全模式或故障判断。须现场确认低位路径、碰撞及50mm退让切换空间。
|
||||
|
||||
## 验证及状态
|
||||
|
||||
Y退50和RX=-1.1整体下移的192组、15984点检查通过,含精确2mm层距;独立复核48组通过。追加RX=-2最高值加100mm后,另48组站点、6720点计算检查通过:参考最高元数据仍为T,rx2MaxZMm为T+100,RX=-1.1点数组与追加前完全一致,各组层距准确。三处Y退50mm保持实际末姿态;连续停稳0.2至2秒、20µm漂移门、旋转数学、8对采集及291节点拓扑保持。
|
||||
|
||||
最终发布图与独立维护源码逐字核对一致,点间距0.7、其他扫描设置及输入配置检查通过。未执行设备动作;本方案不要求新增后端能力。本批另将任务及新扫描参数组件默认点间距更新为0.7,前端资源通过正式Update安装;全局发布记录见`RELEASE-20261127-scanner-spacing-07.md`。
|
||||
37
deploy/windows11/RELEASE-20261127-scanner-spacing-07.md
Normal file
37
deploy/windows11/RELEASE-20261127-scanner-spacing-07.md
Normal file
@ -0,0 +1,37 @@
|
||||
# 扫描点间距默认0.7与Y退50独立副本发布
|
||||
|
||||
用户明确要求所有已发布、涉及扫描参数设置的方案统一点间距默认0.7,激光亮度不变;同时发布独立Y退50低位副本,并追加其RX=-2最高Z在参考最高值基础上加100mm。
|
||||
|
||||
## 范围与保持项
|
||||
|
||||
只读核对51个流程,37个已发布,其中13个发布头各含1个SCANNER_PARAMETERS节点。全部为静态requestJson、无字段覆盖绑定,原值点间距0.5/亮度17;没有未发布草稿冲突。另核对全部37个发布头的子流程引用,共1个引用,不指向本批受影响子版本。
|
||||
|
||||
13个原方案均正常发布新版本,只改requestJson顶层pointDistance为0.7;每个节点的亮度、其他JSON原始字段、路径、参数、拓扑、资源和旧冻结版本逐项核对保持。独立Y退50副本V1也默认0.7。旧任务已保存的显式参数和冻结执行不覆盖。
|
||||
|
||||
平台共用任务默认、新扫描参数组件及其生成源同步0.7,亮度默认17及0至17范围不变,点间距0.05至10范围不变。无需改后端协议或SDK,不操作SDK进程;前端默认通过统一platform.ps1 Update安装,保留私有YAML、证书和业务数据。
|
||||
|
||||
维护normalizer仅替换顶层pointDistance值,不再强制brightness=17;保留原始JSON整数及所有其他字节。动态body、绑定的pointDistance或重复键拒绝自动迁移,需单独审查。本批13个节点不存在这些情况。
|
||||
|
||||
## 验证与发布
|
||||
|
||||
3份原有前端回归通过;12个迁移案例覆盖亮度0、8、17及缺省保留、原始大整数、其他字段保持与动态绑定拒绝。Python生成源和中型夹具生成器语法及默认值检查通过。本批未新增依赖、配置或表结构迁移。临时验证材料按项目要求清理,保留既有回归文件。
|
||||
|
||||
独立Y退50新方法ID `37402d4843664b82b17dc9501eb77cea`,流程 `dc99345185f6d515afff8bd805c763c7`,V1 `a02ccea8e279e8c9caf0acb6d6cb1dc9`。范围为RX=-2:[B+200,T+100],RX=-1.1:[B−100,T−300],T=B+H;详见独立副本发布说明。未运行现场设备,实际低位、顶部及50mm退让切换空间需现场确认。
|
||||
|
||||
以下为13个原方案本批正常发布后的版本记录;所有历史版本保留。
|
||||
|
||||
| 方案 | 本次版本 | 版本ID |
|
||||
| --- | --- | --- |
|
||||
| 车架扫描方案-四站长度参数化逐层工具Z90°版 | V3 | `486342ae748b88f0c32955d0f781ef58` |
|
||||
| 车架扫描方案-参数化自动路径 - RX-2优先工具Z摆扫版 | V4 | `1402b166f9a5bdd153f7e34226f2512e` |
|
||||
| 车架扫描方案-参数化自动路径 - J6优先复扫提速版 | V2 | `dba31fc4f4dcce2bb89b90976ad74b35` |
|
||||
| 中型夹具扫描路径 全流程 - J6 90°复扫提速版 | V2 | `61ad5ec5ff839f94219dc3e091b4b838` |
|
||||
| 车架扫描方案-参数化自动路径 - J6交错优化版 | V9 | `37daa4c9f4c3da7b33e528ae3824990b` |
|
||||
| 大型夹具扫描路径 全流程 - 覆盖优化版 | V7 | `0de64fff52494dd03e85245d48365b4b` |
|
||||
| 大型夹具扫描路径 全流程 - 快速版 | V5 | `268cd8cc9e1e5985f1f9d71262206d39` |
|
||||
| 车架扫描方案-参数化自动路径 | V11 | `2812e93e8775b4e981e09eba35a5d7d5` |
|
||||
| 车架扫描方案-通用 | V4 | `ee4c7d6d602863c07abe11d3557131c7` |
|
||||
| 小型夹具扫描路径 全流程 | V6 | `e3138c008fddfbc584cf91c3babd35de` |
|
||||
| 中型夹具扫描路径 全流程 | V8 | `fa512be8871765e24c92b05f14677c81` |
|
||||
| 手持扫描仪扫描 | V3 | `4019d9e11e5a8047549c10bdefe6f971` |
|
||||
| 大型夹具扫描路径 全流程 | V8 | `8946d6a8bfcbb1ca252b9bd26ccfcb1a` |
|
||||
@ -243,7 +243,7 @@ QUIC上报连接与机械臂SDK的gRPC控制连接分别判断。QUIC断开或
|
||||
|
||||
### 激光亮度与点间距
|
||||
|
||||
“配置扫描参数”组件默认使用激光亮度 `brightness=17`、点间距 `pointDistance=0.5`。亮度为0–17整数,允许0、不接受18;点间距为0.05–10数值。前后端均校验,其他高级参数继续保留 JSON 编辑。
|
||||
“配置扫描参数”组件默认使用激光亮度 `brightness=17`、点间距 `pointDistance=0.7`。亮度为0–17整数,允许0、不接受18;点间距为0.05–10数值。前后端均校验,其他高级参数继续保留 JSON 编辑。已保存的任务参数及显式设置仍按原值使用。
|
||||
|
||||
任务准备页可填写这两项,保存为任务运行参数 `scannerParameters`。执行已有 `SCANNER_PARAMETERS` 节点时覆盖这两个值,保留节点的其他字段和发布版本原文。表单优先使用已保存的任务值,其次节点值,缺省使用默认值。发布版本没有此节点时会明确提示添加、连接到开始采集之前并发布新版本;不静默修改冻结流程或额外下发设备命令。
|
||||
|
||||
|
||||
91
scripts/frame_scan/build_layered_y50_scan.mjs
Normal file
91
scripts/frame_scan/build_layered_y50_scan.mjs
Normal file
@ -0,0 +1,91 @@
|
||||
import fs from 'node:fs'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
// Offline independent derivative. Saving requires a NEW method/flow identity.
|
||||
// This program does not publish, move equipment, or modify the source snapshot.
|
||||
const [sourcePath, outputPath, summaryPath] = process.argv.slice(2)
|
||||
if (!sourcePath || !outputPath) throw new Error('Usage: node build_layered_y50_scan.mjs <V3-snapshot.json> <flow.json> [summary.json]')
|
||||
const source = JSON.parse(fs.readFileSync(sourcePath, 'utf8').replace(/^\uFEFF/, ''))
|
||||
assert.equal(source.published.id, '89e71764f2ec94c5c212fd00cce15947', 'Review another source before deriving a graph')
|
||||
const original = JSON.parse(source.published.flowData), graph = structuredClone(original)
|
||||
assert.equal(graph.nodes.length, 291)
|
||||
const params = n => n.properties.nodeParams || []
|
||||
const mode = n => params(n).find(p => p.name === 'mode')?.input
|
||||
const input = (name, value) => ({ name, type: 'input', input: value, required: true, disabled: true })
|
||||
const field = (name, type) => ({ name, type, children: [], required: true })
|
||||
function set(n, name, value) {
|
||||
const index = params(n).findIndex(p => p.name === name)
|
||||
if (index < 0) n.properties.nodeParams.push(value)
|
||||
else n.properties.nodeParams[index] = value
|
||||
}
|
||||
const start = graph.nodes.find(n => n.type === 'start')
|
||||
const generator = graph.nodes.find(n => params(n).some(p => p.name === 'LM302_param2_mm') && params(n).some(p => p.name === 'scan_layers'))
|
||||
assert(start && generator)
|
||||
const generatorCode = fs.readFileSync(new URL('./layered-y50-length-generator.js', import.meta.url), 'utf8')
|
||||
const plannerCode = fs.readFileSync(new URL('./layered-y50-tool-z-planner.js', import.meta.url), 'utf8')
|
||||
assert(plannerCode.includes('// LAYERED_TOOL_Z'))
|
||||
const startFields = new Map(start.properties.inputParams.map(p => [p.name, p]))
|
||||
startFields.get('scan_height_mm').desc = '参考高度H(mm);参考最高Z=输入最低Z+H。RX=-2有效高度H-100,RX=-1.1有效高度H-200;需H>200且两组相邻层均至少2mm。'
|
||||
startFields.get('scan_layers').desc = '每个RX实际横扫层数N,2至100整数,包含该组最低和最高层;第一层工具Z正转90°,第二层反转90°,逐层交替。'
|
||||
startFields.get('scan_start_z_mm').desc = '输入参考最低Z(mm,默认-222,不低于-300);RX=-2下限=此值+200,上限=参考最高Z+100;RX=-1.1下限=此值-100,上限=参考最高Z-300。默认输入时RX=-1.1最低为-322mm,须确认实际可达。'
|
||||
const orderedFields = ['long_scan_speed', 'short_scan_speed', 'fixtureFrameworkUrls', 'scan_start_z_mm', 'scan_height_mm', 'scan_layers'].map(name => startFields.get(name))
|
||||
for (const station of ['LM302', 'LM304', 'LM306', 'LM308']) {
|
||||
const name = station + '_length_mm'
|
||||
orderedFields.push({ name, type: 'number', children: [], required: true, desc: station + ' 长度A(mm,正数);以机械臂Base X=0为中心,正端X=A/2+100,负端X=-A/2-100。首层从正端开始,后续蛇形。' })
|
||||
orderedFields.push(startFields.get(station + '_param2_mm'))
|
||||
set(generator, name, { name, type: 'quote', input: '', quote: [start.id, 'input', name], quoteType: 'input', required: true, disabled: true })
|
||||
}
|
||||
orderedFields.push(startFields.get('scan_acceleration_mm'))
|
||||
assert(orderedFields.every(Boolean))
|
||||
start.properties.inputParams = orderedFields
|
||||
start.properties.name = '四站独立长度、距离2与实际层数'
|
||||
set(generator, 'code', input('code', generatorCode))
|
||||
generator.properties.name = '四站中心对称X与两组RX高度范围(每组实际N层)'
|
||||
generator.properties.desc = '各站X边界±(A/2+100mm),Base X=0须现场对准样品中心。Y=距离2-232mm;RX=-2先扫,RX=-1.1再扫;N是横扫层数,保留最低和最高层。'
|
||||
for (const station of generator.properties.outputParams.find(p => p.name === 'result').children) {
|
||||
for (const name of ['lengthMm', 'xFirstMm', 'xLastMm', 'yMm', 'layerCount', 'layerStepMm', 'rx2StepMm', 'rx11StepMm', 'overallMinZMm', 'overallMaxZMm', 'scanHeightMm']) {
|
||||
assert(!station.children.some(p => p.name === name))
|
||||
station.children.push(field(name, 'number'))
|
||||
}
|
||||
station.children.find(p => p.name === 'layerStepMm').desc = '两组中较小的层距;各组实际层距分别为rx2StepMm和rx11StepMm。'
|
||||
station.children.find(p => p.name === 'overallMinZMm').desc = '输入参考最低Z;RX=-1.1实际下限比此值低100mm。'
|
||||
}
|
||||
let helperCount = 0
|
||||
for (const n of graph.nodes) {
|
||||
if (mode(n)) { set(n, 'code', input('code', plannerCode)); helperCount++ }
|
||||
if (n.properties.action === 'SCANNER_PARAMETERS') {
|
||||
const request = params(n).find(p => p.name === 'requestJson')
|
||||
assert.equal(request?.type, 'input')
|
||||
const body = JSON.parse(request.input)
|
||||
assert.deepEqual(Object.keys(body).sort(), ['brightness', 'pointDistance'])
|
||||
request.input = JSON.stringify({ ...body, pointDistance: 0.7 }, null, 2)
|
||||
}
|
||||
if (n.properties.name) n.properties.name = n.properties.name.replaceAll('工具Z摆扫', '逐层工具Z交替90°').replaceAll('往复120°', '逐层正反90°').replaceAll('近端衔接', '正X首层衔接').replaceAll('Y退200mm', 'Y退50mm').replaceAll('Y-200mm', 'Y-50mm')
|
||||
}
|
||||
assert.equal(helperCount, 28)
|
||||
assert.equal(graph.nodes.filter(n => n.properties.action === 'SCANNER_START').length, 8)
|
||||
assert.equal(graph.nodes.filter(n => n.properties.action === 'SCANNER_STOP').length, 8)
|
||||
assert.equal(graph.nodes.filter(n => params(n).some(p => p.name === 'resultNodeId')).length, 8)
|
||||
assert.equal(graph.nodes.filter(n => n.properties.action === 'ARM_MOVE_TO_J').length, 8, 'Only original initial/safety joint movements may remain')
|
||||
// Preserve all RPC settings, strict loop exports, scanner defaults, and graph topology.
|
||||
assert.deepEqual(graph.edges, original.edges)
|
||||
for (let i = 0; i < graph.nodes.length; i++) {
|
||||
const n = graph.nodes[i], before = original.nodes[i]
|
||||
assert.equal(n.id, before.id)
|
||||
if (n.properties.action !== 'CODE' && n.properties.action !== 'SCANNER_PARAMETERS' && n.type !== 'start') assert.deepEqual(n.properties.nodeParams, before.properties.nodeParams)
|
||||
if (n.properties.action === 'SCANNER_PARAMETERS') {
|
||||
const check = structuredClone(n.properties.nodeParams)
|
||||
const old = params(before).find(p => p.name === 'requestJson')
|
||||
const body = JSON.parse(params(n).find(p => p.name === 'requestJson').input)
|
||||
assert.equal(body.pointDistance, 0.7)
|
||||
delete body.pointDistance
|
||||
const prior = JSON.parse(old.input); delete prior.pointDistance
|
||||
assert.deepEqual(body, prior, 'Keep the original brightness')
|
||||
check.find(p => p.name === 'requestJson').input = old.input
|
||||
assert.deepEqual(check, before.properties.nodeParams)
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(outputPath, JSON.stringify(graph, null, 2))
|
||||
const summary = { nodes: graph.nodes.length, sourceVersion: 3, captures: 8, stations: ['LM302','LM304','LM306','LM308'], rxOrder: [-2,-1.1], lengthInputs: 4, actualRowCountInput: 'scan_layers', xBoundaries: ['A/2+100','-A/2-100'], retreatYMm: -50, rx2MinOffsetMm: 200, rx2MaxOffsetMm: 100, rx11MinOffsetMm: -100, rx11MaxOffsetMm: -300, rowToolAnglesDeg: [[0,90],[90,0]], toolAxis: 'local Z', requiresNewMethodIdentity: true, published: false, deviceCommandsSent: 0 }
|
||||
if (summaryPath) fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2))
|
||||
console.log(JSON.stringify(summary))
|
||||
80
scripts/frame_scan/layered-y50-length-generator.js
Normal file
80
scripts/frame_scan/layered-y50-length-generator.js
Normal file
@ -0,0 +1,80 @@
|
||||
// Independent layered scan geometry. Inputs are millimetres and mm/s;
|
||||
// absolute Base/TCP points are metres/radians. This code sends no commands.
|
||||
// scan_layers is the actual number of horizontal rows, including both bounds.
|
||||
function handler(params) {
|
||||
function fail(message) { throw new Error(message); }
|
||||
function finite(value) { return typeof value === 'number' && isFinite(value); }
|
||||
function number(name) {
|
||||
var raw = params[name];
|
||||
if (raw === null || raw === undefined || typeof raw === 'boolean' ||
|
||||
(typeof raw !== 'number' && typeof raw !== 'string') || String(raw).trim() === '')
|
||||
fail(name + '必须填写有效数值');
|
||||
var value = Number(raw);
|
||||
if (!finite(value)) fail(name + '必须为有限数值');
|
||||
return value;
|
||||
}
|
||||
function computed(value, label) {
|
||||
if (!finite(value)) fail(label + '计算溢出');
|
||||
return value;
|
||||
}
|
||||
if (!params || typeof params !== 'object' || Array.isArray(params)) fail('缺少分层扫描参数');
|
||||
var height = number('scan_height_mm'), layers = number('scan_layers'), startZ = number('scan_start_z_mm');
|
||||
if (!(height > 200)) fail('扫描高度必须大于200mm');
|
||||
if (layers !== Math.floor(layers) || layers < 2 || layers > 100) fail('实际扫描层数必须为2至100的整数');
|
||||
if (startZ < -300) fail('共享最低Z不能低于-300mm');
|
||||
var longSpeed = number('long_scan_speed'), shortSpeed = number('short_scan_speed');
|
||||
if (!(longSpeed > 0) || !(shortSpeed > 0)) fail('长短边扫描速度必须为正数');
|
||||
if (!(longSpeed / 1000 > 0) || !(shortSpeed / 1000 > 0)) fail('扫描速度换算为m/s后必须为有效正数');
|
||||
var top = computed(startZ + height, '共享最高Z');
|
||||
var rx2Min = computed(startZ + 200, 'RX=-2最低Z'), rx2Max = computed(top + 100, 'RX=-2最高Z');
|
||||
var rx11Min = computed(startZ - 100, 'RX=-1.1最低Z'), rx11Max = computed(top - 300, 'RX=-1.1最高Z');
|
||||
var step2 = computed((rx2Max - rx2Min) / (layers - 1), 'RX=-2层间距');
|
||||
var step11 = computed((rx11Max - rx11Min) / (layers - 1), 'RX=-1.1层间距');
|
||||
if (!(step2 >= 2) || !(step11 >= 2)) fail('每个RX区域的相邻扫描层间距必须至少2mm');
|
||||
var stations = ['LM302', 'LM304', 'LM306', 'LM308'];
|
||||
var ry = -0.013091304695177972, rz = 0.038491946556434904;
|
||||
// Matches the existing 1e-10 m geometry tolerance; intended spacing is checked above.
|
||||
var EPS_MM = 0.0000001;
|
||||
function path(firstX, lastX, y, speed, rx, lo, hi) {
|
||||
var points = [], previousZ = null, span = computed(hi - lo, 'RX区域高度');
|
||||
if (!(span > 0) || lo < -400 || hi < lo) fail('RX扫描Z范围无效');
|
||||
for (var row = 0; row < layers; row++) {
|
||||
var z = row === layers - 1 ? hi : computed(lo + span * (row / (layers - 1)), '扫描层Z');
|
||||
if (previousZ !== null && z - previousZ < 2 - EPS_MM) fail('实际生成的相邻扫描层间距不足2mm');
|
||||
previousZ = z;
|
||||
for (var side = 0; side < 2; side++) {
|
||||
var endpoint = row % 2 === 0 ? side : 1 - side;
|
||||
var point = { x: (endpoint === 0 ? firstX : lastX) / 1000, y: y / 1000, z: z / 1000,
|
||||
rx: rx, ry: ry, rz: rz, velocity: speed / 1000 };
|
||||
var keys = ['x', 'y', 'z', 'rx', 'ry', 'rz', 'velocity'];
|
||||
for (var i = 0; i < keys.length; i++) if (!finite(point[keys[i]])) fail('扫描点坐标或速度计算溢出');
|
||||
if (point.y < 0.456 || point.z < -0.4 - 1e-10 || point.z < lo / 1000 - 1e-10 ||
|
||||
point.z > hi / 1000 + 1e-10 || !(point.velocity > 0)) fail('扫描点超出本组坐标范围或速度无效');
|
||||
points.push(point);
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
var result = {};
|
||||
for (var index = 0; index < stations.length; index++) {
|
||||
var station = stations[index], length = number(station + '_length_mm'), parameter2 = number(station + '_param2_mm');
|
||||
if (!(length > 0)) fail(station + '长度必须为正数');
|
||||
if (parameter2 < 688) fail(station + '距离2不能低于688mm');
|
||||
var firstX = computed(length / 2 + 100, station + '正端X');
|
||||
var lastX = computed(-length / 2 - 100, station + '负端X');
|
||||
var width = computed(firstX - lastX, station + '横扫长度'), y = computed(parameter2 - 232, station + '目标Y');
|
||||
if (!(width >= 2)) fail(station + '横扫长度必须至少2mm');
|
||||
if (y < 456) fail(station + '目标Y不能低于456mm');
|
||||
var speed = station === 'LM304' || station === 'LM308' ? longSpeed : shortSpeed;
|
||||
result[station] = {
|
||||
rx2Points: path(firstX, lastX, y, speed, -2, rx2Min, rx2Max),
|
||||
rx11Points: path(firstX, lastX, y, speed, -1.1, rx11Min, rx11Max),
|
||||
rx2MinZMm: rx2Min, rx2MaxZMm: rx2Max, rx11MinZMm: rx11Min, rx11MaxZMm: rx11Max,
|
||||
originalTopZMm: top, scanSpeedMm: speed,
|
||||
lengthMm: length, xFirstMm: firstX, xLastMm: lastX, yMm: y, layerCount: layers,
|
||||
layerStepMm: Math.min(step2, step11), rx2StepMm: step2, rx11StepMm: step11,
|
||||
overallMinZMm: startZ, overallMaxZMm: top, scanHeightMm: height
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
269
scripts/frame_scan/layered-y50-tool-z-planner.js
Normal file
269
scripts/frame_scan/layered-y50-tool-z-planner.js
Normal file
@ -0,0 +1,269 @@
|
||||
// TOOL_Z_RIGHT_MULTIPLY
|
||||
// LAYERED_TOOL_Z
|
||||
// LAYERED_TOOL_Z_ALTERNATING
|
||||
// Fixed input order: each X row rotates +90 degrees, the next row -90 degrees.
|
||||
// Z transitions hold that row's final angle. This is Cartesian tool rotation,
|
||||
// not a promise that actual joint J6 alone rotates by exactly 90 degrees.
|
||||
// Synchronous original corners remain; this is not a continuous-motion RPC.
|
||||
// Absolute Base/TCP poses use metres/radians. This code sends no device command.
|
||||
// R_target = R_reference * Rz(theta). Base RX/RY/RZ may all change: forcing
|
||||
// Base RX/RY to stay fixed would rotate about the wrong axis. XYZ remain Base
|
||||
// absolute targets; this is not a relative move or a changing user coordinate.
|
||||
function handler(params) {
|
||||
var MIN_EDGE = 0.002, EPS = 1e-10, MAX_POINTS = 4096;
|
||||
var AMPLITUDE = Math.PI / 2, MAX_ANGLE_STEP = Math.PI / 4;
|
||||
function fail(message) { throw new Error(message); }
|
||||
function finite(value) { return typeof value === 'number' && isFinite(value); }
|
||||
function joints(value) {
|
||||
if (typeof value === 'string') {
|
||||
try { value = JSON.parse(value); } catch (error) { fail('关节目标不是有效数组'); }
|
||||
}
|
||||
if (!Array.isArray(value) || value.length !== 6) fail('实际关节角必须为六个数值');
|
||||
for (var i = 0; i < 6; i++) if (!finite(value[i])) fail('关节角数值无效');
|
||||
return value;
|
||||
}
|
||||
function requiredPose(value, label) {
|
||||
var keys = ['x', 'y', 'z', 'rx', 'ry', 'rz'];
|
||||
if (!value) fail(label + '缺少完整TCP位姿');
|
||||
for (var i = 0; i < keys.length; i++) if (!finite(value[keys[i]])) fail(label + '的TCP位姿数值无效');
|
||||
return value;
|
||||
}
|
||||
function distance(a, b) {
|
||||
var x = a.x - b.x, y = a.y - b.y, z = a.z - b.z;
|
||||
return Math.sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
function quaternion(p) {
|
||||
var x = p.rx / 2, y = p.ry / 2, z = p.rz / 2;
|
||||
var cx = Math.cos(x), sx = Math.sin(x), cy = Math.cos(y), sy = Math.sin(y), cz = Math.cos(z), sz = Math.sin(z);
|
||||
return [sx * cy * cz - cx * sy * sz, cx * sy * cz + sx * cy * sz, cx * cy * sz - sx * sy * cz, cx * cy * cz + sx * sy * sz];
|
||||
}
|
||||
function angle(a, b) {
|
||||
var qa = quaternion(a), qb = quaternion(b), minus = 0, plus = 0;
|
||||
for (var i = 0; i < 4; i++) {
|
||||
minus += (qa[i] - qb[i]) * (qa[i] - qb[i]);
|
||||
plus += (qa[i] + qb[i]) * (qa[i] + qb[i]);
|
||||
}
|
||||
return 4 * Math.asin(Math.min(1, Math.sqrt(Math.min(minus, plus)) / 2));
|
||||
}
|
||||
function product(a, b) {
|
||||
return [a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],
|
||||
a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],
|
||||
a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],
|
||||
a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2]];
|
||||
}
|
||||
function matrix(q) {
|
||||
var x = q[0], y = q[1], z = q[2], w = q[3];
|
||||
return [1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w),
|
||||
2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w),
|
||||
2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)];
|
||||
}
|
||||
function nearest(value, previous) {
|
||||
return value + 2 * Math.PI * Math.round((previous - value) / (2 * Math.PI));
|
||||
}
|
||||
function chooseEuler(first, second, previous) {
|
||||
function candidate(value) {
|
||||
return { rx: nearest(value.rx, previous.rx), ry: nearest(value.ry, previous.ry), rz: nearest(value.rz, previous.rz) };
|
||||
}
|
||||
function cost(value) {
|
||||
var x = value.rx - previous.rx, y = value.ry - previous.ry, z = value.rz - previous.rz;
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
var a = candidate(first), b = candidate(second);
|
||||
return cost(a) <= cost(b) ? a : b;
|
||||
}
|
||||
function euler(q, previous, reference) {
|
||||
var r = matrix(q), cp = Math.sqrt(r[0] * r[0] + r[3] * r[3]);
|
||||
if (cp <= 1e-12) {
|
||||
// At pitch +/-pi/2 only rx-sign(pitch)*rz is observable. Choose its
|
||||
// nearest equivalent and share the adjustment between rx and rz.
|
||||
// This singular tolerance only absorbs floating-point round-off.
|
||||
var sign = r[6] < 0 ? 1 : -1, prior = previous.rx - sign * previous.rz;
|
||||
var combined = nearest(Math.atan2(-r[5], r[4]), prior), change = combined - prior;
|
||||
return { rx: previous.rx + change / 2, ry: nearest(sign * Math.PI / 2, previous.ry), rz: previous.rz - sign * change / 2 };
|
||||
}
|
||||
if (reference) return chooseEuler(reference, { rx: reference.rx + Math.PI, ry: Math.PI - reference.ry, rz: reference.rz + Math.PI }, previous);
|
||||
var primary = { rx: Math.atan2(r[7], r[8]), ry: Math.atan2(-r[6], cp), rz: Math.atan2(r[3], r[0]) };
|
||||
return chooseEuler(primary, { rx: primary.rx + Math.PI, ry: Math.PI - primary.ry, rz: primary.rz + Math.PI }, previous);
|
||||
}
|
||||
function toolOrientation(reference, theta, previous, first) {
|
||||
if (first) return { rx: reference.rx, ry: reference.ry, rz: reference.rz };
|
||||
var wanted = product(quaternion(reference), [0, 0, Math.sin(theta / 2), Math.cos(theta / 2)]);
|
||||
var result = euler(wanted, previous, theta === 0 ? reference : null);
|
||||
var actual = quaternion(result), minus = 0, plus = 0;
|
||||
for (var i = 0; i < 4; i++) {
|
||||
minus += (wanted[i] - actual[i]) * (wanted[i] - actual[i]);
|
||||
plus += (wanted[i] + actual[i]) * (wanted[i] + actual[i]);
|
||||
}
|
||||
if (Math.sqrt(Math.min(minus, plus)) > 1e-9) fail('工具Z轴姿态转换误差超出范围');
|
||||
return result;
|
||||
}
|
||||
function state(s) {
|
||||
if (!s || s.connected !== true || s.poweredOn !== true || s.brakeReleased !== true ||
|
||||
s.protectiveStopped !== false || s.emergencyStopped !== false || s.fault !== false ||
|
||||
s.safetyMode !== 'ARM_SAFETY_MODE_NORMAL' || s.controlMode !== 'ARM_CONTROL_MODE_POSITION')
|
||||
fail('机械臂连接、上电、制动或安全状态未确认正常');
|
||||
if (!finite(s.timestamp) || Math.abs(Date.now() / 1000 - s.timestamp) > 10) fail('机械臂实际回读状态已过期');
|
||||
if (s.moving !== false || s.programRunning !== false || s.robotMode !== 'ARM_ROBOT_MODE_IDLE') fail('机械臂尚未确认停稳');
|
||||
var q = joints(s.actualJointState && s.actualJointState.position);
|
||||
var v = s.actualJointState.velocity, t = s.actualTcpVelocity;
|
||||
if (!Array.isArray(v) || v.length !== 6 || !t) fail('停稳复核缺少关节或TCP速度');
|
||||
var keys = ['vx', 'vy', 'vz', 'wx', 'wy', 'wz'];
|
||||
for (var i = 0; i < 6; i++) {
|
||||
if (!finite(v[i]) || Math.abs(v[i]) > 0.001) fail('机械臂关节尚未连续停稳');
|
||||
if (!finite(t[keys[i]]) || Math.abs(t[keys[i]]) > 0.0001) fail('机械臂末端尚未连续停稳');
|
||||
}
|
||||
requiredPose(s.actualTcpPose, '实际回读');
|
||||
return s.actualTcpPose;
|
||||
}
|
||||
function continuous() {
|
||||
var before = params.previousState, after = params.state;
|
||||
var a = state(before), b = state(after), dt = after.timestamp - before.timestamp;
|
||||
if (dt < 0.2 || dt > 2) fail('连续停稳复核的两帧间隔必须为0.2至2秒');
|
||||
if (distance(a, b) > 0.00002 || angle(a, b) > 0.0001) fail('连续回读的TCP位姿仍在漂移');
|
||||
var qa = joints(before.actualJointState.position), qb = joints(after.actualJointState.position);
|
||||
for (var i = 0; i < 6; i++) if (Math.abs(qb[i] - qa[i]) / dt > 0.001) fail('连续关节回读尚未停稳');
|
||||
}
|
||||
function pose(p, speed) { return { x: p.x, y: p.y, z: p.z, rx: p.rx, ry: p.ry, rz: p.rz, velocity: speed }; }
|
||||
function poseMatch(actual, target) {
|
||||
requiredPose(target, '规划目标');
|
||||
if (distance(actual, target) > 0.003 || angle(actual, target) > 0.015) fail('未到指定扫描末点、退让位置或姿态,停止后续动作');
|
||||
}
|
||||
function jointMatch(actual, target) {
|
||||
actual = joints(actual); target = joints(target);
|
||||
for (var i = 0; i < 6; i++) if (Math.abs(actual[i] - target[i]) > 0.015) fail('未到原初始关节目标');
|
||||
}
|
||||
function stamp(reference, now) {
|
||||
if (!reference || !finite(reference.stamp) || now < reference.stamp) fail('实际回读时间与本阶段准备记录不一致');
|
||||
}
|
||||
function confirmedMoves(target, actual) {
|
||||
if (distance(actual, target) > 0.00005 || angle(actual, target) > 0.0001) return [target];
|
||||
continuous();
|
||||
if (distance(params.previousState.actualTcpPose, target) > 0.00005 || angle(params.previousState.actualTcpPose, target) > 0.0001)
|
||||
fail('重复衔接点缺少连续到位回读,停止发送空移动');
|
||||
return [];
|
||||
}
|
||||
function pointList(points, original) {
|
||||
var limit = original ? 200 : MAX_POINTS;
|
||||
if (!Array.isArray(points) || points.length < (original ? 4 : 2) || points.length > limit || (original && points.length % 2 !== 0))
|
||||
fail(original ? '原扫描条带必须为2至100层,每层两个端点' : '扫描点集必须为2至4096个点');
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
var p = requiredPose(points[i], '扫描点');
|
||||
if (!finite(p.velocity) || !(p.velocity > 0) || p.y < 0.456 || p.z < -0.4 - EPS) fail('扫描点速度或XYZ范围无效');
|
||||
if (original && i % 2 === 1 && (Math.abs(p.y - points[i - 1].y) > EPS || Math.abs(p.z - points[i - 1].z) > EPS))
|
||||
fail('原横扫条带两端不在同一Y/Z');
|
||||
if (i && distance(points[i - 1], p) <= 1e-12) fail('原扫描路径存在零距离重复点');
|
||||
}
|
||||
return points;
|
||||
}
|
||||
function copy(p) {
|
||||
var result = {};
|
||||
for (var key in p) if (Object.prototype.hasOwnProperty.call(p, key)) result[key] = p[key];
|
||||
return result;
|
||||
}
|
||||
function sweep(input, orientation) {
|
||||
var result = [], thetaValues = [];
|
||||
function append(p, theta) {
|
||||
var target = copy(p);
|
||||
var converted = toolOrientation(orientation, theta, result.length ? result[result.length - 1] : orientation, result.length === 0);
|
||||
target.rx = converted.rx; target.ry = converted.ry; target.rz = converted.rz;
|
||||
result.push(target); thetaValues.push(theta);
|
||||
}
|
||||
var rows = input.length / 2;
|
||||
for (var row = 0; row < rows; row++) {
|
||||
var a = input[2 * row], b = input[2 * row + 1];
|
||||
var start = row % 2 === 0 ? 0 : AMPLITUDE, end = row % 2 === 0 ? AMPLITUDE : 0;
|
||||
// The next original start point is reached along Z at the previous
|
||||
// row's final tool angle, without resetting or reordering the path.
|
||||
append(a, start);
|
||||
var steps = Math.ceil(AMPLITUDE / MAX_ANGLE_STEP), length = distance(a, b);
|
||||
if (length / steps < MIN_EDGE - EPS) fail('横扫姿态关键帧间距不足2mm');
|
||||
for (var step = 1; step <= steps; step++) {
|
||||
var t = step / steps, point = copy(b);
|
||||
if (step !== steps) {
|
||||
point.x = a.x + (b.x - a.x) * t;
|
||||
point.y = a.y + (b.y - a.y) * t;
|
||||
point.z = a.z + (b.z - a.z) * t;
|
||||
}
|
||||
append(point, step === steps ? end : start + (end - start) * t);
|
||||
if (result.length > MAX_POINTS) fail('工具Z轴分层扫描细分点超过4096个');
|
||||
}
|
||||
}
|
||||
var variation = 0;
|
||||
var referenceQ = quaternion(orientation), inverse = [-referenceQ[0], -referenceQ[1], -referenceQ[2], referenceQ[3]];
|
||||
var referenceMatrix = matrix(referenceQ);
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
// Check the intrinsic phase and physical relative axis, not the Base
|
||||
// rz difference: all three Base Euler components may change together.
|
||||
var value = thetaValues[i], actualQ = quaternion(result[i]), relative = product(inverse, actualQ);
|
||||
var expectedRelative = [0, 0, Math.sin(value / 2), Math.cos(value / 2)], minus = 0, plus = 0;
|
||||
for (var j = 0; j < 4; j++) {
|
||||
minus += (relative[j] - expectedRelative[j]) * (relative[j] - expectedRelative[j]);
|
||||
plus += (relative[j] + expectedRelative[j]) * (relative[j] + expectedRelative[j]);
|
||||
}
|
||||
if (Math.sqrt(Math.min(minus, plus)) > 1e-9) fail('姿态偏离工具自身Z轴旋转');
|
||||
var actualMatrix = matrix(actualQ);
|
||||
for (var j = 2; j < 9; j += 3) if (Math.abs(actualMatrix[j] - referenceMatrix[j]) > 1e-9) fail('工具Z轴在Base中的方向发生变化');
|
||||
if (value < -EPS || value > AMPLITUDE + EPS) fail('工具Z轴转角超出本层0至90度范围');
|
||||
if (i) {
|
||||
var difference = value - thetaValues[i - 1];
|
||||
if (Math.abs(difference) > MAX_ANGLE_STEP + EPS || angle(result[i - 1], result[i]) > MAX_ANGLE_STEP + EPS) fail('相邻工具姿态关键帧超过45度');
|
||||
if (Math.abs(difference) > EPS && distance(result[i - 1], result[i]) < MIN_EDGE - EPS) fail('工具转角变化段XYZ间距不足2mm');
|
||||
if (Math.abs(result[i].z - result[i - 1].z) > EPS && Math.abs(difference) > EPS) fail('Z换层期间不能额外改变工具转角');
|
||||
variation += Math.abs(difference);
|
||||
}
|
||||
}
|
||||
var expectedLast = rows % 2 === 0 ? 0 : AMPLITUDE;
|
||||
if (thetaValues[0] !== 0 || thetaValues[thetaValues.length - 1] !== expectedLast || angle(result[0], orientation) > 1e-9 ||
|
||||
Math.abs(variation - rows * AMPLITUDE) > EPS) fail('工具Z轴未完成每层正负90度交替扫描');
|
||||
for (var row = 0; row < rows; row++) {
|
||||
var first = row * (steps + 1), last = first + steps;
|
||||
if (thetaValues[first] !== (row % 2 === 0 ? 0 : AMPLITUDE) || thetaValues[last] !== (row % 2 === 0 ? AMPLITUDE : 0))
|
||||
fail('工具Z轴每层起止角不符合交替规则');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var actual = state(params.state), now = params.state.timestamp;
|
||||
if (params.mode === 'offset_initial') {
|
||||
jointMatch(params.state.actualJointState.position, params.initialJoints);
|
||||
var initialRetreat = pose(actual, 0.15); initialRetreat.y -= 0.05;
|
||||
return { retreatPose: initialRetreat, stamp: now };
|
||||
}
|
||||
if (params.mode === 'rx_target') {
|
||||
stamp(params.offset, now); stamp(params.reference, now);
|
||||
poseMatch(actual, requiredPose(params.offset.retreatPose, '当前退让位置'));
|
||||
var reference = requiredPose(params.reference.retreatPose, '本站最初姿态基准');
|
||||
if (params.rx !== -2 && params.rx !== -1.1) fail('RX目标必须为-2或-1.1rad');
|
||||
var target = pose(actual, 0.06); target.rx = params.rx; target.ry = reference.ry; target.rz = reference.rz;
|
||||
return { targetPose: target, stamp: now };
|
||||
}
|
||||
if (params.mode === 'scan') {
|
||||
continuous(); stamp(params.rotation, now);
|
||||
var rotation = requiredPose(params.rotation.targetPose, '本组原RX姿态');
|
||||
poseMatch(actual, rotation);
|
||||
var original = pointList(params.points, true), lo = params.minZMm / 1000, hi = params.maxZMm / 1000;
|
||||
if (!finite(lo) || !finite(hi) || !(hi > lo) || lo < -0.4 - EPS || (rotation.rx !== -2 && rotation.rx !== -1.1)) fail('RX扫描Z范围无效');
|
||||
for (var i = 0; i < original.length; i++)
|
||||
if (Math.abs(original[i].rx - rotation.rx) > EPS || original[i].z < lo - EPS || original[i].z > hi + EPS)
|
||||
fail('原扫描点超出本组RX或Z范围');
|
||||
var positiveX = original[0].x, negativeX = original[1].x, fixedY = original[0].y;
|
||||
if (!(positiveX > 0) || !(negativeX < 0) || Math.abs(positiveX + negativeX) > EPS) fail('每组扫描必须从对称X正侧端点开始');
|
||||
if (Math.abs(original[0].z - lo) > EPS || Math.abs(original[original.length - 1].z - hi) > EPS) fail('首末横扫层必须覆盖本组最低和最高Z');
|
||||
for (var row = 0; row < original.length / 2; row++) {
|
||||
var a = original[row * 2], b = original[row * 2 + 1];
|
||||
if (Math.abs(a.x - (row % 2 === 0 ? positiveX : negativeX)) > EPS || Math.abs(b.x - (row % 2 === 0 ? negativeX : positiveX)) > EPS ||
|
||||
Math.abs(a.y - fixedY) > EPS || Math.abs(b.y - fixedY) > EPS) fail('原X端点或Y不符合固定起点蛇形扫描顺序');
|
||||
if (row && a.z - original[(row - 1) * 2].z < MIN_EDGE - EPS) fail('实际横扫层的Z必须递增且层距至少2mm');
|
||||
}
|
||||
var points = sweep(original, rotation);
|
||||
var entry = pose(points[0], 0.15), hover = pose(points[0], 0.15); hover.y -= 0.05;
|
||||
return { points: points, scanPoints: points.slice(1), hover: hover, hoverMoves: confirmedMoves(hover, actual), entry: entry, count: points.length, stamp: now };
|
||||
}
|
||||
if (params.mode === 'offset') {
|
||||
var completed = pointList(params.completedPoints, false), last = completed[completed.length - 1];
|
||||
poseMatch(actual, last);
|
||||
var retreat = pose(last, 0.15); retreat.y -= 0.05;
|
||||
retreat.rx = actual.rx; retreat.ry = actual.ry; retreat.rz = actual.rz;
|
||||
return { retreatPose: retreat, stamp: now };
|
||||
}
|
||||
fail('工具Z轴逐层扫描规划模式无效');
|
||||
}
|
||||
@ -22,7 +22,7 @@ templates={
|
||||
'FRAMEWORK_IMPORT':{'fileIds':[]},
|
||||
'DISCONNECT':{'discardProject':False,'expectedProjectId':None,'expectedSessionId':None},
|
||||
'RECONNECT':{'discardProject':False,'expectedProjectId':None,'expectedSessionId':None,'deviceType':3},
|
||||
'PARAMETERS':{'pointDistance':0.5,'brightness':17}, 'MESH':{},
|
||||
'PARAMETERS':{'pointDistance':0.7,'brightness':17}, 'MESH':{},
|
||||
'EXPORT':{'formats':['PLY']}, 'SNAPSHOT':{'maxPoints':100000,'include':['points','markers','meshes']},
|
||||
'ALIGN':{'action':'enter'}, 'EDIT':{'projectUuid':'','markerIds':[]},
|
||||
'CLIP_PLANE':{'center':[0,0,0],'normal':[0,0,1],'deleteBelowPoints':False,'deleteBelowMarkers':False},
|
||||
@ -115,7 +115,7 @@ def main():
|
||||
fields[-1].update(label='标定类别',hint='标定类别与快速/标准/精细不同;实际硬件支持由设备服务确认。')
|
||||
if key=='mode' and name=='CREATE_PROJECT':fields[-1]['label']='工程模式'
|
||||
if name=='PARAMETERS' and key=='brightness':fields[-1].update(min=0,max=17,step=1,precision=0,integer=True,hint='0–17,整数;默认17')
|
||||
if name=='PARAMETERS' and key=='pointDistance':fields[-1].update(min=0.05,max=10,step=0.05,hint='0.05–10;默认0.5')
|
||||
if name=='PARAMETERS' and key=='pointDistance':fields[-1].update(min=0.05,max=10,step=0.05,hint='0.05–10;默认0.7')
|
||||
if name=='CALIBRATION_RECOVER' and key=='force':fields[-1].update(hint='需要强制恢复时启用;仍检查设备占用、未结束任务及当前会话。')
|
||||
if name=='CALIBRATION_RECOVER' and key=='expectedSessionId':fields[-1].update(label='当前设备会话编号',optional=True,hint='留空时在恢复前自动读取 /api/v1/status 的 sessionId;手动填写或引用的编号须与当前会话一致。')
|
||||
records.append(dict(key=name,method=method,path='/metadata' if path=='/' else path.removeprefix('/api/v1'),
|
||||
|
||||
@ -87,7 +87,7 @@ const start=order[0]
|
||||
for(const item of order.filter(item=>item.properties.action==='SCANNER_PARAMETERS')){
|
||||
const request=item.properties.nodeParams.find(parameter=>parameter.name==='requestJson')
|
||||
assert.equal(request.type,'input')
|
||||
request.input=JSON.stringify({...JSON.parse(request.input),brightness:17,pointDistance:0.5},null,2)
|
||||
request.input=JSON.stringify({...JSON.parse(request.input),pointDistance:0.7},null,2)
|
||||
}
|
||||
const startInputs=start.properties.inputParams
|
||||
const legacy=startInputs.find(parameter=>parameter.name==='scan_speed')
|
||||
|
||||
@ -8,16 +8,55 @@ const snapshot=JSON.parse(fs.readFileSync(snapshotPath,'utf8').replace(/^\uFEFF/
|
||||
assert(snapshot.current?.publishedVersionId&&snapshot.published?.flowData,'A current published version snapshot is required')
|
||||
assert.equal(snapshot.current.publishedVersionId,snapshot.published.id)
|
||||
const graph=JSON.parse(snapshot.published.flowData),before=structuredClone(graph)
|
||||
// Replace only the top-level value token. In particular, never parse/stringify
|
||||
// unrelated SDK integers or overwrite a saved brightness (including zero).
|
||||
function distanceBody(text,body){
|
||||
const stringEnd=start=>{
|
||||
for(let i=start+1;i<text.length;i++){
|
||||
if(text[i]==='\\')i++
|
||||
else if(text[i]==='"')return i+1
|
||||
}
|
||||
throw new Error('Unterminated scanner JSON string')
|
||||
}
|
||||
const spaces=start=>{while(/\s/.test(text[start]||'')&&start<text.length)start++;return start}
|
||||
let depth=0;const ranges=[]
|
||||
for(let i=0;i<text.length;i++){
|
||||
if(text[i]==='"'){
|
||||
const end=stringEnd(i),colon=spaces(end)
|
||||
if(depth===1&&text[colon]===':'&&JSON.parse(text.slice(i,end))==='pointDistance'){
|
||||
const start=spaces(colon+1);let stop=start,nested=0
|
||||
for(;stop<text.length;stop++){
|
||||
if(text[stop]==='"'){stop=stringEnd(stop)-1;continue}
|
||||
if(text[stop]==='{'||text[stop]==='[')nested++
|
||||
else if(text[stop]==='}'||text[stop]===']'){if(nested===0)break;nested--}
|
||||
else if(text[stop]===','&&nested===0)break
|
||||
}
|
||||
while(stop>start&&/\s/.test(text[stop-1]))stop--
|
||||
ranges.push([start,stop])
|
||||
}
|
||||
i=end-1
|
||||
}else if(text[i]==='{'||text[i]==='[')depth++
|
||||
else if(text[i]==='}'||text[i]===']')depth--
|
||||
}
|
||||
assert(ranges.length<=1,'Duplicate scanner pointDistance requires review')
|
||||
if(ranges.length){const [start,end]=ranges[0];return text.slice(0,start)+'0.7'+text.slice(end)}
|
||||
const end=text.lastIndexOf('}')
|
||||
return text.slice(0,end)+(Object.keys(body).length?',':'')+'\n "pointDistance": 0.7\n'+text.slice(end)
|
||||
}
|
||||
let nodes=0,changed=0
|
||||
for(const node of graph.nodes){
|
||||
if(node.properties?.action!=='SCANNER_PARAMETERS')continue
|
||||
nodes++
|
||||
const parameter=node.properties.nodeParams?.find(field=>field.name==='requestJson')
|
||||
assert.equal(parameter?.type,'input',`Dynamic scanner request requires a separate review: ${node.id}`)
|
||||
assert(!node.properties.nodeParams?.find(field=>field.name==='requestFields')?.children?.some(field=>field.name==='pointDistance'),`Bound pointDistance requires a separate review: ${node.id}`)
|
||||
const body=JSON.parse(parameter.input)
|
||||
assert(body&&typeof body==='object'&&!Array.isArray(body))
|
||||
if(body.brightness===17&&body.pointDistance===0.5)continue
|
||||
parameter.input=JSON.stringify({...body,brightness:17,pointDistance:0.5},null,2)
|
||||
if(body.pointDistance===0.7)continue
|
||||
parameter.input=distanceBody(parameter.input,body)
|
||||
const previous={...body},next={...JSON.parse(parameter.input)}
|
||||
delete previous.pointDistance;delete next.pointDistance
|
||||
assert.deepEqual(next,previous,'Only pointDistance may change inside scanner parameters')
|
||||
changed++
|
||||
}
|
||||
assert(nodes>0,'No scanner parameter nodes')
|
||||
@ -29,4 +68,4 @@ for(let i=0;i<verified.nodes.length;i++)if(verified.nodes[i].properties?.action=
|
||||
}
|
||||
assert.deepEqual(verified,before)
|
||||
fs.writeFileSync(outputPath,JSON.stringify(graph,null,2))
|
||||
console.log(JSON.stringify({flowId:snapshot.current.id,nodes,changed,brightness:17,pointDistance:0.5,pathUnchanged:true}))
|
||||
console.log(JSON.stringify({flowId:snapshot.current.id,nodes,changed,brightnessUnchanged:true,pointDistance:0.7,pathUnchanged:true}))
|
||||
|
||||
@ -7,7 +7,7 @@ def run():
|
||||
client = Client().login()
|
||||
db = TargetReadOnlyDb(client)
|
||||
cases = [
|
||||
('defaults', {'pointDistance': .5, 'brightness': 17}, 200),
|
||||
('defaults', {'pointDistance': .7, 'brightness': 17}, 200),
|
||||
('lower bounds', {'pointDistance': .05, 'brightness': 0}, 200),
|
||||
('upper bounds', {'pointDistance': 10, 'brightness': 17}, 200),
|
||||
('brightness only', {'brightness': 8}, 200),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user