From 152cae03231196de019a0d9b9fb61053c7d35575 Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Tue, 21 Jul 2026 10:19:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(arm):=20=E6=B7=BB=E5=8A=A0=E6=9C=BA?= =?UTF-8?q?=E6=A2=B0=E8=87=82=E6=95=85=E9=9A=9C=E6=B8=85=E9=99=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ArmService 中新增 clearFault RPC 方法 - 生成对应的 gRPC 客户端和服务端方法实现 - 在 EdgeArmController 中添加 /clearFault 接口 - 实现 EdgeArmService 的 clearFault 业务逻辑 - 更新方法 ID 映射和协议缓冲区描述符 - 添加同步和异步调用支持 --- .../web/controller/api/EdgeArmController.java | 10 ++ .../edge/client/service/EdgeArmService.java | 8 ++ .../service/impl/EdgeArmServiceImpl.java | 8 ++ .../main/java/cmvr/api/ArmServiceGrpc.java | 96 ++++++++++++++++--- .../java/cmvr/api/ArmServiceOuterClass.java | 48 +++++----- .../src/main/proto/cmvr/api/arm_service.proto | 1 + 6 files changed, 137 insertions(+), 34 deletions(-) diff --git a/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java b/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java index 3fb468e..8bb1c97 100644 --- a/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java +++ b/cmvr-iot-admin/src/main/java/com/cmvr/web/controller/api/EdgeArmController.java @@ -43,6 +43,16 @@ public class EdgeArmController { return AjaxResult.ok(); } + /** + * 清除机械臂故障状态。 + */ + @ApiOperation("清除故障") + @GetMapping("/clearFault") + public AjaxResult clearFault(EdgeCommonVO vo) { + edgeArmService.clearFault(vo); + return AjaxResult.ok(); + } + @ApiOperation("关节空间运动") @PostMapping("/moveJ") public AjaxResult moveJ(@RequestBody EdgeArmMoveJVO moveJVO) { diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeArmService.java b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeArmService.java index 68409ff..0ff6581 100644 --- a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeArmService.java +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/EdgeArmService.java @@ -30,6 +30,14 @@ public interface EdgeArmService { */ Common.CommandHeader.Feedback torqueOn(EdgeCommonVO edgeCommonVO); + /** + * 清除机械臂故障状态。 + * + * @param edgeCommonVO 边缘设备通用参数,包含 terminalId 和 deviceId + * @return 机器人终端返回的通用反馈 + */ + Common.CommandHeader.Feedback clearFault(EdgeCommonVO edgeCommonVO); + /** * 关节空间运动(命令码:moveJ) * 控制机械臂通过关节空间插值运动到目标关节位置 diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeArmServiceImpl.java b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeArmServiceImpl.java index 417ff23..b030600 100644 --- a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeArmServiceImpl.java +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-client/src/main/java/com/cmvr/edge/client/service/impl/EdgeArmServiceImpl.java @@ -44,6 +44,14 @@ public class EdgeArmServiceImpl implements EdgeArmService { return executeGrpcCall(() -> stub.torqueOn(request)); } + @Override + public Common.CommandHeader.Feedback clearFault(EdgeCommonVO edgeCommonVO) { + ArmServiceGrpc.ArmServiceBlockingStub stub = grpcServiceManager.getGrpcClient( + edgeCommonVO.getTerminalId(), ArmServiceGrpc.ArmServiceBlockingStub.class); + Common.CommandHeader.Request request = EdgeCommonUtil.buildRequest(edgeCommonVO.getDeviceId()); + return executeGrpcCall(() -> stub.clearFault(request)); + } + @Override public ArmCommand.MoveJ.Response moveJ(EdgeCommonVO edgeCommonVO, double[] target, Double velocity, Double acceleration, Double blendRadius, diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceGrpc.java b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceGrpc.java index 17fc065..92cd053 100644 --- a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceGrpc.java +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceGrpc.java @@ -77,6 +77,37 @@ public final class ArmServiceGrpc { return getTorqueOnMethod; } + private static volatile io.grpc.MethodDescriptor getClearFaultMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "clearFault", + requestType = cmvr.api.Common.CommandHeader.Request.class, + responseType = cmvr.api.Common.CommandHeader.Feedback.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getClearFaultMethod() { + io.grpc.MethodDescriptor getClearFaultMethod; + if ((getClearFaultMethod = ArmServiceGrpc.getClearFaultMethod) == null) { + synchronized (ArmServiceGrpc.class) { + if ((getClearFaultMethod = ArmServiceGrpc.getClearFaultMethod) == null) { + ArmServiceGrpc.getClearFaultMethod = getClearFaultMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "clearFault")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cmvr.api.Common.CommandHeader.Request.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cmvr.api.Common.CommandHeader.Feedback.getDefaultInstance())) + .setSchemaDescriptor(new ArmServiceMethodDescriptorSupplier("clearFault")) + .build(); + } + } + } + return getClearFaultMethod; + } + private static volatile io.grpc.MethodDescriptor getMoveJMethod; @@ -480,6 +511,13 @@ public final class ArmServiceGrpc { io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getTorqueOnMethod(), responseObserver); } + /** + */ + public void clearFault(cmvr.api.Common.CommandHeader.Request request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getClearFaultMethod(), responseObserver); + } + /** */ public void moveJ(cmvr.api.ArmCommand.MoveJ.Request request, @@ -573,6 +611,13 @@ public final class ArmServiceGrpc { cmvr.api.Common.CommandHeader.Request, cmvr.api.Common.CommandHeader.Feedback>( this, METHODID_TORQUE_ON))) + .addMethod( + getClearFaultMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + cmvr.api.Common.CommandHeader.Request, + cmvr.api.Common.CommandHeader.Feedback>( + this, METHODID_CLEAR_FAULT))) .addMethod( getMoveJMethod(), io.grpc.stub.ServerCalls.asyncUnaryCall( @@ -684,6 +729,14 @@ public final class ArmServiceGrpc { getChannel().newCall(getTorqueOnMethod(), getCallOptions()), request, responseObserver); } + /** + */ + public void clearFault(cmvr.api.Common.CommandHeader.Request request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getClearFaultMethod(), getCallOptions()), request, responseObserver); + } + /** */ public void moveJ(cmvr.api.ArmCommand.MoveJ.Request request, @@ -801,6 +854,13 @@ public final class ArmServiceGrpc { getChannel(), getTorqueOnMethod(), getCallOptions(), request); } + /** + */ + public cmvr.api.Common.CommandHeader.Feedback clearFault(cmvr.api.Common.CommandHeader.Request request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getClearFaultMethod(), getCallOptions(), request); + } + /** */ public cmvr.api.ArmCommand.MoveJ.Response moveJ(cmvr.api.ArmCommand.MoveJ.Request request) { @@ -909,6 +969,14 @@ public final class ArmServiceGrpc { getChannel().newCall(getTorqueOnMethod(), getCallOptions()), request); } + /** + */ + public com.google.common.util.concurrent.ListenableFuture clearFault( + cmvr.api.Common.CommandHeader.Request request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getClearFaultMethod(), getCallOptions()), request); + } + /** */ public com.google.common.util.concurrent.ListenableFuture moveJ( @@ -1000,17 +1068,18 @@ public final class ArmServiceGrpc { private static final int METHODID_TORQUE_OFF = 0; private static final int METHODID_TORQUE_ON = 1; - private static final int METHODID_MOVE_J = 2; - private static final int METHODID_MOVE_L = 3; - private static final int METHODID_SPEED_J = 4; - private static final int METHODID_SPEED_L = 5; - private static final int METHODID_SERVO_J = 6; - private static final int METHODID_STOP_MOTION = 7; - private static final int METHODID_GET_JOINT_STATE = 8; - private static final int METHODID_GET_POSE = 9; - private static final int METHODID_CALIBRATE_ZERO_Q = 10; - private static final int METHODID_GET_POSE_MATRIX = 11; - private static final int METHODID_COMPUTE_FORWARD_KINEMATICS = 12; + private static final int METHODID_CLEAR_FAULT = 2; + private static final int METHODID_MOVE_J = 3; + private static final int METHODID_MOVE_L = 4; + private static final int METHODID_SPEED_J = 5; + private static final int METHODID_SPEED_L = 6; + private static final int METHODID_SERVO_J = 7; + private static final int METHODID_STOP_MOTION = 8; + private static final int METHODID_GET_JOINT_STATE = 9; + private static final int METHODID_GET_POSE = 10; + private static final int METHODID_CALIBRATE_ZERO_Q = 11; + private static final int METHODID_GET_POSE_MATRIX = 12; + private static final int METHODID_COMPUTE_FORWARD_KINEMATICS = 13; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -1037,6 +1106,10 @@ public final class ArmServiceGrpc { serviceImpl.torqueOn((cmvr.api.Common.CommandHeader.Request) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_CLEAR_FAULT: + serviceImpl.clearFault((cmvr.api.Common.CommandHeader.Request) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; case METHODID_MOVE_J: serviceImpl.moveJ((cmvr.api.ArmCommand.MoveJ.Request) request, (io.grpc.stub.StreamObserver) responseObserver); @@ -1144,6 +1217,7 @@ public final class ArmServiceGrpc { .setSchemaDescriptor(new ArmServiceFileDescriptorSupplier()) .addMethod(getTorqueOffMethod()) .addMethod(getTorqueOnMethod()) + .addMethod(getClearFaultMethod()) .addMethod(getMoveJMethod()) .addMethod(getMoveLMethod()) .addMethod(getSpeedJMethod()) diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceOuterClass.java b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceOuterClass.java index 9087b7a..ceb0b01 100644 --- a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceOuterClass.java +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/java/cmvr/api/ArmServiceOuterClass.java @@ -25,32 +25,34 @@ public final class ArmServiceOuterClass { java.lang.String[] descriptorData = { "\n\032cmvr/api/arm_service.proto\022\010cmvr.api\032\025" + "cmvr/api/common.proto\032\032cmvr/api/arm_comm" + - "and.proto2\325\007\n\nArmService\022N\n\ttorqueOff\022\037." + + "and.proto2\246\010\n\nArmService\022N\n\ttorqueOff\022\037." + "cmvr.api.CommandHeader.Request\032 .cmvr.ap" + "i.CommandHeader.Feedback\022M\n\010torqueOn\022\037.c" + "mvr.api.CommandHeader.Request\032 .cmvr.api" + - ".CommandHeader.Feedback\022:\n\005moveJ\022\027.cmvr." + - "api.MoveJ.Request\032\030.cmvr.api.MoveJ.Respo" + - "nse\022:\n\005moveL\022\027.cmvr.api.MoveL.Request\032\030." + - "cmvr.api.MoveL.Response\022=\n\006speedJ\022\030.cmvr" + - ".api.SpeedJ.Request\032\031.cmvr.api.SpeedJ.Re" + - "sponse\022=\n\006speedL\022\030.cmvr.api.SpeedL.Reque" + - "st\032\031.cmvr.api.SpeedL.Response\022=\n\006servoJ\022" + - "\030.cmvr.api.ServoJ.Request\032\031.cmvr.api.Ser" + - "voJ.Response\022O\n\nstopMotion\022\037.cmvr.api.Co" + - "mmandHeader.Request\032 .cmvr.api.CommandHe" + - "ader.Feedback\022@\n\rgetJointState\022\026.cmvr.ap" + - "i.JointRequest\032\027.cmvr.api.JointResponse\022" + - "@\n\007getPose\022\031.cmvr.api.GetPose.Request\032\032." + - "cmvr.api.GetPose.Response\022U\n\016calibrateZe" + - "roQ\022 .cmvr.api.CalibrateZeroQ.Request\032!." + - "cmvr.api.CalibrateZeroQ.Response\022R\n\rgetP" + - "oseMatrix\022\037.cmvr.api.GetPoseMatrix.Reque" + - "st\032 .cmvr.api.GetPoseMatrix.Response\022s\n\030" + - "computeForwardKinematics\022*.cmvr.api.Comp" + - "uteForwardKinematics.Request\032+.cmvr.api." + - "ComputeForwardKinematics.Responseb\006proto" + - "3" + ".CommandHeader.Feedback\022O\n\nclearFault\022\037." + + "cmvr.api.CommandHeader.Request\032 .cmvr.ap" + + "i.CommandHeader.Feedback\022:\n\005moveJ\022\027.cmvr" + + ".api.MoveJ.Request\032\030.cmvr.api.MoveJ.Resp" + + "onse\022:\n\005moveL\022\027.cmvr.api.MoveL.Request\032\030" + + ".cmvr.api.MoveL.Response\022=\n\006speedJ\022\030.cmv" + + "r.api.SpeedJ.Request\032\031.cmvr.api.SpeedJ.R" + + "esponse\022=\n\006speedL\022\030.cmvr.api.SpeedL.Requ" + + "est\032\031.cmvr.api.SpeedL.Response\022=\n\006servoJ" + + "\022\030.cmvr.api.ServoJ.Request\032\031.cmvr.api.Se" + + "rvoJ.Response\022O\n\nstopMotion\022\037.cmvr.api.C" + + "ommandHeader.Request\032 .cmvr.api.CommandH" + + "eader.Feedback\022@\n\rgetJointState\022\026.cmvr.a" + + "pi.JointRequest\032\027.cmvr.api.JointResponse" + + "\022@\n\007getPose\022\031.cmvr.api.GetPose.Request\032\032" + + ".cmvr.api.GetPose.Response\022U\n\016calibrateZ" + + "eroQ\022 .cmvr.api.CalibrateZeroQ.Request\032!" + + ".cmvr.api.CalibrateZeroQ.Response\022R\n\rget" + + "PoseMatrix\022\037.cmvr.api.GetPoseMatrix.Requ" + + "est\032 .cmvr.api.GetPoseMatrix.Response\022s\n" + + "\030computeForwardKinematics\022*.cmvr.api.Com" + + "puteForwardKinematics.Request\032+.cmvr.api" + + ".ComputeForwardKinematics.Responseb\006prot" + + "o3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, diff --git a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/proto/cmvr/api/arm_service.proto b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/proto/cmvr/api/arm_service.proto index 565b493..92562f4 100644 --- a/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/proto/cmvr/api/arm_service.proto +++ b/cmvr-iot-api/cmvr-iot-edge/cmvr-iot-grpc-lib/src/main/proto/cmvr/api/arm_service.proto @@ -8,6 +8,7 @@ import "cmvr/api/arm_command.proto"; service ArmService { rpc torqueOff(CommandHeader.Request) returns (CommandHeader.Feedback); rpc torqueOn(CommandHeader.Request) returns (CommandHeader.Feedback); + rpc clearFault(CommandHeader.Request) returns (CommandHeader.Feedback); rpc moveJ(MoveJ.Request) returns (MoveJ.Response); rpc moveL(MoveL.Request) returns (MoveL.Response); rpc speedJ(SpeedJ.Request) returns (SpeedJ.Response);