fix(arm): resolve saved coordinates by name
This commit is contained in:
parent
c39abb5241
commit
cc9acf67ec
@ -1,5 +1,7 @@
|
||||
# AM FreeScan 开发约定
|
||||
|
||||
- 2026-11-21 用户要求坐标系使用只保存名称、按名称调用。GET/APPLY、工作流目标位姿和命名MoveL/MoveJPose、动作队列使用节点忽略历史固定版本;新保存剔除对应版本字段,不改写数据库中的冻结版本及历史执行。UPDATE/DELETE仍保留记录版本并发保护。内部必须继续核对同名最新记录已完整实际应用、实际TCP和运动期间记录身份,不能为按名字调用取消这些检查、自动应用或重发运动。用户本轮明确授权全部平台代码完成验证后提交并推送现有main;不据此重启正式服务或部署边端。
|
||||
|
||||
- 2026-11-13 用户要求仅启动开发前后端且不再连接现场扫描仪、QUIC、旋转底座、机械臂或AGV,不能操作正式环境。dev环境默认导入.local/dev-isolated.yaml,直连设备地址、密钥和绑定为空,QUIC关闭;本机开发后端使用.local/start-backend-dev.ps1加载仅本进程生效的网络隔离,只允许本机及开发MySQL/Redis。原scanner-private.yaml、正式配置、证书和已交付数据包保留。不得为了启动开发环境而恢复现场配置或解除网络隔离;无用户新授权不提交/推送。
|
||||
|
||||
- 2026-11-13 用户确认正式环境已经完整同步,最终全量迁移阶段结束,正式环境是唯一业务数据源。今后不再导出或导入开发端全量数据,不重跑 Init、Bootstrap、sync-full.ps1,不覆盖正式业务、现场私有配置、证书或数据卷。开发端保持与现场控制隔离,原源后端不因修改代码自动恢复启动。公网仓库为https://p20001.svc.cmvr-iot.icu/SmartBench/am-freescan.git,main分支。
|
||||
|
||||
@ -36,11 +36,16 @@ public class ArmCoordinateMotionService {
|
||||
var query=new ArmTeachingRequest();query.setRobotId(p.getRobotId());query.setDeviceId(p.getDeviceId());query.setTimeoutMs(ArmTimeouts.DEFAULT_MS);
|
||||
// Read failures must not create a physical-operation lease.
|
||||
teaching.validateTarget(ArmTeachingOperation.LIST_USER_COORDINATE_SYSTEMS,query);
|
||||
var proof=teaching.requireCoordinateProof(p.getRobotId(),p.getDeviceId(),p.getUserCoordinateName(),p.getUserCoordinateRevision());
|
||||
try {return checkedStep(p,query,proof,instId);}catch(RuntimeException error){teaching.invalidateCoordinateProof(p.getRobotId(),p.getDeviceId());throw error;}
|
||||
try {
|
||||
var catalog=teaching.execute(ArmTeachingOperation.LIST_USER_COORDINATE_SYSTEMS,query);
|
||||
// Bind only this invocation to the latest record; never trust a saved client revision.
|
||||
p.setUserCoordinateRevision(currentRevision(catalog,p.getUserCoordinateName()));
|
||||
var proof=teaching.requireCoordinateProof(p.getRobotId(),p.getDeviceId(),p.getUserCoordinateName(),p.getUserCoordinateRevision());
|
||||
return checkedStep(p,query,proof,instId,catalog);
|
||||
}catch(RuntimeException error){teaching.invalidateCoordinateProof(p.getRobotId(),p.getDeviceId());throw error;}
|
||||
}
|
||||
private JSONObject checkedStep(EdgeArmMoveLVO p,ArmTeachingRequest query,CoordinateApplicationProof proof,String instId){
|
||||
checkApplied(teaching.execute(ArmTeachingOperation.LIST_USER_COORDINATE_SYSTEMS,query),p,proof);
|
||||
private JSONObject checkedStep(EdgeArmMoveLVO p,ArmTeachingRequest query,CoordinateApplicationProof proof,String instId,JSONObject catalog){
|
||||
checkApplied(catalog,p,proof);
|
||||
verifyActualTcp(p,proof);
|
||||
// Confirms the controller SDK can really read TCP, rather than relying on QUIC presence.
|
||||
var feedback=arm.getPose(p,"__builtin_base__".equals(p.getUserCoordinateName())?"base":p.getUserCoordinateName(),"tcp");
|
||||
@ -76,13 +81,21 @@ public class ArmCoordinateMotionService {
|
||||
if(p.getBlendRadius()!=null&&p.getBlendRadius()!=0)throw new GlobalException("单步运动融合半径必须为0");
|
||||
if(p.getTimeoutMs()==null||p.getTimeoutMs()<100||p.getTimeoutMs()>21600000)throw new GlobalException("请设置足够的运动等待超时(100至21600000毫秒)");
|
||||
}
|
||||
static String currentRevision(JSONObject data,String name) {
|
||||
var coordinates=data==null?null:data.getJSONArray("coordinates");
|
||||
if(coordinates==null)throw new GlobalException("未取得当前坐标系列表,请重新查询并应用");
|
||||
var matches=coordinates.stream().map(v->JSON.parseObject(JSON.toJSONString(v))).filter(c->c!=null&&name.equals(c.getString("name"))).toList();
|
||||
if(matches.size()!=1)throw new GlobalException("所选坐标系不存在或名称不唯一,请重新查询并应用");
|
||||
Object revision=matches.get(0).get("revision");
|
||||
if(!(revision instanceof String text))throw new GlobalException("边端未返回有效坐标系记录身份,请重新查询并应用");
|
||||
return Long.toUnsignedString(ArmUserCoordinates.revision(text,true));
|
||||
}
|
||||
static void checkApplied(JSONObject data,EdgeArmMoveLVO p,CoordinateApplicationProof proof) {
|
||||
// Acknowledgement and the six TCP values come from the verified Apply receipt.
|
||||
// List independently proves that the same named/versioned record is still applied.
|
||||
if(proof==null||!proof.workObjectAcknowledged()||proof.actualTcpOffset().size()!=6||!p.getUserCoordinateName().equals(proof.name())||!p.getUserCoordinateRevision().equals(proof.revision())||!data.getBooleanValue("applicationKnown")||!p.getUserCoordinateName().equals(data.getString("lastAppliedName"))||!p.getUserCoordinateRevision().equals(data.getString("lastAppliedRevision")))
|
||||
throw new GlobalException("所选坐标系尚未完整应用或版本已变化,请重新查询并应用后再移动");
|
||||
var coordinates=data.getJSONArray("coordinates");
|
||||
if(coordinates==null||coordinates.stream().map(v->JSON.parseObject(JSON.toJSONString(v))).noneMatch(c->p.getUserCoordinateName().equals(c.getString("name"))&&p.getUserCoordinateRevision().equals(c.getString("revision"))))throw new GlobalException("所选坐标系记录已修改或删除,请重新选择并应用");
|
||||
if(!p.getUserCoordinateRevision().equals(currentRevision(data,p.getUserCoordinateName())))throw new GlobalException("所选坐标系记录已修改或删除,请重新选择并应用");
|
||||
}
|
||||
private void verifyActualTcp(EdgeArmMoveLVO p,CoordinateApplicationProof proof){
|
||||
var request=new com.cmvr.edge.client.model.system.EdgeSystemJsonCommandVO();request.setRobotId(p.getRobotId());request.setDeviceId(p.getDeviceId());request.setRequestJson("{\"command\":\"get_active_tcp_offset\"}");
|
||||
|
||||
@ -4,19 +4,17 @@ import com.alibaba.fastjson2.JSONArray;
|
||||
import com.cmvr.common.exception.GlobalException;
|
||||
import com.cmvr.edge.client.model.arm.EdgeArmMoveLVO;
|
||||
|
||||
/** Workflow inputs use mm/degrees; SDK requests use m/rad and a pinned coordinate revision. */
|
||||
/** Workflow inputs use mm/degrees and a coordinate name; execution resolves the applied revision. */
|
||||
public final class ArmCoordinateStepParameters {
|
||||
private ArmCoordinateStepParameters() {}
|
||||
public static EdgeArmMoveLVO fromInputs(JSONObject input) {
|
||||
if(input==null||!"absolute_selected_frame".equals(input.getString("targetMode")))throw new GlobalException("旧增量移动已停用,请重新配置移动到目标位姿的完整绝对目标");
|
||||
String name=ArmUserCoordinates.name(input.getString("name"),false);
|
||||
if(!(input.get("expectedRevision") instanceof String))throw new GlobalException("请选择坐标系,版本须保留字符串精度");
|
||||
String revision=input.getString("expectedRevision");ArmUserCoordinates.revision(revision,true);
|
||||
double velocity=positive(input,"velocityMm")/1000,acceleration=positive(input,"accelerationMm")/1000;
|
||||
Object timeout=input.get("timeoutMs");
|
||||
if(!(timeout instanceof Number n)||!Double.isFinite(n.doubleValue())||n.doubleValue()!=Math.rint(n.doubleValue()))throw new GlobalException("等待超时须为整数毫秒");
|
||||
var p=new EdgeArmMoveLVO();p.setRobotId(input.getString("robotId"));p.setDeviceId(input.getString("deviceId"));
|
||||
p.setUserCoordinateName(name);p.setUserCoordinateRevision(revision);p.setCoordinateRelativeTranslation(false);
|
||||
p.setUserCoordinateName(name);p.setCoordinateRelativeTranslation(false);
|
||||
p.setX(0D);p.setY(0D);p.setZ(0D);p.setRx(0D);p.setRy(0D);p.setRz(0D);
|
||||
p.setRx(Math.toRadians(displacement(input,"rxDeg")));p.setRy(Math.toRadians(displacement(input,"ryDeg")));p.setRz(Math.toRadians(displacement(input,"rzDeg")));
|
||||
if(input.containsKey("xMm")||input.containsKey("yMm")||input.containsKey("zMm")) {
|
||||
@ -35,6 +33,7 @@ public final class ArmCoordinateStepParameters {
|
||||
var p=JSONObject.of("robotId","validation","deviceId","validation");var names=new java.util.HashSet<String>();
|
||||
if(params!=null)for(int i=0;i<params.size();i++){
|
||||
var field=params.getJSONObject(i);var name=field.getString("name");
|
||||
if("expectedRevision".equals(name))continue;
|
||||
if(name==null||!names.add(name))throw new GlobalException("目标位姿参数为空或重复");
|
||||
if("quote".equals(field.getString("type"))&&"velocityMm".equals(name)) {
|
||||
var path=field.getJSONArray("quote");
|
||||
|
||||
@ -17,13 +17,12 @@ public final class ArmLinearParameters {
|
||||
private static void validate(JSONObject p,double x,double y,double z,double rx,double ry,double rz,String base,String tcp,boolean forwardRelativeRotation){
|
||||
for(double value:new double[]{x,y,z,rx,ry,rz})if(!Double.isFinite(value))throw new GlobalException("直线运动位姿须为有限数值(m/rad)");
|
||||
String name=p.getString("userCoordinateName");boolean named=name!=null&&!name.isBlank();
|
||||
if(p.get("userCoordinateRevision")!=null&&!(p.get("userCoordinateRevision") instanceof String))throw new GlobalException("坐标系版本请使用字符串,避免uint64精度丢失");
|
||||
boolean explicit=p.get("userFramePose")!=null||p.get("tcpOffset")!=null;
|
||||
if(named){ArmUserCoordinates.name(name,false);ArmUserCoordinates.revision(p.getString("userCoordinateRevision"),true);}
|
||||
if(named)ArmUserCoordinates.name(name,false); // Caller revisions are not a coordinate selection constraint.
|
||||
else if(p.get("userCoordinateRevision")!=null&&!p.getString("userCoordinateRevision").isBlank())throw new GlobalException("填写坐标系版本时必须同时填写名称");
|
||||
if((named||explicit)&&(base!=null&&!base.isBlank()||tcp!=null&&!tcp.isBlank()))throw new GlobalException("服务端用户坐标系不能同时使用旧命名基准/工具坐标系");
|
||||
if(named&&explicit)throw new GlobalException("坐标系名称不能与旧版显式坐标位姿同时填写");
|
||||
if(explicit)throw new GlobalException("旧版手填userFramePose/tcpOffset运动方式已停用,请保存并应用新版坐标系后使用名称与版本");
|
||||
if(explicit)throw new GlobalException("旧版手填userFramePose/tcpOffset运动方式已停用,请保存并应用新版坐标系后使用名称");
|
||||
Object relative=p.get("coordinateRelativeTranslation");if(relative!=null&&!(relative instanceof Boolean))throw new GlobalException("相对平移必须为布尔值");
|
||||
if(Boolean.TRUE.equals(relative))throw new GlobalException("新版MoveL仅支持绝对目标位姿,增量模式已停用,请重新配置");
|
||||
for(String key:List.of("velocity","acceleration"))if(p.get(key)!=null&&ArmUserCoordinates.finite(p.get(key),key)<=0)throw new GlobalException("运动速度及加速度必须为正值");
|
||||
|
||||
@ -42,14 +42,17 @@ public final class ArmTeachingParameters {
|
||||
Object value=input.get(name);
|
||||
if(!(value instanceof Number n)||!Double.isFinite(n.doubleValue())||name.equals("timeoutMs")&&n.doubleValue()!=Math.rint(n.doubleValue()))throw new GlobalException(name+"必须为有效数值,超时为整数毫秒");
|
||||
}
|
||||
if(input.containsKey("expectedRevision")&&!(input.get("expectedRevision") instanceof String))throw new GlobalException("expectedRevision请使用十进制字符串,避免64位精度丢失");
|
||||
var request=input.to(ArmTeachingRequest.class);validate(op,request);return request;
|
||||
if(!ArmUserCoordinates.usesLatestRevision(op)&&input.containsKey("expectedRevision")&&!(input.get("expectedRevision") instanceof String))throw new GlobalException("expectedRevision请使用十进制字符串,避免64位精度丢失");
|
||||
var normalized=new JSONObject(input);
|
||||
if(ArmUserCoordinates.usesLatestRevision(op))normalized.remove("expectedRevision"); // Saved flows may still contain an obsolete revision.
|
||||
var request=normalized.to(ArmTeachingRequest.class);validate(op,request);return request;
|
||||
}
|
||||
public static void validateLiterals(ArmTeachingOperation op,JSONArray params) {
|
||||
JSONObject literals=JSONObject.of("robotId","validation","deviceId","validation");
|
||||
Set<String> names=new HashSet<>(),dynamic=new HashSet<>();
|
||||
if(params!=null)for(int i=0;i<params.size();i++) {
|
||||
var param=params.getJSONObject(i);String name=param.getString("name");
|
||||
if(ArmUserCoordinates.usesLatestRevision(op)&&"expectedRevision".equals(name))continue;
|
||||
if(name==null||!names.add(name))throw new GlobalException("机械臂参数名称为空或重复");
|
||||
if("input".equals(param.getString("type")))literals.put(name,param.get("input"));
|
||||
else if("quote".equals(param.getString("type"))) {
|
||||
|
||||
@ -90,7 +90,7 @@ public class ArmTeachingService {
|
||||
if(!feedback.getSuccess())throw new GlobalException(op.label+"失败:"+feedback.getErrorMessage());
|
||||
if(op==ArmTeachingOperation.APPLY_USER_COORDINATE_SYSTEM){
|
||||
var applied=(ArmCommand.UserCoordinateSystemCommand.Response)response;
|
||||
if(!applied.getApplicationKnown()||!applied.getWorkObjectAcknowledged()||!p.getName().equals(applied.getLastAppliedName())||ArmUserCoordinates.revision(p.getExpectedRevision(),false)!=0&&ArmUserCoordinates.revision(p.getExpectedRevision(),false)!=applied.getLastAppliedRevision()||applied.getActualTcpOffsetCount()!=6||applied.getActualTcpOffsetList().stream().anyMatch(v->!Double.isFinite(v)))
|
||||
if(!applied.getApplicationKnown()||!applied.getWorkObjectAcknowledged()||!p.getName().equals(applied.getLastAppliedName())||applied.getActualTcpOffsetCount()!=6||applied.getActualTcpOffsetList().stream().anyMatch(v->!Double.isFinite(v)))
|
||||
throw new GlobalException("坐标系应用结果未完整确认,请重新查询状态;不会自动继续运动或重发");
|
||||
if(!applied.hasCoordinate()||!applied.getCoordinate().getName().equals(applied.getLastAppliedName())||applied.getCoordinate().getRevision()!=applied.getLastAppliedRevision()||applied.getLastAppliedRevision()==0)
|
||||
throw new GlobalException("应用回执的坐标系记录与名称或版本不一致,不允许继续运动");
|
||||
|
||||
@ -23,9 +23,12 @@ public final class ArmUserCoordinates {
|
||||
if(!(value instanceof Number number)||!Double.isFinite(number.doubleValue()))throw new GlobalException(label+"须为有限数值");return number.doubleValue();
|
||||
}
|
||||
public static boolean edits(ArmTeachingOperation op){return Set.of(ArmTeachingOperation.CALIBRATE_USER_COORDINATE_SYSTEM,ArmTeachingOperation.CREATE_USER_COORDINATE_SYSTEM,ArmTeachingOperation.UPDATE_USER_COORDINATE_SYSTEM).contains(op);}
|
||||
public static boolean usesLatestRevision(ArmTeachingOperation op) {
|
||||
return op==ArmTeachingOperation.GET_USER_COORDINATE_SYSTEM||op==ArmTeachingOperation.APPLY_USER_COORDINATE_SYSTEM;
|
||||
}
|
||||
public static void validate(ArmTeachingOperation op,ArmTeachingRequest request) {
|
||||
boolean modifying=op==ArmTeachingOperation.UPDATE_USER_COORDINATE_SYSTEM||op==ArmTeachingOperation.DELETE_USER_COORDINATE_SYSTEM;
|
||||
revision(request.getExpectedRevision(),modifying);
|
||||
if(!usesLatestRevision(op))revision(request.getExpectedRevision(),modifying);
|
||||
if(edits(op))coordinate(request.getCoordinate());
|
||||
else if(op!=ArmTeachingOperation.LIST_USER_COORDINATE_SYSTEMS)name(request.getName(),modifying);
|
||||
}
|
||||
@ -55,7 +58,7 @@ public final class ArmUserCoordinates {
|
||||
return out.build(); // Ignore client-supplied userPose/revision; the edge calculates them.
|
||||
}
|
||||
public static ArmCommand.UserCoordinateSystemCommand.Request command(ArmTeachingOperation op,ArmTeachingRequest p,cmvr.api.Common.CommandHeader.Request header){
|
||||
validate(op,p);var b=ArmCommand.UserCoordinateSystemCommand.Request.newBuilder().setHeader(header).setExpectedRevision(revision(p.getExpectedRevision(),false));
|
||||
validate(op,p);var b=ArmCommand.UserCoordinateSystemCommand.Request.newBuilder().setHeader(header).setExpectedRevision(usesLatestRevision(op)?0:revision(p.getExpectedRevision(),false));
|
||||
if(edits(op))b.setCoordinate(coordinate(p.getCoordinate()));else if(p.getName()!=null)b.setName(p.getName());return b.build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,35 +83,27 @@ public final class ActionQueueParameters {
|
||||
for (String field : List.of("blendRadius", "jerk"))
|
||||
if (p.get(field) != null && ArmUserCoordinates.finite(p.get(field), field) != 0) throw new GlobalException("末端位姿MoveJ不支持非零" + field);
|
||||
String name = application.getString("name");
|
||||
long revision = coordinateRevision(application);
|
||||
coordinateRevision(application);
|
||||
if (p.get("userCoordinateName") != null && !name.equals(p.get("userCoordinateName"))) throw new GlobalException("MoveJ坐标系名称必须与前序应用步骤一致");
|
||||
if (p.get("userCoordinateRevision") != null && (!(p.get("userCoordinateRevision") instanceof String text)
|
||||
|| text.isBlank() || ArmUserCoordinates.revision(text, false) != revision)) throw new GlobalException("MoveJ坐标系版本必须与前序应用步骤一致并使用uint64字符串");
|
||||
return JSONObject.of("name", name, "expectedRevision", Long.toUnsignedString(revision));
|
||||
return JSONObject.of("name", name); // Old saved revisions do not constrain name-based execution.
|
||||
}
|
||||
|
||||
/** Returns the raw uint64 bits expected by protobuf; callers must preserve the input string. */
|
||||
/** Zero asks the edge to resolve the latest named record and verify its actual application. */
|
||||
public static long coordinateRevision(JSONObject params) {
|
||||
for (String key : params.keySet()) {
|
||||
if (!COORDINATE_FIELDS.contains(key)) {
|
||||
throw new GlobalException("队列应用坐标系仅接受名称和记录版本,不能传入坐标内容或其他参数:" + key);
|
||||
throw new GlobalException("队列应用坐标系仅接受名称(兼容忽略旧记录版本),不能传入坐标内容或其他参数:" + key);
|
||||
}
|
||||
}
|
||||
if (!(params.get("name") instanceof String name)) {
|
||||
throw new GlobalException("请选择队列步骤需要应用的坐标系");
|
||||
}
|
||||
ArmUserCoordinates.name(name, false);
|
||||
Object revision = params.get("expectedRevision");
|
||||
if (revision != null && (!(revision instanceof String text) || text.isBlank())) {
|
||||
throw new GlobalException("坐标系记录版本须为uint64十进制字符串,0表示执行时读取最新版本");
|
||||
}
|
||||
long parsed = ArmUserCoordinates.revision((String) revision, false);
|
||||
if (name.startsWith("__builtin_")) {
|
||||
if (!Set.of("__builtin_base__", "__builtin_tool__").contains(name)) {
|
||||
throw new GlobalException("动作队列仅支持基座和工具两种内置坐标系");
|
||||
}
|
||||
if (parsed != 1L) throw new GlobalException("内置坐标系的记录版本固定为1");
|
||||
}
|
||||
return parsed;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +139,9 @@ public class EdgeSystemServiceImpl implements EdgeSystemService {
|
||||
throw new GlobalException("Action queue step type cannot be empty");
|
||||
}
|
||||
com.alibaba.fastjson2.JSONObject params = step.getParams() == null
|
||||
? new com.alibaba.fastjson2.JSONObject() : step.getParams();
|
||||
? new com.alibaba.fastjson2.JSONObject() : new com.alibaba.fastjson2.JSONObject(step.getParams());
|
||||
if("ARM_MOVE_L".equalsIgnoreCase(step.getType())&¶ms.getString("userCoordinateName")!=null&&!params.getString("userCoordinateName").isBlank())
|
||||
params.remove("userCoordinateRevision"); // Ignore historical public queue revisions, not internally resolved motion identities.
|
||||
SystemCommand.ActionStep.Builder builder = SystemCommand.ActionStep.newBuilder();
|
||||
builder.setTimeoutMs(ActionQueueTimeouts.step(step.getTimeoutMs()));
|
||||
switch (step.getType().trim().toUpperCase()) {
|
||||
|
||||
@ -107,7 +107,9 @@ public class EdgeArmOperateService implements EdgeOperateService {
|
||||
|
||||
// 直接调用边缘端机械臂服务执行笛卡尔空间直线运动
|
||||
if(com.cmvr.arm.ArmLinearParameters.managed(inputParams)){
|
||||
var request=inputParams.to(com.cmvr.edge.client.model.arm.EdgeArmMoveLVO.class);request.setRobotId(robotId);request.setDeviceId(deviceId);edgeArmService.moveL(request);
|
||||
var resolved=new JSONObject(inputParams);
|
||||
if(resolved.getString("userCoordinateName")!=null&&!resolved.getString("userCoordinateName").isBlank())resolved.remove("userCoordinateRevision");
|
||||
var request=resolved.to(com.cmvr.edge.client.model.arm.EdgeArmMoveLVO.class);request.setRobotId(robotId);request.setDeviceId(deviceId);edgeArmService.moveL(request);
|
||||
}else edgeArmService.moveL(
|
||||
edgeCommonVO,
|
||||
x,
|
||||
|
||||
@ -128,7 +128,11 @@ public class EdgeArmController {
|
||||
@ApiOperation("笛卡尔空间直线运动")
|
||||
@PostMapping("/moveL")
|
||||
public AjaxResult moveL(@Validated @RequestBody EdgeArmMoveLVO moveLVO) {
|
||||
if(com.cmvr.arm.ArmLinearParameters.managed((com.alibaba.fastjson2.JSONObject)com.alibaba.fastjson2.JSON.toJSON(moveLVO))){edgeArmService.moveL(moveLVO);return AjaxResult.ok();}
|
||||
if(com.cmvr.arm.ArmLinearParameters.managed((com.alibaba.fastjson2.JSONObject)com.alibaba.fastjson2.JSON.toJSON(moveLVO))){
|
||||
if(moveLVO.getUserCoordinateName()!=null&&!moveLVO.getUserCoordinateName().isBlank())
|
||||
moveLVO.setUserCoordinateRevision(null); // Public callers select a name; internal motion proof revisions remain pinned.
|
||||
edgeArmService.moveL(moveLVO);return AjaxResult.ok();
|
||||
}
|
||||
edgeArmService.moveL(
|
||||
moveLVO,
|
||||
moveLVO.getX(),
|
||||
|
||||
@ -4,9 +4,9 @@ import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
public class ArmCoordinateStepParametersTest {
|
||||
JSONObject input(){return JSONObject.of("robotId","r","deviceId","arm","targetMode","absolute_selected_frame","name","夹具","expectedRevision","18446744073709551615","xMm",-400,"yMm",200,"zMm",300,"rxDeg",90,"ryDeg",-45,"rzDeg",0,"velocityMm",5,"accelerationMm",10,"timeoutMs",120000);}
|
||||
@Test public void absolutePoseConvertsMmAndDegreesWithoutLosingRevision(){var p=ArmCoordinateStepParameters.fromInputs(input());assertEquals(-.4,p.getX(),0);assertEquals(.2,p.getY(),0);assertEquals(.3,p.getZ(),0);assertEquals(Math.PI/2,p.getRx(),1e-12);assertEquals(-Math.PI/4,p.getRy(),1e-12);assertFalse(p.getCoordinateRelativeTranslation());assertEquals("18446744073709551615",p.getUserCoordinateRevision());}
|
||||
@Test public void absolutePoseConvertsUnitsAndLeavesRevisionToExecution(){var p=ArmCoordinateStepParameters.fromInputs(input());assertEquals(-.4,p.getX(),0);assertEquals(.2,p.getY(),0);assertEquals(.3,p.getZ(),0);assertEquals(Math.PI/2,p.getRx(),1e-12);assertEquals(-Math.PI/4,p.getRy(),1e-12);assertFalse(p.getCoordinateRelativeTranslation());assertNull(p.getUserCoordinateRevision());}
|
||||
@Test public void allSixValuesIncludingZeroAreExplicit(){var p=input();for(String key:java.util.List.of("xMm","yMm","zMm","rxDeg","ryDeg","rzDeg")){var invalid=new JSONObject(p);invalid.remove(key);assertThrows(RuntimeException.class,()->ArmCoordinateStepParameters.fromInputs(invalid));p.put(key,0);}assertEquals(0,ArmCoordinateStepParameters.fromInputs(p).getX(),0);}
|
||||
@Test public void oldSavedNodesAreRejectedRatherThanReinterpreted(){var p=input();p.remove("targetMode");assertThrows(RuntimeException.class,()->ArmCoordinateStepParameters.fromInputs(p));final var old=input();old.put("targetMode","relative");assertThrows(RuntimeException.class,()->ArmCoordinateStepParameters.fromInputs(old));}
|
||||
@Test public void invalidInputTypesAndRevisionAreRejected(){for(var patch:java.util.List.of(JSONObject.of("xMm","400"),JSONObject.of("rxDeg",Double.NaN),JSONObject.of("velocityMm",0),JSONObject.of("expectedRevision",4),JSONObject.of("expectedRevision","0"),JSONObject.of("timeoutMs",1.5))){var p=input();p.putAll(patch);assertThrows(RuntimeException.class,()->ArmCoordinateStepParameters.fromInputs(p));}}
|
||||
@Test public void invalidPhysicalInputsAreRejected(){for(var patch:java.util.List.of(JSONObject.of("xMm","400"),JSONObject.of("rxDeg",Double.NaN),JSONObject.of("velocityMm",0),JSONObject.of("timeoutMs",1.5))){var p=input();p.putAll(patch);assertThrows(RuntimeException.class,()->ArmCoordinateStepParameters.fromInputs(p));}}
|
||||
@Test public void upstreamReferencesCannotReplaceExplicitCoordinateChoice(){var params=new JSONArray();input().forEach((k,v)->{if(!k.equals("robotId")&&!k.equals("deviceId"))params.add(JSONObject.of("name",k,"type","input","input",v));});ArmCoordinateStepParameters.validateLiterals(params);params.getJSONObject(0).put("type","quote");assertThrows(RuntimeException.class,()->ArmCoordinateStepParameters.validateLiterals(params));}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public class ArmRelativePoseForwardingTest {
|
||||
@After public void close() throws Exception {if(channel!=null)channel.shutdownNow().awaitTermination(5,TimeUnit.SECONDS);if(server!=null)server.shutdownNow().awaitTermination(5,TimeUnit.SECONDS);}
|
||||
com.cmvr.edge.client.model.arm.EdgeArmMoveLVO target(){return ArmCoordinateStepParameters.fromInputs(JSONObject.of("robotId","r","deviceId","arm","targetMode","absolute_selected_frame","name","夹具","expectedRevision","9007199254740993","xMm",5,"yMm",-8,"zMm",2,"rxDeg",90,"ryDeg",-45,"rzDeg",10,"velocityMm",5,"accelerationMm",10,"timeoutMs",120000));}
|
||||
@Test public void oneMoveLContainsAllSixValuesAndUnchangedRelativeFlag(){
|
||||
service.moveL(target());var request=wire.get();assertEquals(1,calls.get());assertFalse(request.getCoordinateRelativeTranslation());assertEquals("夹具",request.getUserCoordinateName());assertEquals(9007199254740993L,request.getUserCoordinateRevision());
|
||||
service.moveL(target());var request=wire.get();assertEquals(1,calls.get());assertFalse(request.getCoordinateRelativeTranslation());assertEquals("夹具",request.getUserCoordinateName());assertEquals(0L,request.getUserCoordinateRevision());
|
||||
assertEquals(.005,request.getTarget().getX(),0);assertEquals(-.008,request.getTarget().getY(),0);assertEquals(.002,request.getTarget().getZ(),0);assertEquals(Math.PI/2,request.getTarget().getRx(),1e-12);assertEquals(-Math.PI/4,request.getTarget().getRy(),1e-12);assertEquals(Math.toRadians(10),request.getTarget().getRz(),1e-12);
|
||||
}
|
||||
@Test public void edgeFailureIsReturnedWithoutFallbackOrRetry(){
|
||||
|
||||
@ -34,7 +34,7 @@ public class ArmUserCoordinatesIntegrationTest {
|
||||
}
|
||||
@After public void close() throws Exception {channel.shutdownNow().awaitTermination(3,TimeUnit.SECONDS);server.shutdownNow().awaitTermination(3,TimeUnit.SECONDS);}
|
||||
ArmTeachingRequest request(){var p=new ArmTeachingRequest();p.setRobotId("robot");p.setDeviceId("aubo_arm");p.setCoordinate(coordinate());p.setName("夹具坐标系");p.setExpectedRevision("18446744073709551615");return p;}
|
||||
@Test public void sevenRpcsPreserveVersionAndNeverApplyOrMoveImplicitly(){for(var op:ArmTeachingOperation.values())if(op.coordinate()){int before=calls.size();var res=service.execute(op,request());assertEquals(before+1,calls.size());assertEquals("aubo_arm",seen.get().getHeader().getDeviceId());assertEquals(-1L,seen.get().getExpectedRevision());assertEquals("18446744073709551615",res.getJSONObject("coordinate").getString("revision"));if(ArmUserCoordinates.edits(op)){assertEquals(3,seen.get().getCoordinate().getCalibrationPointsCount());assertEquals(0,seen.get().getCoordinate().getUserPoseCount());}}assertEquals(List.of("calibrate","create","get","list","update","delete","apply"),calls);}
|
||||
@Test public void coordinateRpcsKeepCrudVersionsAndUseNamesForGetAndApply(){for(var op:ArmTeachingOperation.values())if(op.coordinate()){int before=calls.size();var res=service.execute(op,request());assertEquals(before+1,calls.size());assertEquals("aubo_arm",seen.get().getHeader().getDeviceId());assertEquals(ArmUserCoordinates.usesLatestRevision(op)?0L:-1L,seen.get().getExpectedRevision());assertEquals("18446744073709551615",res.getJSONObject("coordinate").getString("revision"));if(ArmUserCoordinates.edits(op)){assertEquals(3,seen.get().getCoordinate().getCalibrationPointsCount());assertEquals(0,seen.get().getCoordinate().getUserPoseCount());}}assertEquals(List.of("calibrate","create","get","list","update","delete","apply"),calls);}
|
||||
@Test public void badGeometryMissingOffsetBuiltinAndRevisionFailBeforeRpc(){for(String version:new String[]{"0","-1","18446744073709551616","1.2"}){var p=request();p.setExpectedRevision(version);assertThrows(RuntimeException.class,()->service.execute(ArmTeachingOperation.UPDATE_USER_COORDINATE_SYSTEM,p));}var offset=request();offset.getCoordinate().put("tcpOffset",JSONArray.of(0));assertThrows(RuntimeException.class,()->service.execute(ArmTeachingOperation.CREATE_USER_COORDINATE_SYSTEM,offset));var geometry=request();geometry.getCoordinate().getJSONArray("calibrationPoints").set(2,geometry.getCoordinate().getJSONArray("calibrationPoints").get(1));final var bad=geometry;assertThrows(RuntimeException.class,()->service.execute(ArmTeachingOperation.CREATE_USER_COORDINATE_SYSTEM,bad));var builtin=request();builtin.setName("__builtin_base__");assertThrows(RuntimeException.class,()->service.execute(ArmTeachingOperation.DELETE_USER_COORDINATE_SYSTEM,builtin));assertTrue(calls.isEmpty());}
|
||||
@Test public void incompleteApplyAcknowledgementDoesNotPermitWorkflowSuccess(){incomplete.set(true);assertTrue(assertThrows(RuntimeException.class,()->service.execute(ArmTeachingOperation.APPLY_USER_COORDINATE_SYSTEM,request())).getMessage().contains("未完整确认"));assertEquals(1,calls.size());assertThrows(RuntimeException.class,()->service.requireCoordinateProof("robot","aubo_arm","夹具坐标系","18446744073709551615"));}
|
||||
@Test public void completeApplyProofIsServerOwnedAndInvalidatedByFailureOrChannelChange() throws Exception {
|
||||
@ -46,11 +46,11 @@ public class ArmUserCoordinatesIntegrationTest {
|
||||
try{when(clients.getGrpcClient("robot",ArmServiceGrpc.ArmServiceBlockingStub.class)).thenReturn(ArmServiceGrpc.newBlockingStub(replacement));assertThrows(RuntimeException.class,()->service.requireCoordinateProof("robot","aubo_arm","夹具坐标系","18446744073709551615"));}finally{replacement.shutdownNow().awaitTermination(3,TimeUnit.SECONDS);}
|
||||
}
|
||||
@Test public void conflictsKeepStatusAndAreNotRetried(){fail.set(true);var error=assertThrows(RuntimeException.class,()->service.execute(ArmTeachingOperation.UPDATE_USER_COORDINATE_SYSTEM,request()));assertTrue(error.getMessage().contains("ABORTED"));assertEquals(1,calls.size());}
|
||||
@Test public void workflowQueriesCanFeedPinnedApplyWithoutImplicitMotion(){
|
||||
@Test public void workflowQueriesCanFeedNameBasedApplyWithoutImplicitMotion(){
|
||||
var operator=new com.cmvr.test.flow.runtime.operator.edge.EdgeArmOperateService(mock(com.cmvr.edge.client.service.EdgeArmService.class));org.springframework.test.util.ReflectionTestUtils.setField(operator,"teaching",service);var message=new com.cmvr.test.flow.runtime.message.TaskNodeExecuteMessage();message.setRobotId("robot");message.setAction(com.cmvr.test.enums.ActionEnum.ARM_GET_USER_COORDINATE_SYSTEM);message.setInputParams(JSONObject.of("deviceId","aubo_arm","name","夹具坐标系"));var c=operator.execute(message).getOutputParams().getJSONObject("coordinate");message.setAction(com.cmvr.test.enums.ActionEnum.ARM_APPLY_USER_COORDINATE_SYSTEM);message.setInputParams(JSONObject.of("deviceId","aubo_arm","name",c.getString("name"),"expectedRevision",c.getString("revision")));assertTrue(operator.execute(message).isSuccess());assertEquals(List.of("get","apply"),calls);
|
||||
}
|
||||
@Test public void queuedLinearMotionKeepsNewFieldsAndRejectsMissingAxes(){
|
||||
var service=new com.cmvr.edge.client.service.impl.EdgeSystemServiceImpl(clients);var request=new com.cmvr.edge.client.model.system.EdgeActionQueueVO();request.setRobotId("robot");var step=new com.cmvr.edge.client.model.system.EdgeActionQueueVO.Step();step.setType("ARM_MOVE_L");step.setStepId("s1");step.setDeviceId("aubo_arm");step.setParams(JSONObject.of("x",.005,"y",0,"z",0,"rx",0,"ry",0,"rz",0,"userCoordinateName","夹具坐标系","userCoordinateRevision","9007199254740993","coordinateRelativeTranslation",false));request.setSteps(List.of(step));service.executeActionQueue(request);var received=queue.get().getSteps(0).getArmMoveL();assertEquals("夹具坐标系",received.getUserCoordinateName());assertEquals(9007199254740993L,received.getUserCoordinateRevision());assertFalse(received.getCoordinateRelativeTranslation());step.getParams().remove("x");assertThrows(RuntimeException.class,()->service.executeActionQueue(request));
|
||||
var service=new com.cmvr.edge.client.service.impl.EdgeSystemServiceImpl(clients);var request=new com.cmvr.edge.client.model.system.EdgeActionQueueVO();request.setRobotId("robot");var step=new com.cmvr.edge.client.model.system.EdgeActionQueueVO.Step();step.setType("ARM_MOVE_L");step.setStepId("s1");step.setDeviceId("aubo_arm");step.setParams(JSONObject.of("x",.005,"y",0,"z",0,"rx",0,"ry",0,"rz",0,"userCoordinateName","夹具坐标系","userCoordinateRevision","9007199254740993","coordinateRelativeTranslation",false));request.setSteps(List.of(step));service.executeActionQueue(request);var received=queue.get().getSteps(0).getArmMoveL();assertEquals("夹具坐标系",received.getUserCoordinateName());assertEquals(0L,received.getUserCoordinateRevision());assertFalse(received.getCoordinateRelativeTranslation());step.getParams().remove("x");assertThrows(RuntimeException.class,()->service.executeActionQueue(request));
|
||||
}
|
||||
@Test public void linearRelativeTranslationForwardsMetresAndPinnedVersionWithoutApply(){var arm=new com.cmvr.edge.client.service.impl.EdgeArmServiceImpl(clients);var p=new com.cmvr.edge.client.model.arm.EdgeArmMoveLVO();p.setRobotId("robot");p.setDeviceId("aubo_arm");p.setX(.005);p.setY(0D);p.setZ(0D);p.setRx(0D);p.setRy(0D);p.setRz(0D);p.setUserCoordinateName("夹具坐标系");p.setUserCoordinateRevision("18446744073709551615");p.setCoordinateRelativeTranslation(false);p.setVelocity(.005);p.setAcceleration(.01);arm.moveL(p);assertEquals(.005,move.get().getTarget().getX(),0);assertEquals(-1L,move.get().getUserCoordinateRevision());assertFalse(move.get().getCoordinateRelativeTranslation());assertEquals(List.of("moveL"),calls);p.setRx(.1);arm.moveL(p);p.setRx(0D);p.setBaseFrame("base");assertThrows(RuntimeException.class,()->arm.moveL(p));assertEquals(2,calls.size());}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ public class ArmWorkflowStepOperatorTest {
|
||||
@Test public void workflowUsesResolvedTargetAndVerifiedWorkflowLeaseRoute(){
|
||||
var arm=mock(EdgeArmService.class);var motion=mock(ArmCoordinateMotionService.class);var operator=new EdgeArmOperateService(arm);ReflectionTestUtils.setField(operator,"coordinateMotion",motion);
|
||||
when(motion.workflowStep(any(),eq("inst"))).thenReturn(new JSONObject());operator.execute(message("inst"));
|
||||
verify(motion).workflowStep(argThat(p->p.getRobotId().equals("resolved-robot")&&p.getDeviceId().equals("resolved-arm")&&p.getUserCoordinateRevision().equals("9007199254740993")&&p.getX()==.005&&p.getY()==-.008&&p.getZ()==.002),eq("inst"));
|
||||
verify(motion).workflowStep(argThat(p->p.getRobotId().equals("resolved-robot")&&p.getDeviceId().equals("resolved-arm")&&p.getUserCoordinateRevision()==null&&p.getX()==.005&&p.getY()==-.008&&p.getZ()==.002),eq("inst"));
|
||||
verify(motion,never()).targetStep(any());verifyNoInteractions(arm);
|
||||
}
|
||||
@Test public void singleNodeDebugUsesManualOccupationAndInvalidInputNeverDispatches(){
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { actionQueueTotalTimeout } from './actionQueueTimeout.mjs'
|
||||
import { coordinateName, revisionText } from './armUserCoordinates.mjs'
|
||||
import { coordinateName } from './armUserCoordinates.mjs'
|
||||
import { QUEUE_SPEED_PREFIX, requireStandaloneQueueSpeed } from './actionQueueSpeed.mjs'
|
||||
const deepClone = (value) => JSON.parse(JSON.stringify(value))
|
||||
|
||||
@ -13,14 +13,13 @@ export const QUEUE_LEGACY_COORDINATE_FIELDS = [
|
||||
|
||||
export function validateActionQueueCoordinateParams(params = {}) {
|
||||
if (!params || typeof params !== 'object' || Array.isArray(params))
|
||||
throw new Error('应用坐标系参数必须包含记录名称和版本')
|
||||
throw new Error('应用坐标系参数必须包含记录名称')
|
||||
if (Object.keys(params).some((key) => !['name', 'expectedRevision'].includes(key)))
|
||||
throw new Error('应用坐标系只接受名称和版本,不接受坐标记录或手填坐标变换')
|
||||
throw new Error('应用坐标系只接受名称,不接受坐标记录或手填坐标变换')
|
||||
const name = coordinateName(params.name)
|
||||
const expectedRevision = revisionText(params.expectedRevision)
|
||||
if (name.startsWith('__builtin_') && (!['__builtin_base__', '__builtin_tool__'].includes(name) || expectedRevision !== '1'))
|
||||
throw new Error('内置坐标系仅支持基座和当前工具,版本必须为1')
|
||||
return { name, expectedRevision }
|
||||
if (name.startsWith('__builtin_') && !['__builtin_base__', '__builtin_tool__'].includes(name))
|
||||
throw new Error('内置坐标系仅支持基座和当前工具')
|
||||
return { name }
|
||||
}
|
||||
|
||||
export const isAppliedCoordinateMove = (step) => step?.type === 'ARM_MOVE_J_POSE' || (step?.type === 'ARM_MOVE_L' && step.coordinateMode === 'APPLIED')
|
||||
@ -37,8 +36,9 @@ export function actionQueuePoseJointParams(step, context) {
|
||||
throw new Error('末端位姿MoveJ不能混填关节角、旧坐标系或增量字段')
|
||||
for (const field of ['blendRadius','jerk']) if (p[field] != null && p[field] !== 0) throw new Error('末端位姿MoveJ不支持非零'+field)
|
||||
if (p.userCoordinateName != null && p.userCoordinateName !== coordinate.name) throw new Error('MoveJ坐标系须与前序应用一致')
|
||||
if (p.userCoordinateRevision != null && p.userCoordinateRevision !== coordinate.expectedRevision) throw new Error('MoveJ坐标系版本须与前序应用一致')
|
||||
return {...p,userCoordinateName:coordinate.name,userCoordinateRevision:coordinate.expectedRevision}
|
||||
const result = {...p,userCoordinateName:coordinate.name}
|
||||
delete result.userCoordinateRevision
|
||||
return result
|
||||
}
|
||||
|
||||
export function actionQueueCoordinateContext(steps, index) {
|
||||
@ -55,6 +55,7 @@ export function actionQueueCoordinateContext(steps, index) {
|
||||
}
|
||||
|
||||
export function validateActionQueueCoordinateSequence(steps = []) {
|
||||
steps = steps.map(withoutCoordinateVersions)
|
||||
steps.forEach((step, index) => {
|
||||
if (step.type === QUEUE_APPLY_COORDINATE) validateActionQueueCoordinateParams(step.params)
|
||||
if (step.type === 'ARM_MOVE_J_POSE') { actionQueuePoseJointParams(step,actionQueueCoordinateContext(steps,index)); return }
|
||||
@ -76,13 +77,25 @@ export function actionQueueSingleExecutionSteps(steps, index) {
|
||||
requireStandaloneQueueSpeed(step)
|
||||
if (step.type === 'ARM_MOVE_L' && !isAppliedCoordinateMove(step) && actionQueueCoordinateContext(steps, index))
|
||||
throw new Error('该移动仍使用旧版参考系,请先显式改为沿用前序已应用坐标系')
|
||||
if (!isAppliedCoordinateMove(step)) return [deepClone(step)]
|
||||
if (!isAppliedCoordinateMove(step)) return [withoutCoordinateVersions(step)]
|
||||
const context = actionQueueCoordinateContext(steps, index)
|
||||
if (!context) throw new Error('请先为同一机械臂添加“应用坐标系”步骤,再单独执行此移动')
|
||||
const result = [deepClone(context), deepClone(step)]
|
||||
const result = [withoutCoordinateVersions(context), withoutCoordinateVersions(step)]
|
||||
validateActionQueueCoordinateSequence(result)
|
||||
return result
|
||||
}
|
||||
export function withoutCoordinateVersions(step) {
|
||||
const result = deepClone(step)
|
||||
if (result.type === QUEUE_APPLY_COORDINATE && result.params) delete result.params.expectedRevision
|
||||
if (['ARM_MOVE_L', 'ARM_MOVE_J_POSE'].includes(result.type) && result.params) delete result.params.userCoordinateRevision
|
||||
const properties = result.sourceNode?.properties
|
||||
if (properties?.nodeParams) {
|
||||
const key = ['ARM_GET_USER_COORDINATE_SYSTEM', QUEUE_APPLY_COORDINATE, 'ARM_MOVE_COORDINATE_STEP'].includes(properties.action)
|
||||
? 'expectedRevision' : ['ARM_MOVE_TO_POINT', 'ARM_MOVE_L'].includes(properties.action) ? 'userCoordinateRevision' : null
|
||||
if (key) properties.nodeParams = properties.nodeParams.filter((param) => param.name !== key)
|
||||
}
|
||||
return result
|
||||
}
|
||||
const REFERENCE_KEYS = new Set(['quote', 'nameQuote'])
|
||||
|
||||
const createKey = (prefix) => {
|
||||
@ -117,7 +130,7 @@ const nodeToQueueStep = (node) => {
|
||||
const params = paramsToObject(node)
|
||||
const common = {
|
||||
stepName: node?.properties?.name || '导入步骤',
|
||||
sourceNode: deepClone(node),
|
||||
sourceNode: withoutCoordinateVersions({sourceNode: node}).sourceNode,
|
||||
}
|
||||
if (node?.type === 'sleep' || String(action).toLowerCase() === 'sleep') {
|
||||
const durationMs = numberValue(params.delayMs)
|
||||
@ -169,7 +182,7 @@ const nodeToQueueStep = (node) => {
|
||||
frame: params.frame || 'BASE',
|
||||
...(params.baseFrame ? {baseFrame:params.baseFrame} : {}),
|
||||
...(params.tcpFrame ? {tcpFrame:params.tcpFrame} : {}),
|
||||
...Object.fromEntries(['userCoordinateName', 'userCoordinateRevision', 'coordinateRelativeTranslation', 'userFramePose', 'tcpOffset'].filter((key) => Object.hasOwn(params, key)).map((key) => [key, params[key]])),
|
||||
...Object.fromEntries(['userCoordinateName', 'coordinateRelativeTranslation', 'userFramePose', 'tcpOffset'].filter((key) => Object.hasOwn(params, key)).map((key) => [key, params[key]])),
|
||||
velocity: numberValue(params.velocity, 2.1),
|
||||
acceleration: numberValue(params.acceleration, 2.2),
|
||||
},
|
||||
@ -177,7 +190,7 @@ const nodeToQueueStep = (node) => {
|
||||
}
|
||||
if (action === QUEUE_APPLY_COORDINATE) {
|
||||
return { ...common, type: QUEUE_APPLY_COORDINATE, timeoutMs: 120000,
|
||||
params: { name: params.name || '', expectedRevision: params.expectedRevision || '0' } }
|
||||
params: { name: params.name || '' } }
|
||||
}
|
||||
if (action === 'ARM_MOVE_TO_J') {
|
||||
return {
|
||||
@ -198,7 +211,7 @@ const validateConvertibleNodeParams = (node) => {
|
||||
const action = node?.properties?.action
|
||||
const params = paramsToObject(node)
|
||||
if (action === QUEUE_APPLY_COORDINATE) {
|
||||
if (Object.hasOwn(params, 'coordinate')) return '应用坐标系只接受已有记录名称和版本,请移除坐标记录内容'
|
||||
if (Object.hasOwn(params, 'coordinate')) return '应用坐标系只接受已有记录名称,请移除坐标记录内容'
|
||||
try { validateActionQueueCoordinateParams({ name: params.name, expectedRevision: params.expectedRevision }) } catch (error) { return error.message }
|
||||
}
|
||||
const requiredByAction = {
|
||||
@ -265,7 +278,7 @@ const createEdge = (sourceNodeId, targetNodeId, sourceAnchorId, targetAnchorId)
|
||||
})
|
||||
|
||||
const normalizeQueueStepIds = (steps) => steps.map((step, index) => ({
|
||||
...step,
|
||||
...withoutCoordinateVersions(step),
|
||||
stepId: `step_${index + 1}`,
|
||||
}))
|
||||
|
||||
@ -389,7 +402,7 @@ export const extractActionQueueStep = (sourceGraph, queueId, stepIndex, placemen
|
||||
return { ok: false, message: '后续移动仍沿用该坐标系,请先调整对应移动步骤,再将应用坐标系移出队列' }
|
||||
}
|
||||
|
||||
const node = deepClone(step.sourceNode)
|
||||
const node = withoutCoordinateVersions(step).sourceNode
|
||||
if (step.paramBindings?.velocity) {
|
||||
const binding = queueNode.properties.nodeParams?.find(param => param.name === step.paramBindings.velocity)
|
||||
const velocity = node.properties?.nodeParams?.find(param => param.name === 'velocity')
|
||||
@ -459,7 +472,7 @@ export const moveActionQueueStep = (steps, index, offset) => {
|
||||
}
|
||||
|
||||
export const copyActionQueueStep = (step, overrides = {}) => {
|
||||
const copied = deepClone(step)
|
||||
const copied = withoutCoordinateVersions(step)
|
||||
const originalName = String(step?.stepName || '').trim()
|
||||
return {
|
||||
...copied,
|
||||
@ -476,6 +489,7 @@ export const toActionQueueExecutionSteps = (steps) => (Array.isArray(steps) ? st
|
||||
...(step.coordinateMode ? { coordinateMode: step.coordinateMode } : {}),
|
||||
...(step.deviceId ? { deviceId: step.deviceId } : {}),
|
||||
timeoutMs: Number(step.timeoutMs ?? 120000),
|
||||
params: deepClone(step.type === 'ARM_MOVE_J_POSE' ? actionQueuePoseJointParams(step,actionQueueCoordinateContext(steps,index)) : step.params || {}),
|
||||
params: step.type === QUEUE_APPLY_COORDINATE ? validateActionQueueCoordinateParams(step.params)
|
||||
: withoutCoordinateVersions({type: step.type, params: step.type === 'ARM_MOVE_J_POSE' ? actionQueuePoseJointParams(step,actionQueueCoordinateContext(steps,index)) : step.params || {}}).params,
|
||||
}
|
||||
})
|
||||
|
||||
@ -15,7 +15,7 @@ export function frameOptions(catalog, key) {
|
||||
}
|
||||
export function withArmFrameParams(action, params) {
|
||||
if (!isLinearArmAction(action)) return params
|
||||
const result = params.map((param) => ({ ...param }))
|
||||
const result = params.filter((param) => param.name !== 'userCoordinateRevision').map((param) => ({ ...param }))
|
||||
for (const [name, label] of [
|
||||
['baseFrame', '旧基准坐标系(已停用)'],
|
||||
['tcpFrame', '旧工具坐标系(已停用)']
|
||||
@ -31,7 +31,6 @@ export function withArmFrameParams(action, params) {
|
||||
}
|
||||
for (const field of [
|
||||
{ name: 'userCoordinateName', label: '服务端用户坐标系名称', input: '' },
|
||||
{ name: 'userCoordinateRevision', label: '坐标系版本(字符串)', input: '' },
|
||||
{
|
||||
name: 'coordinateRelativeTranslation',
|
||||
label: '沿坐标轴相对平移',
|
||||
@ -50,8 +49,8 @@ export function withArmFrameParams(action, params) {
|
||||
export function validateFrameChoice(catalog, choice, requireCatalog = true) {
|
||||
if (choice.userCoordinateName) {
|
||||
const saved = catalog?.userCoordinates?.find((c) => c.name === choice.userCoordinateName)
|
||||
if (!saved || saved.revision !== choice.userCoordinateRevision)
|
||||
throw new Error('用户坐标系或版本已变化,请重新读取选择')
|
||||
if (!saved)
|
||||
throw new Error('用户坐标系不存在,请重新读取选择')
|
||||
if (choice.baseFrame || choice.tcpFrame) throw new Error('用户坐标系不能和旧命名参考系同时选择')
|
||||
}
|
||||
if (!catalog && (requireCatalog || choice.baseFrame || choice.tcpFrame))
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
COORDINATE_STEP_ACTION,
|
||||
usesCoordinateSelection,
|
||||
coordinateSelectionField,
|
||||
normalizeCoordinateSelectionParams,
|
||||
canReferenceArmParameter,
|
||||
workflowCoordinateStep
|
||||
} from './armWorkflowCoordinates.mjs'
|
||||
@ -57,11 +58,10 @@ export const ARM_TEACHING_OPERATIONS = [
|
||||
{
|
||||
key: 'MOVE_COORDINATE_STEP',
|
||||
name: '移动到目标位姿',
|
||||
desc: '所选坐标系下的完整绝对TCP目标,XYZ为mm,RX/RY/RZ为°。先应用同名同版本坐标系;六维目标一次MoveL下发并等待完成,不自动重发。',
|
||||
desc: '所选坐标系下的完整绝对TCP目标,XYZ为mm,RX/RY/RZ为°。先应用同名坐标系的当前记录;六维目标一次MoveL下发并等待完成,不自动重发。',
|
||||
timeout: 120000,
|
||||
fields: () => [
|
||||
{ name: 'name', label: '用户坐标系', input: '', type: 'input', disabled: true },
|
||||
{ name: 'expectedRevision', label: '坐标系版本', input: '', type: 'input', disabled: true },
|
||||
{ name: 'targetMode', input: 'absolute_selected_frame', type: 'input', disabled: true },
|
||||
number('xMm', 'X目标位置(mm)', null, undefined, undefined, 1),
|
||||
number('yMm', 'Y目标位置(mm)', null, undefined, undefined, 1),
|
||||
@ -232,7 +232,7 @@ export const ARM_TEACHING_OPERATIONS = [
|
||||
readOnly: [0, 2, 3].includes(i),
|
||||
desc:
|
||||
i === 6
|
||||
? '应用已保存的名称和版本,不执行运动;重连后应重新应用。'
|
||||
? '按名称应用当前保存的坐标系,不执行运动;重连后应重新应用。'
|
||||
: i === 0
|
||||
? '计算三点标定结果,不保存、不应用、不运动。'
|
||||
: '管理边端保存的坐标系记录,不自动应用或运动。',
|
||||
@ -251,14 +251,12 @@ export const ARM_TEACHING_OPERATIONS = [
|
||||
: i !== 3
|
||||
? [{ name: 'name', label: '坐标系名称', input: '', type: 'input', disabled: true }]
|
||||
: []),
|
||||
...([2, 4, 5, 6].includes(i)
|
||||
...([4, 5].includes(i)
|
||||
? [
|
||||
{
|
||||
name: 'expectedRevision',
|
||||
label: [4, 5].includes(i)
|
||||
? '当前记录版本(必填,字符串)'
|
||||
: '记录版本(0取最新;建议固定)',
|
||||
input: [4, 5].includes(i) ? '' : '0',
|
||||
label: '当前记录版本(必填,字符串)',
|
||||
input: '',
|
||||
type: 'input',
|
||||
disabled: true
|
||||
}
|
||||
@ -361,6 +359,7 @@ export function validateArmTeaching(action, values) {
|
||||
}
|
||||
// Validate every known literal while leaving referenced values to runtime checks.
|
||||
export function validateArmTeachingConfiguration(action, params) {
|
||||
params = normalizeCoordinateSelectionParams(action, params)
|
||||
if (
|
||||
params.some(
|
||||
(p) =>
|
||||
|
||||
@ -114,7 +114,7 @@ export function coordinateName(name, custom = false) {
|
||||
}
|
||||
export function validateCoordinate(key, p) {
|
||||
const modifying = ['UPDATE_USER_COORDINATE_SYSTEM', 'DELETE_USER_COORDINATE_SYSTEM'].includes(key)
|
||||
revisionText(p.expectedRevision, modifying)
|
||||
if (modifying) revisionText(p.expectedRevision, true)
|
||||
if (
|
||||
[
|
||||
'CALIBRATE_USER_COORDINATE_SYSTEM',
|
||||
@ -165,9 +165,8 @@ export function validateLinearCoordinate(p, { forwardRelativeRotation = false }
|
||||
throw new Error('旧命名参考系和手填坐标变换已停用,请选择新版坐标系并清空旧参数')
|
||||
if (p.userCoordinateName) {
|
||||
coordinateName(p.userCoordinateName)
|
||||
revisionText(p.userCoordinateRevision, true)
|
||||
if (p.baseFrame || p.tcpFrame) throw new Error('选择用户坐标系时请清空旧基准和工具坐标系')
|
||||
} else if (p.userCoordinateRevision) throw new Error('版本必须同时填写坐标系名称')
|
||||
}
|
||||
if (
|
||||
p.coordinateRelativeTranslation !== undefined &&
|
||||
typeof p.coordinateRelativeTranslation !== 'boolean'
|
||||
|
||||
@ -155,7 +155,7 @@ test('uint64版本保持字符串,修改删除必须固定当前非零版本',
|
||||
true
|
||||
)
|
||||
})
|
||||
test('直线运动显式名称版本和相对平移,不混用旧名称或姿态位移', () => {
|
||||
test('直线运动按名称使用坐标系,兼容旧版本字段且不混用旧名称或姿态位移', () => {
|
||||
const p = {
|
||||
userCoordinateName: '夹具一',
|
||||
userCoordinateRevision: '3',
|
||||
@ -171,10 +171,11 @@ test('直线运动显式名称版本和相对平移,不混用旧名称或姿
|
||||
for (const patch of [
|
||||
{ coordinateRelativeTranslation: true },
|
||||
{ baseFrame: 'base' },
|
||||
{ userCoordinateRevision: '' },
|
||||
{ coordinateRelativeTranslation: 'true' }
|
||||
])
|
||||
assert.throws(() => validateLinearCoordinate({ ...p, ...patch }))
|
||||
assert.doesNotThrow(() => validateLinearCoordinate({ ...p, userCoordinateRevision: '' }))
|
||||
assert.doesNotThrow(() => validateLinearCoordinate({ ...p, userCoordinateRevision: undefined }))
|
||||
assert.deepEqual(poseFrameQuery(p), { baseLink: p.userCoordinateName, eeLink: 'tcp' })
|
||||
assert.deepEqual(poseFrameQuery({ userCoordinateName: '__builtin_tool__' }), { baseLink: '__builtin_tool__', eeLink: 'tcp' })
|
||||
assert.doesNotThrow(() => poseFrameQuery({ userCoordinateName: '__builtin_base__' }))
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { validateLinearCoordinate } from './armUserCoordinates.mjs'
|
||||
import { coordinateName, revisionText, validateLinearCoordinate } from './armUserCoordinates.mjs'
|
||||
|
||||
export const COORDINATE_STEP_ACTION = 'ARM_MOVE_COORDINATE_STEP'
|
||||
export const canReferenceArmParameter = (action, name) =>
|
||||
@ -12,10 +12,17 @@ export const usesCoordinateSelection = (action) =>
|
||||
COORDINATE_STEP_ACTION
|
||||
].includes(action)
|
||||
export const coordinateSelectionField = (param) => ['name', 'expectedRevision'].includes(param.name)
|
||||
export function setCoordinateSelection(params, record) {
|
||||
if (!record?.name || typeof record.revision !== 'string' || !/^[1-9]\d*$/.test(record.revision))
|
||||
throw new Error('请选择具有有效版本的坐标系')
|
||||
return params.map((p) =>
|
||||
export const coordinateRevisionRequired = (action) =>
|
||||
['ARM_UPDATE_USER_COORDINATE_SYSTEM', 'ARM_DELETE_USER_COORDINATE_SYSTEM'].includes(action)
|
||||
export function normalizeCoordinateSelectionParams(action, params) {
|
||||
return usesCoordinateSelection(action) && !coordinateRevisionRequired(action)
|
||||
? params.filter((p) => p.name !== 'expectedRevision')
|
||||
: params
|
||||
}
|
||||
export function setCoordinateSelection(params, record, requireRevision = false) {
|
||||
coordinateName(record?.name)
|
||||
if (requireRevision) revisionText(record.revision, true)
|
||||
return params.filter((p) => requireRevision || p.name !== 'expectedRevision').map((p) =>
|
||||
coordinateSelectionField(p)
|
||||
? {
|
||||
...p,
|
||||
@ -41,7 +48,6 @@ export function workflowCoordinateStep(values) {
|
||||
throw new Error('等待超时须为100至21600000整数毫秒')
|
||||
const p = {
|
||||
userCoordinateName: values.name,
|
||||
userCoordinateRevision: values.expectedRevision,
|
||||
coordinateRelativeTranslation: false,
|
||||
x: values.xMm / 1000,
|
||||
y: values.yMm / 1000,
|
||||
@ -75,6 +81,7 @@ export function workflowStepDisplacement() {
|
||||
throw new Error('旧增量配置已停用,请填写完整绝对目标')
|
||||
}
|
||||
export function normalizeWorkflowStepParams(params) {
|
||||
params = normalizeCoordinateSelectionParams(COORDINATE_STEP_ACTION, params)
|
||||
if (
|
||||
params.some(
|
||||
(p) => p.name === 'targetMode' && p.type === 'input' && p.input === ABSOLUTE_TARGET_MODE
|
||||
|
||||
@ -3,8 +3,8 @@ import assert from 'node:assert/strict'
|
||||
import {workflowCoordinateStep,absolutePoseInputs,setCoordinateSelection,normalizeWorkflowStepParams} from './armWorkflowCoordinates.mjs'
|
||||
import {createArmTeachingGroup,validateArmTeachingConfiguration} from './armTeaching.mjs'
|
||||
const values={targetMode:'absolute_selected_frame',name:'夹具',expectedRevision:'18446744073709551615',xMm:-400,yMm:200,zMm:300,rxDeg:90,ryDeg:-45,rzDeg:0,velocityMm:5,accelerationMm:10,timeoutMs:120000}
|
||||
test('绝对目标六维单位转换、uint64版本保留,重复转换不会累加',()=>{const p=workflowCoordinateStep(values);assert.deepEqual([p.x,p.y,p.z],[-.4,.2,.3]);assert.equal(p.rx,Math.PI/2);assert.equal(p.ry,-Math.PI/4);assert.equal(p.coordinateRelativeTranslation,false);assert.equal(p.userCoordinateRevision,values.expectedRevision);assert.deepEqual(p,workflowCoordinateStep(values))})
|
||||
test('绝对目标六维单位转换、仅按名称使用坐标系,重复转换不会累加',()=>{const p=workflowCoordinateStep(values);assert.deepEqual([p.x,p.y,p.z],[-.4,.2,.3]);assert.equal(p.rx,Math.PI/2);assert.equal(p.ry,-Math.PI/4);assert.equal(p.coordinateRelativeTranslation,false);assert.equal(Object.hasOwn(p,'userCoordinateRevision'),false);assert.deepEqual(p,workflowCoordinateStep(values))})
|
||||
test('全零是明确目标,缺少任一姿态或位置不能当成保持当前值',()=>{const zero={...values,xMm:0,yMm:0,zMm:0,rxDeg:0,ryDeg:0,rzDeg:0};assert.doesNotThrow(()=>workflowCoordinateStep(zero));for(const key of ['xMm','yMm','zMm','rxDeg','ryDeg','rzDeg']){const p={...values};delete p[key];assert.throws(()=>workflowCoordinateStep(p))}for(const value of [null,'10',NaN,Infinity])assert.throws(()=>workflowCoordinateStep({...values,rxDeg:value}))})
|
||||
test('旧增量节点不能被自动解释为绝对目标,打开配置清空六维数值',()=>{const old={...values};delete old.targetMode;assert.throws(()=>workflowCoordinateStep(old),/旧增量/);const params=Object.entries(old).map(([name,input])=>({name,input,type:'input'}));const normalized=normalizeWorkflowStepParams(params);for(const k of ['xMm','yMm','zMm','rxDeg','ryDeg','rzDeg'])assert.equal(normalized.find(p=>p.name===k).input,null)})
|
||||
test('只接受所选参考系实际TCP反馈,再从m/rad转换界面mm/度',()=>{const feedback={referenceFrame:'夹具',endFrame:'tcp',x:-.4,y:.2,z:.3,rx:Math.PI/2,ry:0,rz:0};assert.deepEqual(absolutePoseInputs(feedback,'夹具'),{xMm:-400,yMm:200,zMm:300,rxDeg:90,ryDeg:0,rzDeg:0});assert.throws(()=>absolutePoseInputs({...feedback,referenceFrame:'base'},'夹具'));assert.throws(()=>absolutePoseInputs({...feedback,endFrame:'flange'},'夹具'));assert.throws(()=>absolutePoseInputs({...feedback,rx:undefined},'夹具'))})
|
||||
test('组件名称及默认空目标,坐标系成对选择并拒绝引用',()=>{const node=createArmTeachingGroup().nodeList.find(n=>n.action==='ARM_MOVE_COORDINATE_STEP');assert.equal(node.name,'移动到目标位姿');for(const k of ['xMm','yMm','zMm','rxDeg','ryDeg','rzDeg'])assert.equal(node.nodeParams.find(p=>p.name===k).input,null);const params=setCoordinateSelection(node.nodeParams,{name:'夹具',revision:values.expectedRevision}).map(p=>({...p,input:p.name in values?values[p.name]:p.input}));assert.equal(validateArmTeachingConfiguration(node.action,params),true);const quoted=params.map(p=>p.name==='name'?{...p,type:'quote'}:p);assert.throws(()=>validateArmTeachingConfiguration(node.action,quoted));assert.throws(()=>workflowCoordinateStep({...values,velocityMm:0}));assert.throws(()=>workflowCoordinateStep({...values,expectedRevision:'0'}))})
|
||||
test('组件名称及默认空目标,坐标系按名称选择并拒绝引用',()=>{const node=createArmTeachingGroup().nodeList.find(n=>n.action==='ARM_MOVE_COORDINATE_STEP');assert.equal(node.name,'移动到目标位姿');for(const k of ['xMm','yMm','zMm','rxDeg','ryDeg','rzDeg'])assert.equal(node.nodeParams.find(p=>p.name===k).input,null);const params=setCoordinateSelection(node.nodeParams,{name:'夹具',revision:values.expectedRevision}).map(p=>({...p,input:p.name in values?values[p.name]:p.input}));assert.equal(validateArmTeachingConfiguration(node.action,params),true);const quoted=params.map(p=>p.name==='name'?{...p,type:'quote'}:p);assert.throws(()=>validateArmTeachingConfiguration(node.action,quoted));assert.throws(()=>workflowCoordinateStep({...values,velocityMm:0}));assert.doesNotThrow(()=>workflowCoordinateStep({...values,expectedRevision:'0'}));assert.doesNotThrow(()=>workflowCoordinateStep({...values,expectedRevision:undefined}));assert.equal(params.some(p=>p.name==='expectedRevision'),false)})
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import { getDeviceKindForAction } from './robotDevice.js'
|
||||
import { validateWorkcellLiterals, refreshWorkcellOutputs } from './scanMotorNodes.mjs'
|
||||
import { normalizeCoordinateSelectionParams } from './armWorkflowCoordinates.mjs'
|
||||
import { withoutCoordinateVersions } from './actionQueue.js'
|
||||
|
||||
export const FLOW_SCHEMA_VERSION = 2
|
||||
export const DEFAULT_ROLE_KEY = 'default_executor'
|
||||
@ -658,6 +660,26 @@ export const sanitizeFlowResourceDefinition = (sourceGraph) => {
|
||||
(param) => param.name !== 'deviceId'
|
||||
)
|
||||
})
|
||||
graph.nodes.forEach((node) => {
|
||||
const action = node.properties?.action
|
||||
const params = node.properties?.nodeParams
|
||||
if (!Array.isArray(params)) return
|
||||
node.properties.nodeParams = normalizeCoordinateSelectionParams(action, params)
|
||||
if (['ARM_MOVE_TO_POINT', 'ARM_MOVE_L', 'ARM_MOVE_J_POSE'].includes(action))
|
||||
node.properties.nodeParams = node.properties.nodeParams.filter((param) => param.name !== 'userCoordinateRevision')
|
||||
if (action !== 'SYSTEM_EXECUTE_ACTION_QUEUE') return
|
||||
node.properties.nodeParams.forEach((param) => {
|
||||
if (param.name !== 'steps' || param.type === 'quote') return
|
||||
const serialized = typeof param.input === 'string'
|
||||
let steps = param.input
|
||||
if (serialized) {
|
||||
try { steps = JSON.parse(steps) } catch { return }
|
||||
}
|
||||
if (!Array.isArray(steps)) return
|
||||
const normalized = steps.map(withoutCoordinateVersions)
|
||||
param.input = serialized ? JSON.stringify(normalized) : normalized
|
||||
})
|
||||
})
|
||||
return graph
|
||||
}
|
||||
|
||||
|
||||
@ -284,8 +284,7 @@ async function inspect(row) {
|
||||
await run(async (token) => {
|
||||
const res = await api('getUserCoordinateSystem', {
|
||||
...common(),
|
||||
name: row.name,
|
||||
expectedRevision: row.revision
|
||||
name: row.name
|
||||
})
|
||||
if (token === generation) {
|
||||
detail.value = res.data
|
||||
@ -298,8 +297,7 @@ async function edit(row) {
|
||||
await run(async (token) => {
|
||||
const res = await api('getUserCoordinateSystem', {
|
||||
...common(),
|
||||
name: row.name,
|
||||
expectedRevision: row.revision
|
||||
name: row.name
|
||||
})
|
||||
if (token !== generation) return
|
||||
const c = res.data.coordinate
|
||||
@ -367,7 +365,7 @@ async function apply(row) {
|
||||
current = generation
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`应用“${coordinateLabel(row.name)}”的版本 ${row.revision},${builtIn(row) ? '保留当前实际工具偏移' : '设置记录中的工具偏移'}。此操作不运动,成功后可填写目标位姿并执行运动。`,
|
||||
`按名称应用“${coordinateLabel(row.name)}”的当前记录,${builtIn(row) ? '保留当前实际工具偏移' : '设置记录中的工具偏移'}。此操作不运动,成功后可填写目标位姿并执行运动。`,
|
||||
'应用用户坐标系'
|
||||
)
|
||||
} catch {
|
||||
@ -379,16 +377,16 @@ async function apply(row) {
|
||||
await run(async (token) => {
|
||||
const res = await api('applyUserCoordinateSystem', {
|
||||
...target,
|
||||
name: row.name,
|
||||
expectedRevision: row.revision
|
||||
name: row.name
|
||||
})
|
||||
if (token !== generation) return
|
||||
if (!coordinateApplied(res.data, row))
|
||||
const applied = res.data?.coordinate
|
||||
if (applied?.name !== row.name || !coordinateApplied(res.data, applied))
|
||||
throw new Error('应用回执未完整确认工件设置、名称版本或实际TCP,单步运动保持禁用')
|
||||
detail.value = res.data
|
||||
await load()
|
||||
if (!active || target.robotId !== props.robotId || target.deviceId !== props.deviceId) return
|
||||
if (!coordinateStillApplied(catalog.value, row))
|
||||
if (!coordinateStillApplied(catalog.value, applied))
|
||||
throw new Error('当前应用名称或版本已变化,请重新查询并应用')
|
||||
const loadToken = generation,
|
||||
tcp = await api('getActiveTcpOffset', target, { quiet: true })
|
||||
@ -402,7 +400,7 @@ async function apply(row) {
|
||||
if (!coordinateTcpMatches(res.data, tcp.data))
|
||||
throw new Error('实际TCP偏移与完整应用回执不一致,请核对设备后重新应用')
|
||||
appliedReceipt.value = JSON.parse(JSON.stringify(res.data))
|
||||
appliedRow.value = { name: row.name, revision: row.revision }
|
||||
appliedRow.value = { name: applied.name, revision: applied.revision }
|
||||
ElMessage.success('完整应用回执、当前名称版本及实际TCP校验通过,可手动目标位姿运动')
|
||||
})
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<h4>移动到目标位姿</h4>
|
||||
<p class="hint"
|
||||
>{{
|
||||
row ? `${coordinateLabel(row.name)} · 版本 ${row.revision}` : '请选择并应用坐标系'
|
||||
row ? coordinateLabel(row.name) : '请选择并应用坐标系'
|
||||
}}。以下六项是所选坐标系下的绝对TCP目标;姿态填0表示与参考系对齐。</p
|
||||
>
|
||||
<el-button :loading="reading" :disabled="!row || moving || stopping" @click="readCurrent"
|
||||
@ -136,7 +136,6 @@ async function move() {
|
||||
...settings,
|
||||
targetMode: 'absolute_selected_frame',
|
||||
name: props.row.name,
|
||||
expectedRevision: props.row.revision,
|
||||
timeoutMs: settings.timeoutSeconds * 1000
|
||||
}),
|
||||
robotId: props.robotId,
|
||||
|
||||
@ -55,17 +55,14 @@
|
||||
<el-form-item label="应用坐标系" required>
|
||||
<div class="single-queue-coordinate">
|
||||
<el-select :model-value="step.params?.name || ''" filterable placeholder="读取当前机械臂已保存的坐标系" @update:model-value="selectCoordinate(step, $event)">
|
||||
<el-option v-for="row in coordinateState(step).rows" :key="row.name" :label="`${coordinateLabel(row.name)} · 版本 ${row.revision}`" :value="row.name" />
|
||||
<el-option v-for="row in coordinateState(step).rows" :key="row.name" :label="coordinateLabel(row.name)" :value="row.name" />
|
||||
<el-option v-if="step.params?.name && !coordinateState(step).rows.some(row => row.name === step.params.name)" :label="coordinateLabel(step.params.name)" :value="step.params.name" />
|
||||
</el-select>
|
||||
<el-button :loading="coordinateState(step).loading" :disabled="!robotId || !step.deviceId || deviceLoading" @click="loadCoordinates(step)">读取坐标系</el-button>
|
||||
</div>
|
||||
<div class="single-queue-note">仅查询当前执行机械臂,不会应用坐标系或执行运动。</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="坐标系版本">
|
||||
<el-checkbox :model-value="step.params?.expectedRevision === '0'" :disabled="isBuiltInCoordinate(step) || !coordinateState(step).rows.some(row => row.name === step.params?.name)" @update:model-value="selectLatestRevision(step, $event)">执行时使用最新版本</el-checkbox>
|
||||
<span class="single-queue-note">{{ step.params?.expectedRevision === '0' ? '运行时读取最新记录' : `固定版本 ${step.params?.expectedRevision || '未选择'}` }}</span>
|
||||
</el-form-item>
|
||||
<p class="single-queue-note">仅保存名称,执行时使用当前记录。</p>
|
||||
<el-alert v-if="coordinateState(step).error" :title="coordinateState(step).error" type="warning" :closable="false" />
|
||||
</template>
|
||||
<el-form-item label="步骤超时(毫秒,0继承队列剩余时间)"><el-input-number v-model="step.timeoutMs" :min="0" :max="1800000" :precision="0" :step="1000" /></el-form-item>
|
||||
@ -87,7 +84,7 @@ import { DEVICE_KIND } from '@/cmvr/common/utils/robotDevice'
|
||||
import { armTeachingRequest } from '@/cmvr/common/api/device/armTeaching'
|
||||
import { userCoordinateCatalog } from '@/cmvr/common/utils/armCoordinateFrames.mjs'
|
||||
import { coordinateLabel } from '@/cmvr/common/utils/armUserCoordinates.mjs'
|
||||
import { copyActionQueueStep, getActionQueueStepName, moveActionQueueStep, toActionQueueExecutionSteps, validateActionQueueCoordinateParams, validateActionQueueCoordinateSequence, isAppliedCoordinateMove, actionQueueSingleExecutionSteps } from '@/cmvr/common/utils/actionQueue'
|
||||
import { copyActionQueueStep, getActionQueueStepName, moveActionQueueStep, toActionQueueExecutionSteps, validateActionQueueCoordinateParams, withoutCoordinateVersions, validateActionQueueCoordinateSequence, isAppliedCoordinateMove, actionQueueSingleExecutionSteps } from '@/cmvr/common/utils/actionQueue'
|
||||
import { requireStandaloneQueueSpeed } from '@/cmvr/common/utils/actionQueueSpeed.mjs'
|
||||
|
||||
/**
|
||||
@ -131,15 +128,10 @@ const assignStepDevice = (step, deviceId) => {
|
||||
if ((item.deviceSlotKey || item.deviceBindingKey) === binding && deviceKind(item.type) === deviceKind(step.type)) item.deviceId = deviceId
|
||||
})
|
||||
}
|
||||
const isBuiltInCoordinate = (step) => ['__builtin_base__', '__builtin_tool__'].includes(step.params?.name)
|
||||
const selectCoordinate = (step, name) => {
|
||||
const record = coordinateState(step).rows.find(row => row.name === name)
|
||||
if (!record) return
|
||||
step.params = { name: record.name, expectedRevision: record.revision }
|
||||
}
|
||||
const selectLatestRevision = (step, latest) => {
|
||||
const record = coordinateState(step).rows.find(row => row.name === step.params?.name)
|
||||
if (record) step.params.expectedRevision = isBuiltInCoordinate(step) ? '1' : latest ? '0' : record.revision
|
||||
step.params = { name: record.name }
|
||||
}
|
||||
const loadCoordinates = async (step) => {
|
||||
const currentRobot = robotId.value, currentDevice = step.deviceId
|
||||
@ -183,7 +175,7 @@ const devicesForStep = (step) => devices.value.filter((device) => Number(device.
|
||||
* 等待和站点导航使用易读文案,其余动作保留完整 JSON 信息。
|
||||
*/
|
||||
const stepSummary = (step) => {
|
||||
if (step.type === 'ARM_APPLY_USER_COORDINATE_SYSTEM') return `应用 ${coordinateLabel(step.params?.name || '未选择')} · ${step.params?.expectedRevision === '0' ? '执行时最新版本' : `固定版本 ${step.params?.expectedRevision || '未选择'}`}`
|
||||
if (step.type === 'ARM_APPLY_USER_COORDINATE_SYSTEM') return `应用 ${coordinateLabel(step.params?.name || '未选择')} · 执行时使用当前记录`
|
||||
if (step.type === 'DELAY') return `等待 ${step.params?.durationMs || 0} 毫秒`
|
||||
if (step.type === 'AGV_NAVIGATE_TO_STATION') return `站点 ${step.params?.stationId || '-'}`
|
||||
return JSON.stringify(step.params || {})
|
||||
@ -198,7 +190,7 @@ const initData = async () => {
|
||||
const values = Object.fromEntries(props.nodeParams.map((item) => [item.name, item.input]))
|
||||
actionId.value = values.actionId || ''
|
||||
steps.value = JSON.parse(JSON.stringify(Array.isArray(values.steps) ? values.steps : [])).map((step, index) => ({
|
||||
...step,
|
||||
...withoutCoordinateVersions(step),
|
||||
timeoutMs: Number(step.timeoutMs ?? 120000),
|
||||
stepName: getActionQueueStepName(step, index),
|
||||
runtimeKey: createRuntimeKey(),
|
||||
|
||||
@ -85,18 +85,12 @@
|
||||
</el-form-item>
|
||||
<template v-if="step.type === QUEUE_APPLY_COORDINATE">
|
||||
<ArmWorkflowCoordinateSelect
|
||||
:model-value="{ name: step.params.name, revision: step.selectedRevision || step.params.expectedRevision }"
|
||||
:model-value="{ name: step.params.name }"
|
||||
@selected="(row) => selectCoordinate(step, row)"
|
||||
@read-target-change="step.readTarget = $event"
|
||||
/>
|
||||
<el-form-item v-if="step.params.name && !String(step.params.name).startsWith('__builtin_')" label="使用版本">
|
||||
<el-radio-group :model-value="step.params.expectedRevision === '0' ? 'latest' : 'fixed'" @update:model-value="(mode) => changeCoordinateVersion(step, mode)">
|
||||
<el-radio-button value="fixed" :disabled="!step.selectedRevision || step.selectedRevision === '0'">固定所选版本</el-radio-button>
|
||||
<el-radio-button value="latest">执行时取最新</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<p class="queue-editor__hint">仅应用已保存记录,不创建坐标系、不使能、不运动。应用计为一个步骤;队列结束后保持该坐标系,如需恢复请在末尾应用基座坐标系。</p>
|
||||
<p v-if="step.params.expectedRevision === '0' && step.params.name" class="queue-editor__warning">执行时使用最新记录;若坐标系被修改,后续绝对目标将按新记录解释。</p>
|
||||
<p v-if="step.params.name" class="queue-editor__warning">仅保存名称,执行时使用当前记录;若坐标系被修改,后续绝对目标将按新记录解释。</p>
|
||||
</template>
|
||||
<template v-if="['ARM_MOVE_L','ARM_MOVE_J_POSE'].includes(step.type)">
|
||||
<p v-if="step.type === 'ARM_MOVE_J_POSE'" class="queue-editor__hint">{{ armMotionUnitHint(step.type) }}</p>
|
||||
@ -149,7 +143,7 @@
|
||||
:step="field.step || 1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<el-input v-else v-model="step.params[field.key]" :readonly="step.type === 'ARM_MOVE_L' && ['userCoordinateName','userCoordinateRevision'].includes(field.key)" :placeholder="step.type === 'ARM_MOVE_L' && ['userCoordinateName','userCoordinateRevision'].includes(field.key) ? '点击读取可用坐标系后下拉选择,版本自动带入' : ''" :type="field.multiline ? 'textarea' : 'text'" :rows="3" />
|
||||
<el-input v-else v-model="step.params[field.key]" :readonly="step.type === 'ARM_MOVE_L' && ['userCoordinateName'].includes(field.key)" :placeholder="step.type === 'ARM_MOVE_L' && ['userCoordinateName'].includes(field.key) ? '点击读取可用坐标系后按名称选择' : ''" :type="field.multiline ? 'textarea' : 'text'" :rows="3" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-form>
|
||||
@ -211,7 +205,7 @@ import {
|
||||
copyActionQueueStep, getActionQueueStepName, moveActionQueueStep,
|
||||
QUEUE_APPLY_COORDINATE, QUEUE_LEGACY_COORDINATE_FIELDS,
|
||||
isAppliedCoordinateMove, actionQueueCoordinateContext, actionQueueSingleExecutionSteps,
|
||||
validateActionQueueCoordinateParams, validateActionQueueCoordinateSequence,
|
||||
validateActionQueueCoordinateParams, withoutCoordinateVersions, validateActionQueueCoordinateSequence,
|
||||
} from '@/cmvr/common/utils/actionQueue'
|
||||
|
||||
const props = defineProps({ data: { type: Object, required: true } })
|
||||
@ -244,7 +238,6 @@ const fieldsByType = {
|
||||
{ key: 'baseFrame', label: '旧基准坐标系(已停用,请清空)', required:false },
|
||||
{ key: 'tcpFrame', label: '旧工具坐标系(已停用,请清空)', required:false },
|
||||
{key:'userCoordinateName',label:'服务端用户坐标系名称',required:false},
|
||||
{key:'userCoordinateRevision',label:'坐标系版本(字符串)',required:false},
|
||||
{key:'coordinateRelativeTranslation',label:'沿坐标轴相对平移(XYZ为位移,姿态为0)',required:false,options:[{value:false,label:'否,绝对目标'},{value:true,label:'是,相对平移'}]},
|
||||
...commonMotionFields,
|
||||
],
|
||||
@ -266,7 +259,7 @@ const fieldsByType = {
|
||||
}
|
||||
const defaultParams = {
|
||||
DELAY: { durationMs: 1000 },
|
||||
[QUEUE_APPLY_COORDINATE]: { name: '', expectedRevision: '0' },
|
||||
[QUEUE_APPLY_COORDINATE]: { name: '' },
|
||||
ARM_MOVE_J: { positions: '[0, 0, 0, 0, 0, 0]', velocity: 0.1, acceleration: 0.2 },
|
||||
ARM_MOVE_J_POSE: { x:null,y:null,z:null,rx:null,ry:null,rz:null,velocity:0.1,acceleration:0.5 },
|
||||
ARM_MOVE_L: { x: 0, y: 0, z: 0, rx: 0, ry: 0, rz: 0, velocity: 0.005, acceleration: 0.01 },
|
||||
@ -316,6 +309,7 @@ const selectedRole = () => roles.value.find((role) => role.roleKey === formData.
|
||||
const matchingSlots = (type) => (selectedRole()?.deviceSlots || []).filter((slot) => Number(slot.deviceKind) === deviceKindForType(type))
|
||||
|
||||
const normalizeStep = (source = {}, index = 0) => {
|
||||
source = withoutCoordinateVersions(source)
|
||||
const params = { ...(defaultParams[source.type || 'DELAY'] || {}), ...(source.params || {}) }
|
||||
for (const key of ['positions', 'path']) {
|
||||
if (Array.isArray(params[key])) params[key] = JSON.stringify(params[key])
|
||||
@ -329,7 +323,6 @@ const normalizeStep = (source = {}, index = 0) => {
|
||||
motionLimits: {},
|
||||
speedSource: queueSpeedSource(source, props.data.properties?.nodeParams),
|
||||
...(source.coordinateMode ? { coordinateMode: source.coordinateMode } : {}),
|
||||
selectedRevision: source.params?.expectedRevision && source.params.expectedRevision !== '0' ? source.params.expectedRevision : '',
|
||||
timeoutMs: source.timeoutMs === undefined || source.timeoutMs === null
|
||||
? defaultTimeoutByType[source.type || 'DELAY']
|
||||
: Number(source.timeoutMs),
|
||||
@ -429,11 +422,7 @@ const handleStepTypeChange = (step) => {
|
||||
const handleRoleChange = () => formData.steps.forEach((step) => ensureStepSlot(step))
|
||||
|
||||
const selectCoordinate = (step, row) => {
|
||||
step.params = validateActionQueueCoordinateParams({ name: row.name, expectedRevision: row.revision })
|
||||
step.selectedRevision = row.revision
|
||||
}
|
||||
const changeCoordinateVersion = (step, mode) => {
|
||||
step.params.expectedRevision = mode === 'latest' ? '0' : step.selectedRevision
|
||||
step.params = validateActionQueueCoordinateParams({ name: row.name })
|
||||
}
|
||||
const useAppliedCoordinate = (step) => {
|
||||
QUEUE_LEGACY_COORDINATE_FIELDS.forEach((key) => delete step.params[key])
|
||||
@ -441,7 +430,7 @@ const useAppliedCoordinate = (step) => {
|
||||
}
|
||||
const coordinateContextLabel = (index) => {
|
||||
const context = actionQueueCoordinateContext(formData.steps, index)
|
||||
return context ? `${coordinateLabel(context.params.name)} · ${context.params.expectedRevision === '0' ? '执行时取最新' : `版本 ${context.params.expectedRevision}`}` : '尚未添加,请先为相同设备用途添加“应用坐标系”步骤'
|
||||
return context ? `${coordinateLabel(context.params.name)} · 执行时使用当前记录` : '尚未添加,请先为相同设备用途添加“应用坐标系”步骤'
|
||||
}
|
||||
|
||||
const loadHelperRobots = async () => {
|
||||
@ -472,7 +461,7 @@ const loadHelperDevices = async (robotId) => {
|
||||
|
||||
const openStepHelper = async (step, mode = 'position') => {
|
||||
helperMode.value = mode; helperFrameCatalog.value = null
|
||||
helperFrames.value = {baseFrame:step.params.baseFrame || '',tcpFrame:step.params.tcpFrame || '',userCoordinateName:step.params.userCoordinateName||'',userCoordinateRevision:step.params.userCoordinateRevision||'',coordinateRelativeTranslation:step.params.coordinateRelativeTranslation||false}
|
||||
helperFrames.value = {baseFrame:step.params.baseFrame || '',tcpFrame:step.params.tcpFrame || '',userCoordinateName:step.params.userCoordinateName||'',coordinateRelativeTranslation:step.params.coordinateRelativeTranslation||false}
|
||||
helperStep.value = step
|
||||
const context = actionQueueCoordinateContext(formData.steps, formData.steps.indexOf(step))
|
||||
if (isAppliedCoordinateMove(step) && !context) {
|
||||
@ -527,14 +516,14 @@ const applyStepHelper = async () => {
|
||||
const context = actionQueueCoordinateContext(formData.steps, formData.steps.indexOf(step))
|
||||
const inherited = isAppliedCoordinateMove(step)
|
||||
const coordinate = inherited ? validateActionQueueCoordinateParams(context?.params)
|
||||
: helperFrames.value.userCoordinateName ? { name: helperFrames.value.userCoordinateName, expectedRevision: helperFrames.value.userCoordinateRevision } : null
|
||||
const frameChoice = inherited ? { userCoordinateName: coordinate.name, userCoordinateRevision: coordinate.expectedRevision } : { ...helperFrames.value }
|
||||
: helperFrames.value.userCoordinateName ? { name: helperFrames.value.userCoordinateName } : null
|
||||
const frameChoice = inherited ? { userCoordinateName: coordinate.name } : { ...helperFrames.value }
|
||||
const legacyFrame = inherited ? 'BASE' : step.params.frame
|
||||
const query = poseFrameQuery(frameChoice, legacyFrame)
|
||||
if (coordinate) {
|
||||
const record = await armTeachingRequest('getUserCoordinateSystem', {...target,...coordinate})
|
||||
if (record.data?.coordinate?.name !== coordinate.name || (coordinate.expectedRevision !== '0' && record.data.coordinate.revision !== coordinate.expectedRevision))
|
||||
throw new Error('前序坐标系名称或版本已变化,请重新选择')
|
||||
if (record.data?.coordinate?.name !== coordinate.name)
|
||||
throw new Error('前序坐标系名称未确认,请重新选择')
|
||||
}
|
||||
const response = await getArmStatus({...target,...query})
|
||||
const pose = response?.data
|
||||
@ -577,7 +566,7 @@ const applyStepHelper = async () => {
|
||||
}
|
||||
|
||||
const parseJsonFields = (step) => {
|
||||
const params = { ...step.params }
|
||||
const params = withoutCoordinateVersions(step).params
|
||||
for (const key of ['positions', 'path']) {
|
||||
if (typeof params[key] !== 'string') continue
|
||||
try {
|
||||
@ -662,7 +651,7 @@ const buildQueueDefinition = () => {
|
||||
deviceBindingKey: step.deviceBindingKey,
|
||||
deviceSlotKey: step.deviceSlotKey,
|
||||
} : {}),
|
||||
...(step.sourceNode ? { sourceNode: JSON.parse(JSON.stringify(step.sourceNode)) } : {}),
|
||||
...(step.sourceNode ? { sourceNode: withoutCoordinateVersions(step).sourceNode } : {}),
|
||||
params: speed.params,
|
||||
...(speed.paramBindings ? { paramBindings: speed.paramBindings } : {}),
|
||||
}
|
||||
|
||||
@ -15,13 +15,10 @@
|
||||
v-for="c in catalog?.userCoordinates || []"
|
||||
:key="c.name"
|
||||
:value="c.name"
|
||||
:label="`${coordinateLabel(c.name)} · 版本 ${c.revision}`" /></el-select
|
||||
:label="coordinateLabel(c.name)" /></el-select
|
||||
></el-form-item>
|
||||
<p v-if="modelValue.userCoordinateName" class="frame-tip"
|
||||
>已选择版本
|
||||
{{
|
||||
modelValue.userCoordinateRevision
|
||||
}}。读取结果为该参考系下的实际TCP位姿(位置m、姿态rad),不是坐标系定义或位移增量。版本变化或服务重连后,需重新查询并应用后再运行。</p
|
||||
>仅保存坐标系名称,执行时使用当前记录。读取结果为该参考系下的实际TCP位姿(位置m、姿态rad),不是坐标系定义或位移增量;运行前仍须应用同名坐标系。</p
|
||||
>
|
||||
<p v-if="modelValue.userCoordinateName === '__builtin_tool__'" class="frame-tip">工具参考系使用最近一次应用时冻结的TCP坐标系;需先应用该记录,读取操作不会自动应用。</p>
|
||||
</el-form>
|
||||
@ -62,10 +59,11 @@ function selectCoordinate(name) {
|
||||
if (props.disabled || loading.value) return
|
||||
const c = catalog.value?.userCoordinates?.find((c) => c.name === name)
|
||||
if (name && !c) return
|
||||
const choice = { ...props.modelValue }
|
||||
delete choice.userCoordinateRevision
|
||||
emit('update:modelValue', {
|
||||
...props.modelValue,
|
||||
...choice,
|
||||
userCoordinateName: name,
|
||||
userCoordinateRevision: c?.revision || '',
|
||||
...(name ? { baseFrame: '', tcpFrame: '' } : {})
|
||||
})
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
v-if="usesCoordinateSelection(data.properties?.action)"
|
||||
:key="data.id"
|
||||
:model-value="coordinateChoice"
|
||||
:require-revision="requiresCoordinateRevision"
|
||||
:allow-built-in="
|
||||
!['ARM_UPDATE_USER_COORDINATE_SYSTEM', 'ARM_DELETE_USER_COORDINATE_SYSTEM'].includes(
|
||||
data.properties?.action
|
||||
@ -128,6 +129,8 @@ import {
|
||||
COORDINATE_STEP_ACTION,
|
||||
usesCoordinateSelection,
|
||||
coordinateSelectionField,
|
||||
coordinateRevisionRequired,
|
||||
normalizeCoordinateSelectionParams,
|
||||
canReferenceArmParameter,
|
||||
setCoordinateSelection,
|
||||
normalizeWorkflowStepParams,
|
||||
@ -168,13 +171,14 @@ const target = ref({}),
|
||||
parameters = ref([]),
|
||||
saving = ref(false)
|
||||
const pickerOpen = ref(false)
|
||||
const requiresCoordinateRevision = computed(() => coordinateRevisionRequired(props.data.properties?.action))
|
||||
const coordinateChoice = computed(() => ({
|
||||
name:
|
||||
parameters.value.find((p) => p.name === 'name' && p.type === 'input')?.input ||
|
||||
parameters.value.find((p) => p.name === 'coordinate')?.input?.name ||
|
||||
'',
|
||||
revision:
|
||||
parameters.value.find((p) => p.name === 'expectedRevision' && p.type === 'input')?.input || ''
|
||||
...(requiresCoordinateRevision.value ? { revision:
|
||||
parameters.value.find((p) => p.name === 'expectedRevision' && p.type === 'input')?.input || '' } : {})
|
||||
}))
|
||||
const visibleParameters = computed(() =>
|
||||
parameters.value.filter(
|
||||
@ -192,14 +196,12 @@ async function fillCurrentPose() {
|
||||
try {
|
||||
const record = await coordinateReader('getUserCoordinateSystem', {
|
||||
...origin,
|
||||
name: choice.name,
|
||||
expectedRevision: choice.revision
|
||||
name: choice.name
|
||||
})
|
||||
if (
|
||||
record.data?.coordinate?.name !== choice.name ||
|
||||
record.data.coordinate.revision !== choice.revision
|
||||
record.data?.coordinate?.name !== choice.name
|
||||
)
|
||||
throw new Error('坐标系名称或版本未确认,请重新读取列表')
|
||||
throw new Error('坐标系名称未确认,请重新读取列表')
|
||||
const res = await poseReader({
|
||||
...origin,
|
||||
baseLink: choice.name === '__builtin_base__' ? 'base' : choice.name,
|
||||
@ -223,7 +225,7 @@ async function fillCurrentPose() {
|
||||
}
|
||||
}
|
||||
function selectCoordinate(row) {
|
||||
parameters.value = setCoordinateSelection(parameters.value, row)
|
||||
parameters.value = setCoordinateSelection(parameters.value, row, requiresCoordinateRevision.value)
|
||||
const coordinate = parameters.value.find((p) => p.name === 'coordinate')
|
||||
if (coordinate) {
|
||||
coordinate.type = 'input'
|
||||
@ -246,7 +248,7 @@ watch(
|
||||
const savedParams =
|
||||
props.data.properties?.action === COORDINATE_STEP_ACTION
|
||||
? normalizeWorkflowStepParams(copy(props.data.properties?.nodeParams || []))
|
||||
: props.data.properties?.nodeParams || []
|
||||
: normalizeCoordinateSelectionParams(props.data.properties?.action, props.data.properties?.nodeParams || [])
|
||||
parameters.value = (preset.value?.nodeParams || []).map((field) => ({
|
||||
...copy(field),
|
||||
...copy(savedParams.find((item) => item.name === field.name) || {})
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
v-for="row in selectableRows"
|
||||
:key="row.name"
|
||||
:value="row.name"
|
||||
:label="`${coordinateLabel(row.name)} · 版本 ${row.revision}`"
|
||||
:label="requireRevision ? `${coordinateLabel(row.name)} · 版本 ${row.revision}` : coordinateLabel(row.name)"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button
|
||||
@ -66,8 +66,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<p v-if="modelValue.name" class="hint"
|
||||
>已配置:{{ coordinateLabel(modelValue.name) }} · 版本
|
||||
{{ modelValue.revision }}。名称和版本一起保存,不使用上游引用。</p
|
||||
>已配置:{{ coordinateLabel(modelValue.name) }}<template v-if="requireRevision"> · 版本 {{ modelValue.revision }},用于修改或删除时的并发校验</template><template v-else>。仅保存名称,执行时使用该名称的当前记录</template>,不使用上游引用。</p
|
||||
>
|
||||
<el-alert v-if="error" :title="error" type="warning" :closable="false" />
|
||||
</section>
|
||||
@ -82,6 +81,7 @@ import { coordinateLabel } from '@/cmvr/common/utils/armUserCoordinates.mjs'
|
||||
const props = defineProps({
|
||||
modelValue: { type: Object, default: () => ({}) },
|
||||
allowBuiltIn: { type: Boolean, default: true },
|
||||
requireRevision: { type: Boolean, default: false },
|
||||
api: { type: Function, default: armTeachingRequest },
|
||||
robotReader: { type: Function, default: getRobotList },
|
||||
deviceReader: { type: Function, default: getRobotDevicesByRobotId }
|
||||
@ -169,7 +169,7 @@ async function load() {
|
||||
function select(name) {
|
||||
const row = selectableRows.value.find((r) => r.name === name)
|
||||
if (!row || loading.value) return
|
||||
emit('update:modelValue', { name: row.name, revision: row.revision })
|
||||
emit('update:modelValue', { name: row.name, ...(props.requireRevision ? { revision: row.revision } : {}) })
|
||||
emit('selected', JSON.parse(JSON.stringify(row)))
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
@ -168,10 +168,7 @@ const poseCoordinateSummary = computed(() => {
|
||||
const coordinate = field('userCoordinateName')
|
||||
if (coordinate?.type === 'quote') return '运行时引用,当前尚未确定'
|
||||
if (typeof coordinate?.input === 'string' && coordinate.input.trim()) {
|
||||
const revision = field('userCoordinateRevision')
|
||||
const version = revision?.type === 'quote' ? '版本由运行时引用确定'
|
||||
: revision?.input != null && revision.input !== '' ? `版本 ${revision.input}` : '版本未指定'
|
||||
return `${coordinateLabel(coordinate.input)} · ${version}`
|
||||
return `${coordinateLabel(coordinate.input)} · 执行时使用当前记录`
|
||||
}
|
||||
return '未指定(沿用边端当前参考系)'
|
||||
})
|
||||
@ -382,7 +379,7 @@ const testRule = (property) => {
|
||||
const robotFormAction = ref()
|
||||
const helperMode = ref('position'), helperFrames = ref({}), helperFrameCatalog = ref(null)
|
||||
function applyFrameSelection() {
|
||||
for(const key of ['userCoordinateName','userCoordinateRevision','coordinateRelativeTranslation']){const p=formData.nodeParams.find(p=>p.name===key);if(p?.type==='input')p.input=helperFrames.value[key]??(key==='coordinateRelativeTranslation'?false:'')}
|
||||
for(const key of ['userCoordinateName','coordinateRelativeTranslation']){const p=formData.nodeParams.find(p=>p.name===key);if(p?.type==='input')p.input=helperFrames.value[key]??(key==='coordinateRelativeTranslation'?false:'')}
|
||||
for (const [key,list] of [['baseFrame','baseFrames'],['tcpFrame','tcpFrames']]) {
|
||||
const param = formData.nodeParams.find(p => p.name === key)
|
||||
if (param?.type === 'input') param.input = helperFrames.value[key] || ''
|
||||
@ -523,10 +520,10 @@ async function readArmPosition() {
|
||||
if (!valid) return
|
||||
if (choice.userCoordinateName) {
|
||||
const record = await armTeachingRequest('getUserCoordinateSystem', {
|
||||
...target, name: choice.userCoordinateName, expectedRevision: choice.userCoordinateRevision
|
||||
...target, name: choice.userCoordinateName
|
||||
}, { quiet: true })
|
||||
if (record.data?.coordinate?.name !== choice.userCoordinateName || record.data.coordinate.revision !== choice.userCoordinateRevision)
|
||||
throw new Error('坐标系名称或版本已变化,请重新读取列表并选择')
|
||||
if (record.data?.coordinate?.name !== choice.userCoordinateName)
|
||||
throw new Error('坐标系名称未确认,请重新读取列表并选择')
|
||||
}
|
||||
const response = await getArmStatus({ ...target, ...poseFrameQuery(choice, legacy) })
|
||||
if (!dialogVisible.value || nodeId !== props.data.id || robotFormAction.value !== props.data.properties.action
|
||||
@ -569,7 +566,7 @@ const toStationOptions = (stations) => (Array.isArray(stations) ? stations : [])
|
||||
const openRobotForm = async (action, mode = 'position') => {
|
||||
helperMode.value = mode
|
||||
helperFrameCatalog.value = null
|
||||
helperFrames.value = Object.fromEntries(['baseFrame','tcpFrame','userCoordinateName','userCoordinateRevision','coordinateRelativeTranslation'].map(key => [key,formData.nodeParams.find(p => p.name === key && p.type === 'input')?.input ?? (key==='coordinateRelativeTranslation'?false:'')]))
|
||||
helperFrames.value = Object.fromEntries(['baseFrame','tcpFrame','userCoordinateName','coordinateRelativeTranslation'].map(key => [key,formData.nodeParams.find(p => p.name === key && p.type === 'input')?.input ?? (key==='coordinateRelativeTranslation'?false:'')]))
|
||||
dialogVisible.value = true
|
||||
robotFormAction.value = action
|
||||
robotForm.deviceId = ''
|
||||
|
||||
9
deploy/windows11/RELEASE-20261121-coordinate-names.md
Normal file
9
deploy/windows11/RELEASE-20261121-coordinate-names.md
Normal file
@ -0,0 +1,9 @@
|
||||
# 坐标系按名称调用
|
||||
|
||||
使用坐标系时仅保存名称,执行时取边端同名最新记录。覆盖直接查询和应用、工作流应用与目标位姿、命名MoveL/MoveJPose及动作队列;旧流程保存的expectedRevision/userCoordinateRevision兼容忽略,新保存或试运行序列化时剔除使用字段。数据库中的历史执行及冻结流程不批量改写。
|
||||
|
||||
更新和删除坐标系仍保留版本并发保护。按名字调用不会自动应用坐标系:运动前仍须确认最新同名记录已完整实际应用,并核对实际TCP、设备身份及资源占用;内部本次解析的记录版本用于拒绝运动准备期间的变更。动作队列仍要求同一机械臂的前序应用步骤,失败不自动重发。
|
||||
|
||||
本次不新增数据库结构、迁移、依赖或私有配置。现有边端协议的版本0已支持按名字取最新,并保留实际应用检查;无需修改Proto。Windows更新脚本的构建、暂存和启动入口保持,用户确认现场停止并明确要求更新后再运行原一键发布脚本。推送源码不会使运行中的Java和网页自动更新。AGV已到站处理属于独立边端程序,不由平台发布脚本安装。
|
||||
|
||||
后端89项相关回归及22模块JAR打包通过;前端51项原有回归、11项临时行为检查、完整流程保存/试运行序列化检查、8个组件离线编译、全量类型检查和standalone构建通过。改动文件ESLint无错误、无新增警告,保留20条原有格式警告;构建仍有既有图标、样式及分包大小警告。自动验证只用离线模拟,不启动现场任务或设备动作。
|
||||
@ -60,11 +60,11 @@
|
||||
|
||||
### 动作队列应用坐标系与末端位姿MoveJ(2026-11-10)
|
||||
|
||||
动作队列继续使用 `SystemService.ExecuteActionQueue`,新增“应用坐标系”步骤,对应 `ActionStep.arm_apply_user_coordinate=12`。在动作队列中选择同一机器人角色下的机械臂设备用途,读取已有坐标系后下拉选择;默认固定所选记录版本,也可选择执行时最新版本(`expected_revision=0`)。版本以十进制字符串保存,不能用标定格式版本代替记录版本。基座和当前工具两个内置坐标系使用固定版本1。
|
||||
动作队列继续使用 `SystemService.ExecuteActionQueue`,新增“应用坐标系”步骤,对应 `ActionStep.arm_apply_user_coordinate=12`。在动作队列中选择同一机器人角色下的机械臂设备用途,读取已有坐标系后下拉选择;按2026-11-21要求,使用步骤只保存坐标系名称,执行时读取同名最新记录(协议`expected_revision=0`)。历史流程中的固定版本兼容忽略,新保存会清除使用节点的旧版本字段。记录的内部版本继续由边端维护,UPDATE/DELETE仍携带十进制字符串版本防止并发覆盖。
|
||||
|
||||
推荐顺序为“应用坐标系 → 机械臂直线运动”,也可在队列中再次应用另一坐标系。新建直线运动沿用前序同一机械臂的应用步骤,输入完整绝对TCP目标(位置m、姿态rad);姿态角0表示与参考系对齐,不表示保持当前姿态。应用步骤仅引用名称和版本,不接受三点、坐标内容、TCP偏移或创建参数;沿用时不能混填旧坐标系或增量参数。旧流程的运动参数保留,需用户显式迁移后才切换到新版沿用方式,不能自动清除旧参数改变运动含义。
|
||||
推荐顺序为“应用坐标系 → 机械臂直线运动”,也可在队列中再次应用另一坐标系。新建直线运动沿用前序同一机械臂的应用步骤,输入完整绝对TCP目标(位置m、姿态rad);姿态角0表示与参考系对齐,不表示保持当前姿态。应用步骤仅引用名称,不接受三点、坐标内容、TCP偏移或创建参数;沿用时不能混填旧坐标系或增量参数。旧流程的运动参数保留,需用户显式迁移后才切换到新版沿用方式,不能自动清除旧参数改变运动含义。
|
||||
|
||||
新增“机械臂末端位姿关节运动(MoveJ)”,对应 `arm_move_j_pose=13`,必须先在同一队列为同一机械臂应用坐标系,名称和版本自动沿用该步骤。六维目标是所选坐标系下的绝对TCP位姿,XYZ为m、RX/RY/RZ为rad(RzRyRx);速度为rad/s,加速度为rad/s²。边端负责坐标变换、逆解及关节运动,平台不自行解算或降级为直线运动;混合半径固定0。原“机械臂关节运动”仍发送关节角数组,不自动转换为末端位姿。直线与末端位姿关节运动切换时保留六维目标,速度和加速度按各自单位独立保存。
|
||||
新增“机械臂末端位姿关节运动(MoveJ)”,对应 `arm_move_j_pose=13`,必须先在同一队列为同一机械臂应用坐标系,名称自动沿用该步骤;边端仍核对该名称的最新记录已实际应用。六维目标是所选坐标系下的绝对TCP位姿,XYZ为m、RX/RY/RZ为rad(RzRyRx);速度为rad/s,加速度为rad/s²。边端负责坐标变换、逆解及关节运动,平台不自行解算或降级为直线运动;混合半径固定0。原“机械臂关节运动”仍发送关节角数组,不自动转换为末端位姿。直线与末端位姿关节运动切换时保留六维目标,速度和加速度按各自单位独立保存。
|
||||
|
||||
“单独执行此步骤”针对新版沿用方式的直线运动和末端位姿MoveJ,会将同一机械臂最近的应用步骤和该运动一起提交,不执行中间其他运动。应用步骤本身也可以单独试运行。读取下拉列表及当前位姿仅查询,不会应用、使能或移动设备。
|
||||
|
||||
@ -235,7 +235,7 @@ QUIC上报连接与机械臂SDK的gRPC控制连接分别判断。QUIC断开或
|
||||
|
||||
### 机械臂速度参数来源(2026-11-10)
|
||||
|
||||
机械臂工作流的速度字段支持填写数值或引用上游,包括关节/直线运动、移动到目标位姿、轨迹起点、轨迹回放速度上限与回放倍率,以及动作队列中的机械臂运动步骤。沿用各字段显示的单位和现有范围;坐标系名称、版本及目标位姿节点的其他固定字段仍按原有规则配置。
|
||||
机械臂工作流的速度字段支持填写数值或引用上游,包括关节/直线运动、移动到目标位姿、轨迹起点、轨迹回放速度上限与回放倍率,以及动作队列中的机械臂运动步骤。沿用各字段显示的单位和现有范围;坐标系名称及目标位姿节点的其他固定字段仍按原有规则配置;坐标使用节点不保存固定记录版本,更新和删除的并发版本保留。
|
||||
|
||||
动作队列引用以标准节点引用参数保存,步骤只记录对应速度参数的绑定名;运行时从本次执行及循环轮次的已解析输入取值,再下发整条队列,不在边端逐步回读。复制、排序、重新打开及移出队列保留引用。缺少引用结果、非数值、非有限值或越界按现有运行校验报错,不回退到之前的填写值。引用速度的步骤需要通过完整工作流试运行,孤立单步调试会提示缺少上游运行上下文。
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user