feat: 机械臂
This commit is contained in:
parent
3b036d983e
commit
faf85b3634
@ -2,7 +2,7 @@ package com.cmvr.web.controller.api;
|
||||
|
||||
import com.cmvr.common.core.controller.BaseController;
|
||||
import com.cmvr.common.core.domain.AjaxResult;
|
||||
import com.cmvr.edge.client.model.biohead.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.biohead.EdgeFacialExpressionVO;
|
||||
import com.cmvr.edge.client.service.EdgeBioHeadService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -24,39 +24,6 @@ public class EdgeBioHeadController extends BaseController {
|
||||
@ApiOperation("设置面部表情")
|
||||
@PostMapping("/expression")
|
||||
public AjaxResult expression(@RequestBody EdgeFacialExpressionVO facialExpressionVo) {
|
||||
/*// 构建面部表情参数
|
||||
EdgeFacialExpressionVo expression = EdgeFacialExpressionVo.builder()
|
||||
.eyebrow(EdgeFacialExpressionVo.Eyebrow.builder()
|
||||
.leftOutsideY(1f)
|
||||
.leftInsideY(0.4f)
|
||||
.rightOutsideY(0.2f)
|
||||
.rightInsideY(0.2f)
|
||||
.build())
|
||||
.eyelid(EdgeFacialExpressionVo.Eyelid.builder()
|
||||
.leftUpperY(0.4f)
|
||||
.leftLowerY(0.4f)
|
||||
.rightUpperY(0.4f)
|
||||
.rightLowerY(0.5f)
|
||||
.build())
|
||||
.eyeball(EdgeFacialExpressionVo.Eyeball.builder()
|
||||
.leftX(0.2f)
|
||||
.leftY(0.3f)
|
||||
.rightX(0.4f)
|
||||
.rightY(0.5f)
|
||||
.build())
|
||||
.mouth(EdgeFacialExpressionVo.Mouth.builder()
|
||||
.upperLipY(0.3f)
|
||||
.lowerLipY(-0.3f)
|
||||
.build())
|
||||
.nose(EdgeFacialExpressionVo.Nose.builder()
|
||||
.leftY(0f)
|
||||
.rightY(0f)
|
||||
.build())
|
||||
.jaw(EdgeFacialExpressionVo.Jaw.builder()
|
||||
.x(0f)
|
||||
.y(0f)
|
||||
.build())
|
||||
.build();*/
|
||||
return success(edgeBioHeadService.setExpression(facialExpressionVo));
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.cmvr.web.controller.api;
|
||||
|
||||
import com.cmvr.common.core.domain.AjaxResult;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO;
|
||||
import com.cmvr.edge.client.service.EdgeHumanoidRobotService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "机械臂")
|
||||
@RestController
|
||||
@RequestMapping("/api/humanoid")
|
||||
@RequiredArgsConstructor
|
||||
public class EdgeHumanoidRobotController {
|
||||
|
||||
private final EdgeHumanoidRobotService edgeHumanoidRobotService;
|
||||
|
||||
@ApiOperation("设置面部表情")
|
||||
@PostMapping("/moveJ")
|
||||
public AjaxResult expression(@RequestBody EdgeMoveJVO moveJVO) {
|
||||
return AjaxResult.ok(edgeHumanoidRobotService.moveJ(moveJVO));
|
||||
}
|
||||
}
|
||||
@ -54,6 +54,8 @@ public class GrpcServiceManager {
|
||||
// 注册机器人灵巧手服务的 Stub
|
||||
clientFactories.put(DexHandServiceGrpc.DexHandServiceBlockingStub.class, new GrpcClientFactory<>(DexHandServiceGrpc::newBlockingStub));
|
||||
clientFactories.put(DexHandServiceGrpc.DexHandServiceStub.class, new GrpcClientFactory<>(DexHandServiceGrpc::newStub));
|
||||
// 注册机械臂服务的stub
|
||||
clientFactories.put(HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub.class, new GrpcClientFactory<>(HumanoidRobotServiceGrpc::newBlockingStub));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.cmvr.edge.client.model.biohead;
|
||||
package com.cmvr.edge.client.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.cmvr.edge.client.model.biohead;
|
||||
|
||||
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package com.cmvr.edge.client.model.humanoid;
|
||||
|
||||
import cmvr.api.HumanoidRobot;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EdgeMoveJVO extends EdgeCommonVO {
|
||||
/** 全局关节角速度 (rad/s) */
|
||||
private double vel;
|
||||
|
||||
/** 机械臂整体加速度 (rad/s^2) */
|
||||
private double acc;
|
||||
|
||||
/** 关节命令列表 */
|
||||
private List<JointCmd> cmds;
|
||||
|
||||
/**
|
||||
* 内部类:关节命令
|
||||
*/
|
||||
@Data
|
||||
public static class JointCmd {
|
||||
private String jointName; // 关节名称
|
||||
private double rad; // 弧度
|
||||
private double vel; // 角速度,rad/s
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package com.cmvr.edge.client.service;
|
||||
|
||||
import com.cmvr.edge.client.model.biohead.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.biohead.EdgeFacialExpressionVO;
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cmvr.edge.client.service;
|
||||
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO;
|
||||
|
||||
/**
|
||||
* 边缘系统机械臂服务
|
||||
*/
|
||||
public interface EdgeHumanoidRobotService {
|
||||
/**
|
||||
* 移动机械臂
|
||||
*/
|
||||
public String moveJ(EdgeMoveJVO vo);
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ import cmvr.api.BioheadCommand;
|
||||
import cmvr.api.Common;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.cmvr.edge.client.manage.GrpcServiceManager;
|
||||
import com.cmvr.edge.client.model.biohead.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.biohead.EdgeFacialExpressionVO;
|
||||
import com.cmvr.edge.client.service.EdgeBioHeadService;
|
||||
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
||||
|
||||
@ -12,11 +12,11 @@ import com.cmvr.edge.client.file.ByteArrayMultipartFile;
|
||||
import com.cmvr.edge.client.manage.GrpcServiceManager;
|
||||
import com.cmvr.edge.client.service.EdgeCameraService;
|
||||
import com.cmvr.edge.client.service.EdgeStreamService;
|
||||
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
||||
import com.cmvr.edge.client.utils.H265DecoderUtil;
|
||||
import com.cmvr.framework.websocket.service.MessagePushService;
|
||||
import com.cmvr.system.service.ISysFileService;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Timestamp;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -59,7 +59,7 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
public CameraCommand.CameraState status(String terminalId, String deviceId) {
|
||||
CameraServiceGrpc.CameraServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, CameraServiceGrpc.CameraServiceBlockingStub.class);
|
||||
CameraCommand.GetCameraStateCommand.Request request = CameraCommand.GetCameraStateCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
return executeGrpcCall(() -> stub.getStatus(request)).getState();
|
||||
}
|
||||
@ -77,7 +77,7 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
public String start(String terminalId, String deviceId) {
|
||||
CameraServiceGrpc.CameraServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, CameraServiceGrpc.CameraServiceBlockingStub.class);
|
||||
CameraCommand.StartCameraCommand.Request request = CameraCommand.StartCameraCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
Common.CommandHeader.Feedback header = executeGrpcCall(() -> stub.startCamera(request)).getHeader();
|
||||
return JSON.toJSONString(header);
|
||||
@ -87,7 +87,7 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
public String stop(String terminalId, String deviceId) {
|
||||
CameraServiceGrpc.CameraServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, CameraServiceGrpc.CameraServiceBlockingStub.class);
|
||||
CameraCommand.StopCameraCommand.Request request = CameraCommand.StopCameraCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
Common.CommandHeader.Feedback header = executeGrpcCall(() -> stub.stopCamera(request)).getHeader();
|
||||
return JSON.toJSONString(header);
|
||||
@ -101,7 +101,7 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
}
|
||||
CameraServiceGrpc.CameraServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, CameraServiceGrpc.CameraServiceBlockingStub.class);
|
||||
CameraCommand.GetRGBImageCommand.Request request = CameraCommand.GetRGBImageCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
CameraCommand.GetRGBImageCommand.Feedback feedback = executeGrpcCall(() -> stub.getRGBImage(request));
|
||||
CameraCommand.FrameData frame = feedback.getColorFrame();
|
||||
@ -130,7 +130,7 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
String videoPath = StrUtil.format("{}/{}_{}.mp4", "/home/share/assets/video", deviceId, System.currentTimeMillis());
|
||||
|
||||
CameraCommand.StartCameraRecordingCommand.Request request = CameraCommand.StartCameraRecordingCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.setVideoPath(videoPath)
|
||||
.build();
|
||||
executeGrpcCall(() -> stub.startRecording(request));
|
||||
@ -141,7 +141,7 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
public String stopRecording(String terminalId, String deviceId) {
|
||||
CameraServiceGrpc.CameraServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, CameraServiceGrpc.CameraServiceBlockingStub.class);
|
||||
CameraCommand.StopCameraRecordingCommand.Request request = CameraCommand.StopCameraRecordingCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
Common.CommandHeader.Feedback header = executeGrpcCall(() -> stub.stopRecording(request)).getHeader();
|
||||
return JSON.toJSONString(header);
|
||||
@ -155,11 +155,11 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
|
||||
CameraServiceGrpc.CameraServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, CameraServiceGrpc.CameraServiceBlockingStub.class);
|
||||
CameraCommand.GetRGBDImagesCommand.Request request = CameraCommand.GetRGBDImagesCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
CameraCommand.GetRGBDImagesCommand.Feedback feedback = executeGrpcCall(() -> stub.getRGBDImages(request));
|
||||
|
||||
return JSON.toJSONString(feedback);
|
||||
return JSON.toJSONString(feedback);
|
||||
}
|
||||
|
||||
// 缓冲区和收集状态
|
||||
@ -222,7 +222,7 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
|
||||
// 构建请求并发送
|
||||
CameraCommand.GetRGBImageStreamCommand.Request request = CameraCommand.GetRGBImageStreamCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.setEof(false)
|
||||
.build();
|
||||
|
||||
@ -241,17 +241,6 @@ public class EdgeCameraServiceImpl implements EdgeCameraService, EdgeStreamServi
|
||||
|
||||
}
|
||||
|
||||
private static Common.CommandHeader.Request buildRequest(String deviceId) {
|
||||
return Common.CommandHeader.Request.newBuilder()
|
||||
.setDeviceId(deviceId)
|
||||
.setTimestamp(
|
||||
Timestamp.newBuilder()
|
||||
.setSeconds(System.currentTimeMillis() / 1000)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface GrpcCall<T> {
|
||||
T call() throws Exception;
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
package com.cmvr.edge.client.service.impl;
|
||||
|
||||
import cmvr.api.Common;
|
||||
import cmvr.api.HumanoidRobot;
|
||||
import cmvr.api.HumanoidRobotServiceGrpc;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.cmvr.edge.client.manage.GrpcServiceManager;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO;
|
||||
import com.cmvr.edge.client.service.EdgeHumanoidRobotService;
|
||||
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EdgeHumanoidRobotServiceImpl implements EdgeHumanoidRobotService {
|
||||
|
||||
private final GrpcServiceManager grpcServiceManager;
|
||||
|
||||
@Override
|
||||
public String moveJ(EdgeMoveJVO vo) {
|
||||
HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub stub =
|
||||
grpcServiceManager.getGrpcClient(vo.getTerminalId(),
|
||||
HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub.class);
|
||||
|
||||
Common.CommandHeader.Request header = EdgeCommonUtil.buildRequest(vo.getDeviceId());
|
||||
|
||||
HumanoidRobot.MoveJ.Request.Builder builder = HumanoidRobot.MoveJ.Request.newBuilder()
|
||||
.setHeader(header)
|
||||
.setVel(vo.getVel())
|
||||
.setAcc(vo.getAcc());
|
||||
|
||||
if (vo.getCmds() != null) {
|
||||
for (EdgeMoveJVO.JointCmd j : vo.getCmds()) {
|
||||
builder.addCmds(HumanoidRobot.JointCmd.newBuilder()
|
||||
.setJointName(j.getJointName())
|
||||
.setRad(j.getRad())
|
||||
.setVel(j.getVel())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
HumanoidRobot.MoveJ.Response response = stub.moveJ(builder.build());
|
||||
return JSON.toJSONString(response.getHeader());
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ import cmvr.api.MicrophoneCommand;
|
||||
import cmvr.api.MicPhoneServiceGrpc;
|
||||
import com.cmvr.edge.client.manage.GrpcServiceManager;
|
||||
import com.cmvr.edge.client.service.EdgeMicrophoneService;
|
||||
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
||||
import io.grpc.ManagedChannel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
@ -32,20 +33,6 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
*/
|
||||
private final GrpcServiceManager grpcServiceManager;
|
||||
|
||||
/**
|
||||
* 构建请求头
|
||||
*/
|
||||
private static Common.CommandHeader.Request buildRequest(String deviceId) {
|
||||
return Common.CommandHeader.Request.newBuilder()
|
||||
.setDeviceId(deviceId)
|
||||
.setTimestamp(
|
||||
Timestamp.newBuilder()
|
||||
.setSeconds(System.currentTimeMillis() / 1000)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取麦克风当前状态
|
||||
* 通过gRPC调用获取麦克风的运行状态,包括是否正在录音、音量等信息
|
||||
@ -60,7 +47,7 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
try {
|
||||
MicPhoneServiceGrpc.MicPhoneServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, MicPhoneServiceGrpc.MicPhoneServiceBlockingStub.class);
|
||||
MicrophoneCommand.GetMicStateCommand.Request request = MicrophoneCommand.GetMicStateCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
// 直接返回完整的 Feedback
|
||||
return stub.getStatus(request);
|
||||
@ -87,7 +74,7 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
|
||||
// 构建请求消息
|
||||
MicrophoneCommand.StartMicRecordingCommand.Request request = MicrophoneCommand.StartMicRecordingCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.setFilePath(filePath)
|
||||
.build();
|
||||
|
||||
@ -115,7 +102,7 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
|
||||
// 构建请求消息
|
||||
MicrophoneCommand.StopMicRecordingCommand.Request request = MicrophoneCommand.StopMicRecordingCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
@ -142,7 +129,7 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
|
||||
// 构建请求消息
|
||||
MicrophoneCommand.PauseMicRecordingCommand.Request request = MicrophoneCommand.PauseMicRecordingCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
@ -169,7 +156,7 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
|
||||
// 构建请求消息
|
||||
MicrophoneCommand.ResumeMicRecordingCommand.Request request = MicrophoneCommand.ResumeMicRecordingCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
@ -197,7 +184,7 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
|
||||
// 构建请求消息
|
||||
MicrophoneCommand.SetMicPhoneVolumeCommand.Request request = MicrophoneCommand.SetMicPhoneVolumeCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.setVolume(volume)
|
||||
.build();
|
||||
|
||||
@ -226,7 +213,7 @@ public class EdgeMicrophoneServiceImpl implements EdgeMicrophoneService {
|
||||
|
||||
// 构建请求消息
|
||||
MicrophoneCommand.GetMicPhoneVolumeCommand.Request request = MicrophoneCommand.GetMicPhoneVolumeCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求并获取响应
|
||||
|
||||
@ -9,6 +9,7 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cmvr.edge.client.manage.GrpcServiceManager;
|
||||
import com.cmvr.edge.client.service.EdgeSpeakerService;
|
||||
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
||||
import com.google.protobuf.Timestamp;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
@ -37,20 +38,6 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
*/
|
||||
private final GrpcServiceManager grpcServiceManager;
|
||||
|
||||
/**
|
||||
* 构建请求头
|
||||
*/
|
||||
private static Common.CommandHeader.Request buildRequest(String deviceId) {
|
||||
return Common.CommandHeader.Request.newBuilder()
|
||||
.setDeviceId(deviceId)
|
||||
.setTimestamp(
|
||||
Timestamp.newBuilder()
|
||||
.setSeconds(System.currentTimeMillis() / 1000)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扬声器当前状态
|
||||
* 通过gRPC调用获取扬声器的运行状态,包括是否正在播放、音量等信息
|
||||
@ -65,7 +52,7 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
try {
|
||||
SpeakerServiceGrpc.SpeakerServiceBlockingStub stub = grpcServiceManager.getGrpcClient(terminalId, SpeakerServiceGrpc.SpeakerServiceBlockingStub.class);
|
||||
SpeakerCommand.GetSpeakerStateCommand.Request request = SpeakerCommand.GetSpeakerStateCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
// 直接返回完整的 Feedback
|
||||
return stub.getStatus(request);
|
||||
@ -92,7 +79,7 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
|
||||
// 构建请求消息
|
||||
SpeakerCommand.PlayAudioCommand.Request request = SpeakerCommand.PlayAudioCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.setAudioPath(audioPath)
|
||||
.build();
|
||||
|
||||
@ -123,7 +110,7 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
|
||||
// 构建请求消息
|
||||
SpeakerCommand.StopSpeakerCommand.Request request = SpeakerCommand.StopSpeakerCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
@ -150,7 +137,7 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
|
||||
// 构建请求消息
|
||||
SpeakerCommand.PauseSpeakerCommand.Request request = SpeakerCommand.PauseSpeakerCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
@ -177,7 +164,7 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
|
||||
// 构建请求消息
|
||||
SpeakerCommand.ResumeSpeakerCommand.Request request = SpeakerCommand.ResumeSpeakerCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求
|
||||
@ -205,7 +192,7 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
|
||||
// 构建请求消息
|
||||
SpeakerCommand.SetSpeakerVolumeCommand.Request request = SpeakerCommand.SetSpeakerVolumeCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.setVolume(volume)
|
||||
.build();
|
||||
|
||||
@ -234,7 +221,7 @@ public class EdgeSpeakerServiceImpl implements EdgeSpeakerService {
|
||||
|
||||
// 构建请求消息
|
||||
SpeakerCommand.GetSpeakerVolumeCommand.Request request = SpeakerCommand.GetSpeakerVolumeCommand.Request.newBuilder()
|
||||
.setHeader(buildRequest(deviceId))
|
||||
.setHeader(EdgeCommonUtil.buildRequest(deviceId))
|
||||
.build();
|
||||
|
||||
// 发送请求并获取响应
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,424 @@
|
||||
package cmvr.api;
|
||||
|
||||
import static io.grpc.MethodDescriptor.generateFullMethodName;
|
||||
|
||||
/**
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.52.0)",
|
||||
comments = "Source: cmvr/api/humanoid_robot.proto")
|
||||
@io.grpc.stub.annotations.GrpcGenerated
|
||||
public final class HumanoidRobotServiceGrpc {
|
||||
|
||||
private HumanoidRobotServiceGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "cmvr.api.HumanoidRobotService";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
private static volatile io.grpc.MethodDescriptor<cmvr.api.Common.CommandHeader.Request,
|
||||
cmvr.api.Common.CommandHeader.Feedback> getTorqueOffMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "torqueOff",
|
||||
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<cmvr.api.Common.CommandHeader.Request,
|
||||
cmvr.api.Common.CommandHeader.Feedback> getTorqueOffMethod() {
|
||||
io.grpc.MethodDescriptor<cmvr.api.Common.CommandHeader.Request, cmvr.api.Common.CommandHeader.Feedback> getTorqueOffMethod;
|
||||
if ((getTorqueOffMethod = HumanoidRobotServiceGrpc.getTorqueOffMethod) == null) {
|
||||
synchronized (HumanoidRobotServiceGrpc.class) {
|
||||
if ((getTorqueOffMethod = HumanoidRobotServiceGrpc.getTorqueOffMethod) == null) {
|
||||
HumanoidRobotServiceGrpc.getTorqueOffMethod = getTorqueOffMethod =
|
||||
io.grpc.MethodDescriptor.<cmvr.api.Common.CommandHeader.Request, cmvr.api.Common.CommandHeader.Feedback>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "torqueOff"))
|
||||
.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 HumanoidRobotServiceMethodDescriptorSupplier("torqueOff"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getTorqueOffMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<cmvr.api.Common.CommandHeader.Request,
|
||||
cmvr.api.Common.CommandHeader.Feedback> getTorqueOnMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "torqueOn",
|
||||
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<cmvr.api.Common.CommandHeader.Request,
|
||||
cmvr.api.Common.CommandHeader.Feedback> getTorqueOnMethod() {
|
||||
io.grpc.MethodDescriptor<cmvr.api.Common.CommandHeader.Request, cmvr.api.Common.CommandHeader.Feedback> getTorqueOnMethod;
|
||||
if ((getTorqueOnMethod = HumanoidRobotServiceGrpc.getTorqueOnMethod) == null) {
|
||||
synchronized (HumanoidRobotServiceGrpc.class) {
|
||||
if ((getTorqueOnMethod = HumanoidRobotServiceGrpc.getTorqueOnMethod) == null) {
|
||||
HumanoidRobotServiceGrpc.getTorqueOnMethod = getTorqueOnMethod =
|
||||
io.grpc.MethodDescriptor.<cmvr.api.Common.CommandHeader.Request, cmvr.api.Common.CommandHeader.Feedback>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "torqueOn"))
|
||||
.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 HumanoidRobotServiceMethodDescriptorSupplier("torqueOn"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getTorqueOnMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<cmvr.api.HumanoidRobot.MoveJ.Request,
|
||||
cmvr.api.HumanoidRobot.MoveJ.Response> getMoveJMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "moveJ",
|
||||
requestType = cmvr.api.HumanoidRobot.MoveJ.Request.class,
|
||||
responseType = cmvr.api.HumanoidRobot.MoveJ.Response.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<cmvr.api.HumanoidRobot.MoveJ.Request,
|
||||
cmvr.api.HumanoidRobot.MoveJ.Response> getMoveJMethod() {
|
||||
io.grpc.MethodDescriptor<cmvr.api.HumanoidRobot.MoveJ.Request, cmvr.api.HumanoidRobot.MoveJ.Response> getMoveJMethod;
|
||||
if ((getMoveJMethod = HumanoidRobotServiceGrpc.getMoveJMethod) == null) {
|
||||
synchronized (HumanoidRobotServiceGrpc.class) {
|
||||
if ((getMoveJMethod = HumanoidRobotServiceGrpc.getMoveJMethod) == null) {
|
||||
HumanoidRobotServiceGrpc.getMoveJMethod = getMoveJMethod =
|
||||
io.grpc.MethodDescriptor.<cmvr.api.HumanoidRobot.MoveJ.Request, cmvr.api.HumanoidRobot.MoveJ.Response>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "moveJ"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.HumanoidRobot.MoveJ.Request.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.HumanoidRobot.MoveJ.Response.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new HumanoidRobotServiceMethodDescriptorSupplier("moveJ"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getMoveJMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new async stub that supports all call types for the service
|
||||
*/
|
||||
public static HumanoidRobotServiceStub newStub(io.grpc.Channel channel) {
|
||||
io.grpc.stub.AbstractStub.StubFactory<HumanoidRobotServiceStub> factory =
|
||||
new io.grpc.stub.AbstractStub.StubFactory<HumanoidRobotServiceStub>() {
|
||||
@java.lang.Override
|
||||
public HumanoidRobotServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
return new HumanoidRobotServiceStub(channel, callOptions);
|
||||
}
|
||||
};
|
||||
return HumanoidRobotServiceStub.newStub(factory, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
|
||||
*/
|
||||
public static HumanoidRobotServiceBlockingStub newBlockingStub(
|
||||
io.grpc.Channel channel) {
|
||||
io.grpc.stub.AbstractStub.StubFactory<HumanoidRobotServiceBlockingStub> factory =
|
||||
new io.grpc.stub.AbstractStub.StubFactory<HumanoidRobotServiceBlockingStub>() {
|
||||
@java.lang.Override
|
||||
public HumanoidRobotServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
return new HumanoidRobotServiceBlockingStub(channel, callOptions);
|
||||
}
|
||||
};
|
||||
return HumanoidRobotServiceBlockingStub.newStub(factory, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ListenableFuture-style stub that supports unary calls on the service
|
||||
*/
|
||||
public static HumanoidRobotServiceFutureStub newFutureStub(
|
||||
io.grpc.Channel channel) {
|
||||
io.grpc.stub.AbstractStub.StubFactory<HumanoidRobotServiceFutureStub> factory =
|
||||
new io.grpc.stub.AbstractStub.StubFactory<HumanoidRobotServiceFutureStub>() {
|
||||
@java.lang.Override
|
||||
public HumanoidRobotServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
return new HumanoidRobotServiceFutureStub(channel, callOptions);
|
||||
}
|
||||
};
|
||||
return HumanoidRobotServiceFutureStub.newStub(factory, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static abstract class HumanoidRobotServiceImplBase implements io.grpc.BindableService {
|
||||
|
||||
/**
|
||||
*/
|
||||
public void torqueOff(cmvr.api.Common.CommandHeader.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.Common.CommandHeader.Feedback> responseObserver) {
|
||||
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getTorqueOffMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void torqueOn(cmvr.api.Common.CommandHeader.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.Common.CommandHeader.Feedback> responseObserver) {
|
||||
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getTorqueOnMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void moveJ(cmvr.api.HumanoidRobot.MoveJ.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.HumanoidRobot.MoveJ.Response> responseObserver) {
|
||||
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getMoveJMethod(), responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
getTorqueOffMethod(),
|
||||
io.grpc.stub.ServerCalls.asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
cmvr.api.Common.CommandHeader.Request,
|
||||
cmvr.api.Common.CommandHeader.Feedback>(
|
||||
this, METHODID_TORQUE_OFF)))
|
||||
.addMethod(
|
||||
getTorqueOnMethod(),
|
||||
io.grpc.stub.ServerCalls.asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
cmvr.api.Common.CommandHeader.Request,
|
||||
cmvr.api.Common.CommandHeader.Feedback>(
|
||||
this, METHODID_TORQUE_ON)))
|
||||
.addMethod(
|
||||
getMoveJMethod(),
|
||||
io.grpc.stub.ServerCalls.asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
cmvr.api.HumanoidRobot.MoveJ.Request,
|
||||
cmvr.api.HumanoidRobot.MoveJ.Response>(
|
||||
this, METHODID_MOVE_J)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static final class HumanoidRobotServiceStub extends io.grpc.stub.AbstractAsyncStub<HumanoidRobotServiceStub> {
|
||||
private HumanoidRobotServiceStub(
|
||||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected HumanoidRobotServiceStub build(
|
||||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
return new HumanoidRobotServiceStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void torqueOff(cmvr.api.Common.CommandHeader.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.Common.CommandHeader.Feedback> responseObserver) {
|
||||
io.grpc.stub.ClientCalls.asyncUnaryCall(
|
||||
getChannel().newCall(getTorqueOffMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void torqueOn(cmvr.api.Common.CommandHeader.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.Common.CommandHeader.Feedback> responseObserver) {
|
||||
io.grpc.stub.ClientCalls.asyncUnaryCall(
|
||||
getChannel().newCall(getTorqueOnMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void moveJ(cmvr.api.HumanoidRobot.MoveJ.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.HumanoidRobot.MoveJ.Response> responseObserver) {
|
||||
io.grpc.stub.ClientCalls.asyncUnaryCall(
|
||||
getChannel().newCall(getMoveJMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static final class HumanoidRobotServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub<HumanoidRobotServiceBlockingStub> {
|
||||
private HumanoidRobotServiceBlockingStub(
|
||||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected HumanoidRobotServiceBlockingStub build(
|
||||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
return new HumanoidRobotServiceBlockingStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public cmvr.api.Common.CommandHeader.Feedback torqueOff(cmvr.api.Common.CommandHeader.Request request) {
|
||||
return io.grpc.stub.ClientCalls.blockingUnaryCall(
|
||||
getChannel(), getTorqueOffMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public cmvr.api.Common.CommandHeader.Feedback torqueOn(cmvr.api.Common.CommandHeader.Request request) {
|
||||
return io.grpc.stub.ClientCalls.blockingUnaryCall(
|
||||
getChannel(), getTorqueOnMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public cmvr.api.HumanoidRobot.MoveJ.Response moveJ(cmvr.api.HumanoidRobot.MoveJ.Request request) {
|
||||
return io.grpc.stub.ClientCalls.blockingUnaryCall(
|
||||
getChannel(), getMoveJMethod(), getCallOptions(), request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static final class HumanoidRobotServiceFutureStub extends io.grpc.stub.AbstractFutureStub<HumanoidRobotServiceFutureStub> {
|
||||
private HumanoidRobotServiceFutureStub(
|
||||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected HumanoidRobotServiceFutureStub build(
|
||||
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
|
||||
return new HumanoidRobotServiceFutureStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.Common.CommandHeader.Feedback> torqueOff(
|
||||
cmvr.api.Common.CommandHeader.Request request) {
|
||||
return io.grpc.stub.ClientCalls.futureUnaryCall(
|
||||
getChannel().newCall(getTorqueOffMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.Common.CommandHeader.Feedback> torqueOn(
|
||||
cmvr.api.Common.CommandHeader.Request request) {
|
||||
return io.grpc.stub.ClientCalls.futureUnaryCall(
|
||||
getChannel().newCall(getTorqueOnMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.HumanoidRobot.MoveJ.Response> moveJ(
|
||||
cmvr.api.HumanoidRobot.MoveJ.Request request) {
|
||||
return io.grpc.stub.ClientCalls.futureUnaryCall(
|
||||
getChannel().newCall(getMoveJMethod(), getCallOptions()), request);
|
||||
}
|
||||
}
|
||||
|
||||
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 class MethodHandlers<Req, Resp> implements
|
||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
|
||||
private final HumanoidRobotServiceImplBase serviceImpl;
|
||||
private final int methodId;
|
||||
|
||||
MethodHandlers(HumanoidRobotServiceImplBase serviceImpl, int methodId) {
|
||||
this.serviceImpl = serviceImpl;
|
||||
this.methodId = methodId;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
case METHODID_TORQUE_OFF:
|
||||
serviceImpl.torqueOff((cmvr.api.Common.CommandHeader.Request) request,
|
||||
(io.grpc.stub.StreamObserver<cmvr.api.Common.CommandHeader.Feedback>) responseObserver);
|
||||
break;
|
||||
case METHODID_TORQUE_ON:
|
||||
serviceImpl.torqueOn((cmvr.api.Common.CommandHeader.Request) request,
|
||||
(io.grpc.stub.StreamObserver<cmvr.api.Common.CommandHeader.Feedback>) responseObserver);
|
||||
break;
|
||||
case METHODID_MOVE_J:
|
||||
serviceImpl.moveJ((cmvr.api.HumanoidRobot.MoveJ.Request) request,
|
||||
(io.grpc.stub.StreamObserver<cmvr.api.HumanoidRobot.MoveJ.Response>) responseObserver);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class HumanoidRobotServiceBaseDescriptorSupplier
|
||||
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
|
||||
HumanoidRobotServiceBaseDescriptorSupplier() {}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
|
||||
return cmvr.api.HumanoidRobot.getDescriptor();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
|
||||
return getFileDescriptor().findServiceByName("HumanoidRobotService");
|
||||
}
|
||||
}
|
||||
|
||||
private static final class HumanoidRobotServiceFileDescriptorSupplier
|
||||
extends HumanoidRobotServiceBaseDescriptorSupplier {
|
||||
HumanoidRobotServiceFileDescriptorSupplier() {}
|
||||
}
|
||||
|
||||
private static final class HumanoidRobotServiceMethodDescriptorSupplier
|
||||
extends HumanoidRobotServiceBaseDescriptorSupplier
|
||||
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
|
||||
private final String methodName;
|
||||
|
||||
HumanoidRobotServiceMethodDescriptorSupplier(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
|
||||
return getServiceDescriptor().findMethodByName(methodName);
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
|
||||
|
||||
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
|
||||
io.grpc.ServiceDescriptor result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
synchronized (HumanoidRobotServiceGrpc.class) {
|
||||
result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
|
||||
.setSchemaDescriptor(new HumanoidRobotServiceFileDescriptorSupplier())
|
||||
.addMethod(getTorqueOffMethod())
|
||||
.addMethod(getTorqueOnMethod())
|
||||
.addMethod(getMoveJMethod())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
syntax = "proto3";
|
||||
package cmvr.api;
|
||||
import "cmvr/api/common.proto";
|
||||
|
||||
message JointCmd {
|
||||
string joint_name = 1; // 关节名称
|
||||
double rad = 2; // 弧度
|
||||
double vel = 3; // 角速度,rad/s
|
||||
}
|
||||
|
||||
|
||||
message MoveJ{
|
||||
message Request{
|
||||
CommandHeader.Request header = 1;
|
||||
repeated JointCmd cmds = 2;
|
||||
double vel = 3;
|
||||
double acc = 4;
|
||||
}
|
||||
|
||||
message Response{
|
||||
CommandHeader.Feedback header= 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
service HumanoidRobotService{
|
||||
rpc torqueOff(CommandHeader.Request) returns (CommandHeader.Feedback);
|
||||
rpc torqueOn(CommandHeader.Request) returns (CommandHeader.Feedback);
|
||||
rpc moveJ(MoveJ.Request) returns (MoveJ.Response);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user