From 01db54812f19e92e8abbdb243a35a551428bf5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Mon, 5 May 2025 11:42:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=8A=A0=E6=B6=B2=E6=9C=BA=E6=A2=B0?= =?UTF-8?q?=E8=87=82=E8=B0=83=E8=AF=95=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gd/app/cmd/debug/DebugSualRobotMoveJoint.java | 34 ++++++++++++++++ .../gd/app/cmd/debug/DebugSualRobotMovePoint.java | 32 +++++++++++++++ .../gd/app/cmd/debug/DebugSualRobotOrigin.java | 45 ++++++++++++++++++++++ .../gd/app/cmd/debug/DebugSualRobotSet.java | 45 ++++++++++++++++++++++ .../gd/app/cmd/debug/DebugSualRobotStop.java | 45 ++++++++++++++++++++++ .../gd/common/cmd/DeviceCommandGenerator.java | 16 +++----- 6 files changed, 206 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java create mode 100644 src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java new file mode 100644 index 0000000..b31ca06 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java @@ -0,0 +1,34 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 加液机械臂 轴移动到指定角度 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_sual_robot_move_joint") +public class DebugSualRobotMoveJoint extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double joint1 = cmdDTO.getDoubleParam("joint1"); + Double joint2 = cmdDTO.getDoubleParam("joint2"); + DeviceCommand deviceCommandJoint1 = DeviceCommandGenerator.dualRobotJoint1Move(joint1); + CommandFuture deviceCommandJoint1Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint1); + DeviceCommand deviceCommandJoint2 = DeviceCommandGenerator.dualRobotJoint1Move(joint2); + CommandFuture deviceCommandJoint2Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint2); + commandWait(deviceCommandJoint1Future, deviceCommandJoint2Future); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java new file mode 100644 index 0000000..322e037 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java @@ -0,0 +1,32 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 加液机械臂 移动到指定坐标 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_sual_robot_move_point") +public class DebugSualRobotMovePoint extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double x = cmdDTO.getDoubleParam("x"); + Double y = cmdDTO.getDoubleParam("y"); + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotMovePoint(x, y); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + commandWait(deviceCommandFuture); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java new file mode 100644 index 0000000..3d37662 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java @@ -0,0 +1,45 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +/** + * 加液机械臂 回原点 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_sual_robot_origin") +public class DebugSualRobotOrigin extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Boolean joint1 = cmdDTO.getBooleanParam("joint1"); + Boolean joint2 = cmdDTO.getBooleanParam("joint2"); + List futuresList = new ArrayList<>(); + if (joint1) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Origin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (joint2) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint2Origin(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java new file mode 100644 index 0000000..6096cd5 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java @@ -0,0 +1,45 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +/** + * 加液机械臂 设置参数 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_sual_robot_set") +public class DebugSualRobotSet extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Double joint1Speed = cmdDTO.getDoubleParam("joint1Speed"); + Double joint2Speed = cmdDTO.getDoubleParam("joint2Speed"); + List futuresList = new ArrayList<>(); + if (joint1Speed != null) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Set(joint1Speed); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (joint2Speed != null) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint2Set(joint2Speed); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + } +} diff --git a/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java new file mode 100644 index 0000000..fa64207 --- /dev/null +++ b/src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java @@ -0,0 +1,45 @@ +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.DeviceCommand; +import com.iflytop.gd.common.cmd.DeviceCommandGenerator; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +/** + * 加液机械臂 停止移动 + */ +@Slf4j +@Component +@RequiredArgsConstructor +@CommandMapping("debug_sual_robot_stop") +public class DebugSualRobotStop extends BaseCommandHandler { + private final DeviceCommandService deviceCommandService; + + @Override + public void handle(CmdDTO cmdDTO) throws Exception { + Boolean joint1 = cmdDTO.getBooleanParam("joint1"); + Boolean joint2 = cmdDTO.getBooleanParam("joint2"); + List futuresList = new ArrayList<>(); + if (joint1) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint1Stop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + if (joint2) { + DeviceCommand deviceCommand = DeviceCommandGenerator.dualRobotJoint2Stop(); + CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); + futuresList.add(deviceCommandFuture); + } + + commandWait(futuresList.toArray(new CommandFuture[0])); + } +} diff --git a/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java b/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java index b19742a..607964d 100644 --- a/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java +++ b/src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java @@ -116,13 +116,11 @@ public class DeviceCommandGenerator { * 双轴械臂 移动关节1 * * @param position 位置 单位° - * @param speed 速度 单位 °/s */ - public static DeviceCommand dualRobotJoint1Move(Double position, Double speed) { + public static DeviceCommand dualRobotJoint1Move(Double position) { DeviceCommandParams params = new DeviceCommandParams(); params.setAxis(CmdAxis.joint1); params.setPosition(position); - params.setSpeed(speed); return controlCmd(CmdDevice.dual_robot, CmdAction.move_joint, params, "双轴械臂 移动关节1"); } @@ -130,26 +128,22 @@ public class DeviceCommandGenerator { * 双轴械臂 移动关节2 * * @param position 位置 单位° - * @param speed 速度 单位 °/s */ - public static DeviceCommand dualRobotJoint2Move(Double position, Double speed) { + public static DeviceCommand dualRobotJoint2Move(Double position) { DeviceCommandParams params = new DeviceCommandParams(); params.setAxis(CmdAxis.joint2); params.setPosition(position); - params.setSpeed(speed); return controlCmd(CmdDevice.dual_robot, CmdAction.move_joint, params, "双轴械臂 移动关节2"); } /** * 双轴械臂 移动至指定点 * - * @param speed 速度 单位 °/s - * @param x 位置x - * @param y 位置y + * @param x 位置x + * @param y 位置y */ - public static DeviceCommand dualRobotMovePoint(Double speed, Double x, Double y) { + public static DeviceCommand dualRobotMovePoint(Double x, Double y) { DeviceCommandParams params = new DeviceCommandParams(); - params.setSpeed(speed); params.setX(x); params.setY(y); return controlCmd(CmdDevice.dual_robot, CmdAction.move_point, params, "双轴械臂 移动至指定点");