Browse Source

fix:移动都改为相对移动

master
白凤吉 3 months ago
parent
commit
46a345d516
  1. 2
      src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommandHandler.java
  2. 2
      src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommandHandler.java
  3. 2
      src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommandHandler.java
  4. 12
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java
  5. 12
      src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java
  6. 98
      src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java

2
src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftDownCommandHandler.java

@ -27,7 +27,7 @@ public class CoverElevatorLiftDownCommandHandler extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> { return runAsync(() -> {
Double velocity = cmdDTO.getDoubleParam("velocity"); Double velocity = cmdDTO.getDoubleParam("velocity");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMove(velocity);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(velocity);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture); commandWait(deviceCommandFuture);
}); });

2
src/main/java/com/iflytop/gd/app/cmd/debug/CoverElevatorLiftUpCommandHandler.java

@ -28,7 +28,7 @@ public class CoverElevatorLiftUpCommandHandler extends BaseCommandHandler {
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { public CompletableFuture<Void> handle(CmdDTO cmdDTO) {
return runAsync(() -> { return runAsync(() -> {
Double velocity = cmdDTO.getDoubleParam("velocity"); Double velocity = cmdDTO.getDoubleParam("velocity");
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMove(velocity);
DeviceCommandBundle deviceCommand = DeviceCommandGenerator.trayMotorMoveBy(velocity);
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);
commandWait(deviceCommandFuture); commandWait(deviceCommandFuture);
}); });

2
src/main/java/com/iflytop/gd/app/cmd/debug/LiquidArmRotateCommandHandler.java

@ -31,7 +31,7 @@ public class LiquidArmRotateCommandHandler extends BaseCommandHandler {
DeviceCommandBundle deviceCommandJoint1 = DeviceCommandGenerator.dualRobotJoint1Move(largeArmAngle); DeviceCommandBundle deviceCommandJoint1 = DeviceCommandGenerator.dualRobotJoint1Move(largeArmAngle);
CommandFuture deviceCommandJoint1Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint1); CommandFuture deviceCommandJoint1Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint1);
commandWait(deviceCommandJoint1Future); commandWait(deviceCommandJoint1Future);
DeviceCommandBundle deviceCommandJoint2 = DeviceCommandGenerator.dualRobotJoint1Move(smallArmAngle);
DeviceCommandBundle deviceCommandJoint2 = DeviceCommandGenerator.dualRobotJoint2Move(smallArmAngle);
CommandFuture deviceCommandJoint2Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint2); CommandFuture deviceCommandJoint2Future = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommandJoint2);
commandWait(deviceCommandJoint1Future, deviceCommandJoint2Future); commandWait(deviceCommandJoint1Future, deviceCommandJoint2Future);
}); });

12
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftDownCommandHandler.java

@ -31,12 +31,12 @@ public class PalletElevatorLiftDownCommandHandler extends BaseCommandHandler {
Double distance = cmdDTO.getDoubleParam("distance"); Double distance = cmdDTO.getDoubleParam("distance");
DeviceCommandBundle deviceCommand; DeviceCommandBundle deviceCommand;
switch (index) { switch (index) {
case 1 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Move(distance);
case 2 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Move(distance);
case 3 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Move(distance);
case 4 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Move(distance);
case 5 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Move(distance);
case 6 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Move(distance);
case 1 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance);
case 2 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance);
case 3 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance);
case 4 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance);
case 5 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance);
case 6 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance);
default -> throw new RuntimeException("index 未找到"); default -> throw new RuntimeException("index 未找到");
} }
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);

12
src/main/java/com/iflytop/gd/app/cmd/debug/PalletElevatorLiftUpCommandHandler.java

@ -30,12 +30,12 @@ public class PalletElevatorLiftUpCommandHandler extends BaseCommandHandler {
Double distance = cmdDTO.getDoubleParam("distance"); Double distance = cmdDTO.getDoubleParam("distance");
DeviceCommandBundle deviceCommand; DeviceCommandBundle deviceCommand;
switch (index) { switch (index) {
case 1 -> deviceCommand = DeviceCommandGenerator.heaterMotor1Move(distance);
case 2 -> deviceCommand = DeviceCommandGenerator.heaterMotor2Move(distance);
case 3 -> deviceCommand = DeviceCommandGenerator.heaterMotor3Move(distance);
case 4 -> deviceCommand = DeviceCommandGenerator.heaterMotor4Move(distance);
case 5 -> deviceCommand = DeviceCommandGenerator.heaterMotor5Move(distance);
case 6 -> deviceCommand = DeviceCommandGenerator.heaterMotor6Move(distance);
case 1 -> deviceCommand = DeviceCommandGenerator.heaterMotor1MoveBy(distance);
case 2 -> deviceCommand = DeviceCommandGenerator.heaterMotor2MoveBy(distance);
case 3 -> deviceCommand = DeviceCommandGenerator.heaterMotor3MoveBy(distance);
case 4 -> deviceCommand = DeviceCommandGenerator.heaterMotor4MoveBy(distance);
case 5 -> deviceCommand = DeviceCommandGenerator.heaterMotor5MoveBy(distance);
case 6 -> deviceCommand = DeviceCommandGenerator.heaterMotor6MoveBy(distance);
default -> throw new RuntimeException("index 未找到"); default -> throw new RuntimeException("index 未找到");
} }
CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand);

98
src/main/java/com/iflytop/gd/common/cmd/DeviceCommandGenerator.java

