feat: 机械臂speedJ
This commit is contained in:
parent
8286d36968
commit
0cd4fac52b
@ -1,7 +1,9 @@
|
||||
package com.cmvr.web.controller.api;
|
||||
|
||||
import com.cmvr.common.core.domain.AjaxResult;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeSpeedJVO;
|
||||
import com.cmvr.edge.client.service.EdgeHumanoidRobotService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -10,7 +12,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "边缘--机械臂")
|
||||
@ -23,16 +24,19 @@ public class EdgeHumanoidRobotController {
|
||||
|
||||
@ApiOperation("moveJ")
|
||||
@PostMapping("/moveJ")
|
||||
public AjaxResult expression(@RequestBody EdgeMoveJVO moveJVO) {
|
||||
public AjaxResult moveJ(@RequestBody EdgeMoveJVO moveJVO) {
|
||||
return AjaxResult.ok(edgeHumanoidRobotService.moveJ(moveJVO));
|
||||
}
|
||||
|
||||
@ApiOperation("speedJ")
|
||||
@PostMapping("/speedJ")
|
||||
public AjaxResult speedJ(@RequestBody EdgeSpeedJVO speedJVO) {
|
||||
return AjaxResult.ok(edgeHumanoidRobotService.speedJ(speedJVO));
|
||||
}
|
||||
|
||||
@ApiOperation("获取关节状态")
|
||||
@GetMapping("/getJointState")
|
||||
public AjaxResult status(
|
||||
@RequestParam("deviceId") String deviceId,
|
||||
@RequestParam("terminalId") String terminalId
|
||||
) {
|
||||
return AjaxResult.ok(edgeHumanoidRobotService.getJointState(terminalId, deviceId));
|
||||
public AjaxResult status(EdgeCommonVO vo) {
|
||||
return AjaxResult.ok(edgeHumanoidRobotService.getJointState(vo));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package com.cmvr.edge.client.model.humanoid;
|
||||
|
||||
import cmvr.api.HumanoidRobotCommand;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EdgeSpeedJVO extends EdgeCommonVO {
|
||||
/** 关节角速度 (rad/s) */
|
||||
private double vel;
|
||||
|
||||
/** 加速度 (rad/s^2) */
|
||||
private double acc;
|
||||
|
||||
/** 关节名称 */
|
||||
private String jointName;
|
||||
|
||||
/**
|
||||
* 角度
|
||||
*/
|
||||
private HumanoidRobotCommand.RobotJointIndexDirection dir;
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package com.cmvr.edge.client.service;
|
||||
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeSpeedJVO;
|
||||
|
||||
/**
|
||||
* 边缘系统机械臂服务
|
||||
@ -14,6 +16,10 @@ public interface EdgeHumanoidRobotService {
|
||||
/**
|
||||
* 获取关节状态
|
||||
*/
|
||||
public String getJointState(String terminalId, String deviceId);
|
||||
public String getJointState(EdgeCommonVO vo);
|
||||
|
||||
/**
|
||||
* 旋转关节
|
||||
*/
|
||||
public String speedJ(EdgeSpeedJVO vo);
|
||||
}
|
||||
|
||||
@ -5,7 +5,9 @@ import cmvr.api.HumanoidRobotCommand;
|
||||
import cmvr.api.HumanoidRobotServiceGrpc;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.cmvr.edge.client.manage.GrpcServiceManager;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeMoveJVO;
|
||||
import com.cmvr.edge.client.model.humanoid.EdgeSpeedJVO;
|
||||
import com.cmvr.edge.client.service.EdgeHumanoidRobotService;
|
||||
import com.cmvr.edge.client.utils.EdgeCommonUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -47,15 +49,31 @@ public class EdgeHumanoidRobotServiceImpl implements EdgeHumanoidRobotService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJointState(String terminalId, String deviceId) {
|
||||
public String getJointState(EdgeCommonVO vo) {
|
||||
HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub stub =
|
||||
grpcServiceManager.getGrpcClient(terminalId, HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub.class);
|
||||
grpcServiceManager.getGrpcClient(vo.getTerminalId(), HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub.class);
|
||||
|
||||
Common.CommandHeader.Request header = EdgeCommonUtil.buildRequest(deviceId);
|
||||
Common.CommandHeader.Request header = EdgeCommonUtil.buildRequest(vo.getDeviceId());
|
||||
HumanoidRobotCommand.JointRequest build = HumanoidRobotCommand.JointRequest.newBuilder()
|
||||
.setHeader(header)
|
||||
.build();
|
||||
HumanoidRobotCommand.JointResponse response = stub.getJointState(build);
|
||||
return JSON.toJSONString(response.getStateList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String speedJ(EdgeSpeedJVO vo) {
|
||||
HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub stub =
|
||||
grpcServiceManager.getGrpcClient(vo.getTerminalId(), HumanoidRobotServiceGrpc.HumanoidRobotServiceBlockingStub.class);
|
||||
|
||||
Common.CommandHeader.Request header = EdgeCommonUtil.buildRequest(vo.getDeviceId());
|
||||
HumanoidRobotCommand.SpeedJ.Request request = HumanoidRobotCommand.SpeedJ.Request.newBuilder()
|
||||
.setHeader(header)
|
||||
.setAcc(vo.getAcc())
|
||||
.setVel(vo.getVel())
|
||||
.setDir(vo.getDir())
|
||||
.build();
|
||||
HumanoidRobotCommand.SpeedJ.Response response = stub.speedJ(request);
|
||||
return JSON.toJSONString(response.getHeader());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user