feat(agv): 添加AGV移动到指定点功能
- 在ActionEnum中新增AGV_MOVE_TO_POINT枚举值 - 在FlowActionExecutorService中添加AGV移动逻辑处理 - 新增EdgeAgvOperateService实现AGV边缘操作服务 - 集成EdgeAgvService进行机器人导航控制 - 实现坐标参数解析和验证功能 - 添加AGV移动任务下发和结果返回机制
This commit is contained in:
parent
db17d50ef6
commit
0f36d8b4d1
@ -63,6 +63,9 @@ public enum ActionEnum {
|
||||
BIO_HEAD_SPEAK_STOP("EDGE", "BIO_HEAD_SPEAK_STOP", "停止说话"),
|
||||
BIO_HEAD_SPECIAL_EXPRESSION("EDGE", "BIO_HEAD_SPECIAL_EXPRESSION", "表情,1:高兴,2:惊讶,3:疲惫"),
|
||||
|
||||
// --------------- agv ---------------
|
||||
AGV_MOVE_TO_POINT("EDGE", "AGV_MOVE_TO_POINT", "移动到指定点"),
|
||||
|
||||
// 大模型行为
|
||||
// ---------------获取触控坐标---------------
|
||||
TOUCH_COORDINATES("LLM", "TOUCH_COORDINATES", "获取触控坐标"),
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
package com.cmvr.test.flow.runtime.operator.edge;
|
||||
|
||||
import cmvr.api.AgvCommand;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cmvr.common.exception.GlobalException;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.service.EdgeAgvService;
|
||||
import com.cmvr.test.enums.ActionEnum;
|
||||
import com.cmvr.test.flow.runtime.message.TaskNodeExecuteMessage;
|
||||
import com.cmvr.test.flow.runtime.message.TaskNodeExecuteResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* AGV边缘操作服务
|
||||
* 处理AGV相关的设备行为,如移动到指定位置
|
||||
*
|
||||
* @author cmvr-iot
|
||||
* @since 2026-06-29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class EdgeAgvOperateService implements EdgeOperateService {
|
||||
|
||||
private final EdgeAgvService edgeAgvService;
|
||||
|
||||
@Override
|
||||
public boolean supports(ActionEnum action) {
|
||||
return action.name().startsWith("AGV_");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskNodeExecuteResult execute(TaskNodeExecuteMessage message) {
|
||||
ActionEnum action = message.getAction();
|
||||
JSONObject inputParams = message.getInputParams();
|
||||
String terminalId = message.getTerminalId();
|
||||
|
||||
// 从输入参数中获取机器人ID
|
||||
String deviceId = inputParams.getString("deviceId");
|
||||
|
||||
if (deviceId == null || deviceId.isEmpty()) {
|
||||
throw new GlobalException("机器人ID(deviceId)不能为空");
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case AGV_MOVE_TO_POINT: {
|
||||
log.info("执行AGV移动到指定位置操作,机器人ID: {}", deviceId);
|
||||
|
||||
// 从输入参数中获取坐标信息
|
||||
Double x = inputParams.getDouble("x");
|
||||
Double y = inputParams.getDouble("y");
|
||||
Double theta = inputParams.getDouble("theta");
|
||||
String taskId = inputParams.getString("taskId");
|
||||
|
||||
// 参数验证
|
||||
if (x == null || y == null) {
|
||||
throw new GlobalException("X和Y坐标不能为空");
|
||||
}
|
||||
|
||||
// 构建自由导航点
|
||||
AgvCommand.FreeGoPoint freeGoPoint = AgvCommand.FreeGoPoint.newBuilder()
|
||||
.setX(x)
|
||||
.setY(y)
|
||||
.setTheta(theta != null ? theta : 0.0)
|
||||
.build();
|
||||
|
||||
// 构建边缘端通用参数
|
||||
EdgeCommonVO edgeCommonVO = new EdgeCommonVO();
|
||||
edgeCommonVO.setTerminalId(terminalId);
|
||||
edgeCommonVO.setDeviceId(deviceId);
|
||||
|
||||
// 直接调用边缘端AGV服务执行导航
|
||||
AgvCommand.RobotGoTargetResData result =
|
||||
edgeAgvService.robotGoTargetWithFreeGo(edgeCommonVO, freeGoPoint, taskId);
|
||||
|
||||
log.info("AGV移动任务下发成功,返回码: {}", result.getRetCode());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new GlobalException("不支持的AGV操作类型: " + action);
|
||||
}
|
||||
|
||||
return TaskNodeExecuteResult.success();
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ import com.cmvr.edge.client.service.EdgeCameraService;
|
||||
import com.cmvr.edge.client.service.EdgeHlcService;
|
||||
import com.cmvr.edge.client.service.EdgeMicrophoneService;
|
||||
import com.cmvr.edge.client.service.EdgeSpeakerService;
|
||||
import com.cmvr.edge.client.service.EdgeAgvService;
|
||||
import com.cmvr.llm.service.LLMAiAgentPlatformService;
|
||||
import com.cmvr.llm.service.LLMAiTtsService;
|
||||
import com.cmvr.test.enums.ActionEnum;
|
||||
@ -31,6 +32,7 @@ public class FlowActionExecutorService {
|
||||
private final EdgeHlcService edgeHlcService;
|
||||
private final LLMAiTtsService llmAiTtsService;
|
||||
private final LLMAiAgentPlatformService llmAiAgentPlatformService;
|
||||
private final EdgeAgvService edgeAgvService;
|
||||
|
||||
public String actionExecute(FlowActionRequestVO req) {
|
||||
|
||||
@ -104,6 +106,44 @@ public class FlowActionExecutorService {
|
||||
edgeFacialExpressionVO.setDeviceId(deviceId);
|
||||
return edgeBioHeadService.setExpression(edgeFacialExpressionVO);
|
||||
|
||||
// ==== AGV ====
|
||||
case AGV_MOVE_TO_POINT: {
|
||||
log.info("执行AGV移动到指定位置操作");
|
||||
|
||||
// 从payload中获取机器人ID和坐标信息
|
||||
String deviceId1 = payload.getString("deviceId");
|
||||
if (StrUtil.isEmpty(deviceId1)) {
|
||||
throw new GlobalException("机器人ID(deviceId)不能为空");
|
||||
}
|
||||
|
||||
Double x = payload.getDouble("x");
|
||||
Double y = payload.getDouble("y");
|
||||
Double theta = payload.getDouble("theta");
|
||||
String taskId = payload.getString("taskId");
|
||||
|
||||
// 参数验证
|
||||
if (x == null || y == null) {
|
||||
throw new GlobalException("X和Y坐标不能为空");
|
||||
}
|
||||
|
||||
// 构建自由导航点
|
||||
cmvr.api.AgvCommand.FreeGoPoint freeGoPoint = cmvr.api.AgvCommand.FreeGoPoint.newBuilder()
|
||||
.setX(x)
|
||||
.setY(y)
|
||||
.setTheta(theta != null ? theta : 0.0)
|
||||
.build();
|
||||
|
||||
// 直接调用边缘端AGV服务
|
||||
cmvr.api.AgvCommand.RobotGoTargetResData result =
|
||||
edgeAgvService.robotGoTargetWithFreeGo(edgeCommonVO, freeGoPoint, taskId);
|
||||
|
||||
log.info("AGV移动任务下发成功,返回码: {}", result.getRetCode());
|
||||
|
||||
// 返回结果字符串
|
||||
return String.format("AGV移动任务下发成功, retCode=%d, errMsg=%s",
|
||||
result.getRetCode(), result.getErrMsg());
|
||||
}
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("未实现的 EDGE Action: " + action.name());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user