@ -20,6 +20,17 @@ public class DeviceCommandGenerator {
} }
/** /**
* 相对移动
*
* @param position 位置 单位mm
*/
public static DeviceCommandBundle doorMoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.door_motor, CmdAction.move_by, params, "门 相对移动");
}
/**
* 停止动作 * 停止动作
*/ */
public static DeviceCommandBundle doorStop() { public static DeviceCommandBundle doorStop() {
@ -36,12 +47,10 @@ public class DeviceCommandGenerator {
/** /**
* 设置参数 * 设置参数
* *
* @param current 电流 [0-31]
* @param speed 速度 单位 mm/s * @param speed 速度 单位 mm/s
*/ */
public static DeviceCommandBundle doorSet(Integer current, Double speed) {
public static DeviceCommandBundle doorSet(Double speed) {
DeviceCommandParams params = new DeviceCommandParams(); DeviceCommandParams params = new DeviceCommandParams();
params.setCurrent(current);
params.setSpeed(speed); params.setSpeed(speed);
return setInfoCmd(CmdDevice.door_motor, CmdAction.set, null, "门 设置参数"); return setInfoCmd(CmdDevice.door_motor, CmdAction.set, null, "门 设置参数");
} }
@ -85,6 +94,17 @@ public class DeviceCommandGenerator {
} }
/** /**
* 拍子升降电机 相对移动
*
* @param position 位置 单位mm
*/
public static DeviceCommandBundle trayMotorMoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.tray_motor, CmdAction.move_by, params, "拍子升降电机 相对移动");
}
/**
* 拍子升降电机 停止移动 * 拍子升降电机 停止移动
*/ */
public static DeviceCommandBundle trayMotorStop() { public static DeviceCommandBundle trayMotorStop() {
@ -313,7 +333,7 @@ public class DeviceCommandGenerator {
public static DeviceCommandBundle gantryXMoveBy(Double position) { public static DeviceCommandBundle gantryXMoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams(); DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position); params.setPosition(position);
return controlMotorCmd(CmdDevice.gantry_x, CmdAction.move_by, params, "龙门架 x轴移动");
return controlMotorCmd(CmdDevice.gantry_x, CmdAction.move_by, params, "龙门架 x轴相对移动");
} }
/** /**
@ -324,7 +344,7 @@ public class DeviceCommandGenerator {
public static DeviceCommandBundle gantryYMoveBy(Double position) { public static DeviceCommandBundle gantryYMoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams(); DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position); params.setPosition(position);
return controlMotorCmd(CmdDevice.gantry_y, CmdAction.move_by, params, "龙门架 y轴移动");
return controlMotorCmd(CmdDevice.gantry_y, CmdAction.move_by, params, "龙门架 y轴相对移动");
} }
/** /**
@ -335,7 +355,7 @@ public class DeviceCommandGenerator {
public static DeviceCommandBundle gantryZMoveBy(Double position) { public static DeviceCommandBundle gantryZMoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams(); DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position); params.setPosition(position);
return controlMotorCmd(CmdDevice.gantry_z, CmdAction.move_by, params, "龙门架 z轴移动");
return controlMotorCmd(CmdDevice.gantry_z, CmdAction.move_by, params, "龙门架 z轴相对移动");
} }
/** /**
@ -546,6 +566,72 @@ public class DeviceCommandGenerator {
return controlMotorCmd(CmdDevice.heater_motor_6, CmdAction.move, params, "加热区顶升电机 加热位6移动"); return controlMotorCmd(CmdDevice.heater_motor_6, CmdAction.move, params, "加热区顶升电机 加热位6移动");
} }
/**
* 加热区顶升电机 加热位1相对移动
*
* @param position 位置 单位 mm
*/
public static DeviceCommandBundle heaterMotor1MoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.heater_motor_1, CmdAction.move_by, params, "加热区顶升电机 加热位1相对移动");
}
/**
* 加热区顶升电机 加热位2相对移动
*
* @param position 位置 单位 mm
*/
public static DeviceCommandBundle heaterMotor2MoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.heater_motor_2, CmdAction.move_by, params, "加热区顶升电机 加热位2相对移动");
}
/**
* 加热区顶升电机 加热位3相对移动
*
* @param position 位置 单位 mm
*/
public static DeviceCommandBundle heaterMotor3MoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.heater_motor_3, CmdAction.move_by, params, "加热区顶升电机 加热位3相对移动");
}
/**
* 加热区顶升电机 加热位4相对移动
*
* @param position 位置 单位 mm
*/
public static DeviceCommandBundle heaterMotor4MoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.heater_motor_4, CmdAction.move_by, params, "加热区顶升电机 加热位4相对移动");
}
/**
* 加热区顶升电机 加热位5相对移动
*
* @param position 位置 单位 mm
*/
public static DeviceCommandBundle heaterMotor5MoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.heater_motor_5, CmdAction.move_by, params, "加热区顶升电机 加热位5相对移动");
}
/**
* 加热区顶升电机 加热位6相对移动
*
* @param position 位置 单位 mm
*/
public static DeviceCommandBundle heaterMotor6MoveBy(Double position) {
DeviceCommandParams params = new DeviceCommandParams();
params.setPosition(position);
return controlMotorCmd(CmdDevice.heater_motor_6, CmdAction.move_by, params, "加热区顶升电机 加热位6相对移动");
}
/** /**
* 加热区顶升电机 加热位1停止 * 加热区顶升电机 加热位1停止

Loading…
Cancel
Save