Browse Source

feat:加液机械臂调试指令

master
白凤吉 3 months ago
parent
commit
01db54812f
  1. 34
      src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMoveJoint.java
  2. 32
      src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotMovePoint.java
  3. 45
      src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotOrigin.java
  4. 45
      src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotSet.java
  5. 45
      src/main/java/com/iflytop/gd/app/cmd/debug/DebugSualRobotStop.java
  6. 16
      src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java

34
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);
}
}

32
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);
}
}

45
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<CommandFuture> 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]));
}
}

45
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<CommandFuture> 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]));
}
}

45
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<CommandFuture> 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]));
}
}

16
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, "双轴械臂 移动至指定点");

Loading…
Cancel
Save