From 6f49c1cf543d3789aea3da5e233dca06931c88ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 13 May 2025 09:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gd/app/cmd/DualRobotJointOriginCommand.java | 18 +++++----------- .../iflytop/gd/app/cmd/GantryXOriginCommand.java | 6 +++--- .../cmd/debug/LiquidArmResetCommandHandler.java | 25 +++++----------------- .../hardware/type/LiquidDistributionArmDriver.java | 5 +++++ .../init/zapp_sub_module_reg_initial_value.csv | 4 ++-- 5 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/iflytop/gd/app/cmd/DualRobotJointOriginCommand.java b/src/main/java/com/iflytop/gd/app/cmd/DualRobotJointOriginCommand.java index 2686851..348a158 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/DualRobotJointOriginCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/DualRobotJointOriginCommand.java @@ -6,6 +6,8 @@ import com.iflytop.gd.app.service.DeviceCommandUtilService; import com.iflytop.gd.app.service.SelfTestService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.cmd.CmdAxis; +import com.iflytop.gd.hardware.type.LiquidDistributionArmDriver; +import com.iflytop.gd.hardware.type.Servo.LiquidArmMId; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -20,23 +22,13 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("dual_robot_joint_origin")//业务指令注解 public class DualRobotJointOriginCommand extends BaseCommandHandler { - private final DeviceCommandUtilService deviceCommandUtilService; - private final SelfTestService selfTestService; + private final LiquidDistributionArmDriver liquidDistributionArmDriver; @Override public CompletableFuture handle(CmdDTO cmdDTO) { - Boolean joint1 = cmdDTO.getBooleanParam("joint1"); - Boolean joint2 = cmdDTO.getBooleanParam("joint1"); return runAsync(() -> { - - if (joint1) { - deviceCommandUtilService.dualRobotOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand(), CmdAxis.joint1); - selfTestService.getSelfTestState().setDualRobotJoint1Origin(true); - } - if (joint2) { - deviceCommandUtilService.dualRobotOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand(), CmdAxis.joint2); - selfTestService.getSelfTestState().setDualRobotJoint2Origin(true); - } + liquidDistributionArmDriver.liquidDistributionArmEnable(LiquidArmMId.LiquidDistributionArm, 1); + liquidDistributionArmDriver.liquidDistributionArmMoveTo(LiquidArmMId.LiquidDistributionArm, 0); }); } } diff --git a/src/main/java/com/iflytop/gd/app/cmd/GantryXOriginCommand.java b/src/main/java/com/iflytop/gd/app/cmd/GantryXOriginCommand.java index 5ce0db4..6695af8 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/GantryXOriginCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/GantryXOriginCommand.java @@ -28,16 +28,16 @@ public class GantryXOriginCommand extends BaseCommandHandler { Boolean x = cmdDTO.getBooleanParam("x"); Boolean y = cmdDTO.getBooleanParam("y"); Boolean z = cmdDTO.getBooleanParam("z"); - if (x) { + if (x != null && x) { deviceCommandUtilService.gantryXMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); selfTestService.getSelfTestState().setGantryXOrigin(true); } - if (y) { + if (y != null && y) { deviceCommandUtilService.gantryYMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); selfTestService.getSelfTestState().setGantryYOrigin(true); } - if (z) { + if (z != null && z) { deviceCommandUtilService.gantryZMoveOrigin(cmdDTO.getCommandId(), cmdDTO.getCommand()); selfTestService.getSelfTestState().setGantryZOrigin(true); } diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommandHandler.java b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommandHandler.java index 8b6b1b5..4672e15 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommandHandler.java +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmResetCommandHandler.java @@ -2,17 +2,13 @@ package com.iflytop.gd.app.cmd.debug; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; -import com.iflytop.gd.app.service.DeviceCommandService; import com.iflytop.gd.common.annotation.CommandMapping; -import com.iflytop.gd.common.cmd.CommandFuture; -import com.iflytop.gd.common.cmd.DeviceCommandBundle; -import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import com.iflytop.gd.hardware.type.LiquidDistributionArmDriver; +import com.iflytop.gd.hardware.type.Servo.LiquidArmMId; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.CompletableFuture; /** @@ -23,24 +19,13 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("debug_liquid_arm_reset") public class LiquidArmResetCommandHandler extends BaseCommandHandler { - private final DeviceCommandService deviceCommandService; + private final LiquidDistributionArmDriver liquidDistributionArmDriver; @Override public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { - List target = (List) cmdDTO.getParams().get("target"); - List futuresList = new ArrayList<>(); - if (target != null && target.contains("largeArm")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint1Origin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - if (target != null && target.contains("smallArm")) { - DeviceCommandBundle deviceCommand = DeviceCommandGenerator.dualRobotJoint2Origin(); - CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); - futuresList.add(deviceCommandFuture); - } - commandWait(futuresList.toArray(new CommandFuture[0])); + liquidDistributionArmDriver.liquidDistributionArmEnable(LiquidArmMId.LiquidDistributionArm, 1); + liquidDistributionArmDriver.liquidDistributionArmMoveToBlock(LiquidArmMId.LiquidDistributionArm, 0); }); } } diff --git a/src/main/java/com/iflytop/gd/hardware/type/LiquidDistributionArmDriver.java b/src/main/java/com/iflytop/gd/hardware/type/LiquidDistributionArmDriver.java index 582c830..3fee77e 100644 --- a/src/main/java/com/iflytop/gd/hardware/type/LiquidDistributionArmDriver.java +++ b/src/main/java/com/iflytop/gd/hardware/type/LiquidDistributionArmDriver.java @@ -40,6 +40,11 @@ public class LiquidDistributionArmDriver { canBus.callcmd(id.mid, CmdId.liquid_distribution_arm_move_to, index); } + public void liquidDistributionArmMoveToBlock(LiquidArmMId id, int index) throws HardwareException { + liquidDistributionArmMoveTo(id,index); + canBus.waitForMod(id.mid,3000); + } + public int liquidDistributionReadPos(LiquidArmMId id) throws HardwareException { log.info("liquidDistributionReadPos called with id: {}", id); diff --git a/src/main/resources/init/zapp_sub_module_reg_initial_value.csv b/src/main/resources/init/zapp_sub_module_reg_initial_value.csv index 1f8b165..885be14 100644 --- a/src/main/resources/init/zapp_sub_module_reg_initial_value.csv +++ b/src/main/resources/init/zapp_sub_module_reg_initial_value.csv @@ -144,14 +144,14 @@ id,mid,regIndex,regInitVal 144,CapStorageM,kreg_step_motor_shaft,1 145,CapStorageM,kreg_step_motor_one_circle_pulse,500 146,CapStorageM,kreg_step_motor_one_circle_pulse_denominator,1 -147,CapStorageM,kreg_step_motor_default_velocity,200 +147,CapStorageM,kreg_step_motor_default_velocity,250 148,CapStorageM,kreg_step_motor_low_velocity,0 149,CapStorageM,kreg_step_motor_mid_velocity,0 150,CapStorageM,kreg_step_motor_high_velocity,0 151,CapStorageM,kreg_step_motor_ihold,5 152,CapStorageM,kreg_step_motor_irun,31 153,CapStorageM,kreg_step_motor_iholddelay,10 -154,CapStorageM,kreg_step_motor_iglobalscaler,128 +154,CapStorageM,kreg_step_motor_iglobalscaler,80 155,CapStorageM,kreg_step_motor_mres,0 156,CapStorageM,kreg_step_motor_run_to_zero_speed,100 157,CapStorageM,kreg_step_motor_look_zero_edge_speed,100