障碍物检测初始化
This commit is contained in:
@@ -344,6 +344,7 @@ export default function DeviceStatusPage() {
|
||||
const controllerRef = useRef<DeviceController | null>(null);
|
||||
|
||||
const isFirstConnect = useRef(true);
|
||||
const [detectReportInfo, setDeportInfo] = useState<any>(null);
|
||||
|
||||
// 标记本次会话是否已经发起过控制权限申请,避免手柄/方向盘高频更新时重复申请
|
||||
|
||||
@@ -1184,6 +1185,11 @@ export default function DeviceStatusPage() {
|
||||
mapRef.current?.flyToPosition?.(realtimePosition, { height: 300 });
|
||||
|
||||
};
|
||||
const handleDetectionReport = (res) => {
|
||||
setDeportInfo(res);
|
||||
console.log("获取障碍物信息", res)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1207,6 +1213,9 @@ export default function DeviceStatusPage() {
|
||||
|
||||
controller.handleArrivedPoint = handleFinishEdPoint;
|
||||
|
||||
controller.onDetectionReport = handleDetectionReport;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1511,6 +1520,14 @@ export default function DeviceStatusPage() {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
console.log(realtimePosition?.controlMode, "现在的控制controlmode")
|
||||
if (realtimePosition?.controlMode != 3 || realtimePosition?.control_mode != 3) {
|
||||
|
||||
messageApi.warning(t('devices.noRemoteControl'));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
console.log('Gamepad state updated:', state);
|
||||
@@ -2433,6 +2450,8 @@ export default function DeviceStatusPage() {
|
||||
ifClearNavLine={clearNavLine}
|
||||
|
||||
ifClearPlanLine={clearPlanLine}
|
||||
detectReportInfo={detectReportInfo}
|
||||
|
||||
|
||||
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
|
||||
|
||||
|
||||
@@ -144,14 +144,11 @@ export default function MapEditorPage() {
|
||||
};
|
||||
loadDevices();
|
||||
}, [stationId]);
|
||||
useEffect(() => {
|
||||
console.log("siteMapInfoId state:", siteMapInfoId);
|
||||
}, [siteMapInfoId]);
|
||||
|
||||
const getSiteMapInfoFn = () => {
|
||||
getSiteMapInfo({ siteId: stationId }).then((res: any) => {
|
||||
if (res?.code === 200 && res.data) {
|
||||
setSiteMapInfoId(res.data.id ?? null);
|
||||
console.log(res.data.id, "res.data.id")
|
||||
setReturnPointConfigList(res?.data?.restPoints || []);
|
||||
// 同时加载已保存的障碍物点(tempObstaclePoints),方便编辑
|
||||
const savedObstacles = (res?.data?.tempObstaclePoints || []).map((op: any) => ({
|
||||
@@ -160,12 +157,17 @@ export default function MapEditorPage() {
|
||||
lat: Number(op.position?.lat ?? 0),
|
||||
name: op.alias || '',
|
||||
radius: Number(op.radius) || 2.0,
|
||||
//shapeType:
|
||||
// op.shapeType === 'rect' || op.shape_type === 'aabb'
|
||||
// ? 'rect'
|
||||
// : 'circle',
|
||||
//width: Number(op.width ?? op.size?.[0]) || (Number(op.radius) || 2) * 2,
|
||||
//height: Number(op.height ?? op.size?.[1]) || (Number(op.radius) || 2) * 2,
|
||||
}));
|
||||
setObstaclePointConfigList(savedObstacles);
|
||||
|
||||
} else {
|
||||
setSiteMapInfoId(null);
|
||||
console.log("res.data.id111")
|
||||
|
||||
setReturnPointConfigList([]);
|
||||
setObstaclePointConfigList([]);
|
||||
@@ -173,7 +175,6 @@ export default function MapEditorPage() {
|
||||
}
|
||||
}).catch(() => {
|
||||
setSiteMapInfoId(null);
|
||||
console.log("res.data.id112221")
|
||||
|
||||
setReturnPointConfigList([]);
|
||||
setObstaclePointConfigList([]);
|
||||
|
||||
@@ -72,6 +72,8 @@ export default function RobotTaskPage() {
|
||||
const [taskList, setTaskList] = useState([]);
|
||||
const { modal } = App.useApp();
|
||||
const [polyPoints, setPolyPoints] = useState([]);
|
||||
const [detectReportInfo, setDeportInfo] = useState<any>(null);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -281,6 +283,10 @@ export default function RobotTaskPage() {
|
||||
//if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
|
||||
//setShowVideo(true);
|
||||
};
|
||||
const handleDetectionReport = (res) => {
|
||||
console.log('收到障碍物物信息', res);
|
||||
setDeportInfo(res);
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -298,6 +304,8 @@ export default function RobotTaskPage() {
|
||||
controller.deviceStatusChangedMsg = () => {
|
||||
fetchAllData();
|
||||
}
|
||||
controller.onDetectionReport = handleDetectionReport;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1565,6 +1573,8 @@ export default function RobotTaskPage() {
|
||||
routeMode={routeMode}
|
||||
mapLayer={currentStation?.siteMapName}
|
||||
focusOverlay={focusOverlay}
|
||||
detectReportInfo={detectReportInfo}
|
||||
|
||||
/>
|
||||
|
||||
{/* 机器人状态悬浮面板 - 绝对定位左上角 */}
|
||||
|
||||
@@ -47,6 +47,7 @@ export default class DeviceController {
|
||||
this.onIsFinished = null;
|
||||
this.onIsExecuting = null;
|
||||
this.handleArrivedPoint = null;
|
||||
this.onDetectionReport = null;
|
||||
|
||||
// 全量设备实时状态(mapPush)连接
|
||||
this.mapPushWs = null;
|
||||
@@ -167,6 +168,23 @@ export default class DeviceController {
|
||||
console.log('route_post');
|
||||
this.onRoutePost?.(msg);
|
||||
}
|
||||
if (msg?.type == 'detectionReport') {
|
||||
console.log('detectionReport');
|
||||
this.onDetectionReport?.(msg);
|
||||
}
|
||||
|
||||
// case 'detectionReport':
|
||||
//const { isSecure, obstacle } = msg.data;
|
||||
//if (isSecure) return;
|
||||
//const type = obstacle?.type;
|
||||
//const distance = (obstacle?.distance || 0).toFixed(2);
|
||||
//const types = { 0: i18n.t('constants.locationUnknown'), 1: i18n.t('devices.obstaclePerson'), 2: i18n.t('devices.obstacleVehicle'), 3: i18n.t('devices.obstacleFence'), 4: i18n.t('devices.obstaclePothole'), 5: i18n.t('devices.obstacleGrass') };
|
||||
//this.messageApi.warning({
|
||||
// key: 'obstacle-warning',
|
||||
// content: i18n.t('devices.obstacleDetectedReport', { obstacle: types[type] ?? i18n.t('devices.unknownObject'), distance }),
|
||||
// duration: 3,
|
||||
//});
|
||||
//break;
|
||||
|
||||
|
||||
|
||||
@@ -527,10 +545,11 @@ export default class DeviceController {
|
||||
this.deviceStatusChangedMsg?.(msg);
|
||||
break;
|
||||
|
||||
case 'remoteControl':
|
||||
|
||||
case 'detectionReport':
|
||||
this.onDetectionReport?.(msg);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user