feat: 添加手动发布充电任务功能,更新API接口并优化机器人前往充电逻辑
This commit is contained in:
parent
e2cb39b27c
commit
9ee0cc394d
@ -4,5 +4,5 @@ ENV_WEBSOCKET_BASE=/ws
|
||||
ENV_STORAGE_WEBSOCKET_BASE=/vwedWs
|
||||
|
||||
# 开发环境token配置 - 可以手动设置或从另一个项目获取后填入
|
||||
ENV_DEV_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NTc1Mjc0NTksInVzZXJuYW1lIjoiYWRtaW4ifQ.MionV2RtdoIm085NYLRQxCNHxmgB9HGCvYXlsAERkG4
|
||||
ENV_DEV_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NTgyMTA0NTIsInVzZXJuYW1lIjoiYWRtaW4ifQ.UTbugug5gJAxFvC92T_5wqt4JeI_SnF4PeayjAx5K4g
|
||||
ENV_DEV_TENANT_ID=1000
|
||||
|
@ -4,11 +4,28 @@ const enum API {
|
||||
// 控制接口 - 只包含右键菜单需要的
|
||||
控制AMR = '/amr/control',
|
||||
抢占控制权 = '/amr/controlAmr',
|
||||
设置接单状态 = '/amr/acceptTask',
|
||||
// 设置接单状态 = '/amr/acceptTask',
|
||||
手动发布充电任务 = '/amr/manuallSetCharging',
|
||||
}
|
||||
|
||||
// 只保留右键菜单需要的API函数
|
||||
|
||||
/**
|
||||
* 手动发布充电任务
|
||||
* @param sceneId 场景ID
|
||||
* @param amrId AMR ID
|
||||
* @returns 是否成功
|
||||
*/
|
||||
export async function manuallSetCharging(sceneId: string, amrId: string): Promise<boolean> {
|
||||
try {
|
||||
await http.get(`${API.手动发布充电任务}/${sceneId}/${amrId}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('手动发布充电任务失败:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制AMR - 用于暂停、继续、启动、停止、前往充电、前往停靠、路径导航、重置、诊断、更新
|
||||
*/
|
||||
|
@ -128,9 +128,6 @@ const handleActionComplete = (data: any) => {
|
||||
if (data.success) {
|
||||
const actionName = getActionDisplayName(data.action);
|
||||
message.success(`${actionName}操作成功`);
|
||||
} else {
|
||||
const actionName = getActionDisplayName(data.action);
|
||||
message.error(`${actionName}操作失败`);
|
||||
}
|
||||
|
||||
emit('actionComplete', data);
|
||||
|
@ -6,6 +6,7 @@
|
||||
import * as AmrApi from '../../apis/amr';
|
||||
import type { RobotInfo } from '../../apis/robot';
|
||||
import { RobotState } from '../../apis/robot';
|
||||
import { editorStore } from '../../stores/editor.store';
|
||||
|
||||
export interface RobotMenuConfig {
|
||||
menuType: 'robot' | 'default';
|
||||
@ -61,7 +62,7 @@ export async function executeRobotAction(
|
||||
console.error(`机器人${action}操作失败:`, error);
|
||||
return {
|
||||
success: false,
|
||||
message: `机器人${action}操作失败: ${error}`,
|
||||
message: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -122,10 +123,19 @@ async function executeAmrAction(
|
||||
result = await AmrApi.controlAmr(robotInfo.id, 'stop');
|
||||
break;
|
||||
|
||||
case 'go_charge':
|
||||
case 'go_charge': {
|
||||
// 前往充电 - 有对应API
|
||||
result = await AmrApi.controlAmr(robotInfo.id, 'go_charge');
|
||||
const sceneId = editorStore.getEditorValue()?.getSceneId();
|
||||
if (!sceneId) {
|
||||
console.error('前往充电失败: 场景ID未提供');
|
||||
return {
|
||||
success: false,
|
||||
message: '',
|
||||
};
|
||||
}
|
||||
result = await AmrApi.manuallSetCharging(sceneId, robotInfo.id);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'go_dock':
|
||||
// 前往停靠 - 有对应API
|
||||
@ -187,14 +197,14 @@ async function executeAmrAction(
|
||||
|
||||
return {
|
||||
success: result,
|
||||
message: result ? `${action}操作成功` : `${action}操作失败`,
|
||||
message: result ? `${action}操作成功` : '',
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error(`AMR操作失败 (${action}):`, error);
|
||||
return {
|
||||
success: false,
|
||||
message: `操作失败: ${error}`,
|
||||
message: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -662,6 +662,10 @@ export class EditorService extends Meta2d {
|
||||
/** 保存从后台传来的所有额外字段(除了已处理的robotGroups、robots、points、routes、areas之外的字段) */
|
||||
#originalSceneData?: Partial<StandardScene>;
|
||||
|
||||
public getSceneId(): string | undefined {
|
||||
return (this.#originalSceneData as any)?.id;
|
||||
}
|
||||
|
||||
/** 坐标转换方法 - 将左上角原点的坐标转换为中心点原点的坐标 */
|
||||
#transformCoordinate(x: number, y: number): { x: number; y: number } {
|
||||
const { ratio = 1, width = 0, height = 0 } = this.#originalSceneData ?? {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user