障碍物检测初始化
This commit is contained in:
@@ -16,7 +16,7 @@ import * as Cesium from 'cesium';
|
|||||||
|
|
||||||
import 'cesium/Build/Cesium/Widgets/widgets.css';
|
import 'cesium/Build/Cesium/Widgets/widgets.css';
|
||||||
|
|
||||||
const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw, onMarkPoint, routeMode = '', polyPoints, mapLayer, activeType, overlayRefreshKey = 0, focusOverlay = null, onObstacleRadiusChange, obstacleShapes = [], onObstacleRectResize, siteMapInfoId }, ref) => {
|
const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw, onMarkPoint, routeMode = '', polyPoints, mapLayer, activeType, overlayRefreshKey = 0, focusOverlay = null, onObstacleRadiusChange, obstacleShapes = [], onObstacleRectResize, siteMapInfoId, detectReportInfo }, ref) => {
|
||||||
const containerRef = useRef(null);
|
const containerRef = useRef(null);
|
||||||
const viewerRef = useRef(null);
|
const viewerRef = useRef(null);
|
||||||
const tooltipRef = useRef(null);
|
const tooltipRef = useRef(null);
|
||||||
@@ -78,6 +78,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
// try { viewer.camera.cancelFlight(); } catch (e) { /* 忽略取消异常 */ }
|
// try { viewer.camera.cancelFlight(); } catch (e) { /* 忽略取消异常 */ }
|
||||||
// viewer.camera.flyTo(config);
|
// viewer.camera.flyTo(config);
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
|
||||||
const resetFlightPriority = () => { lastFlightPriorityRef.current = -1; };
|
const resetFlightPriority = () => { lastFlightPriorityRef.current = -1; };
|
||||||
const getObstacleHandlePosition = (
|
const getObstacleHandlePosition = (
|
||||||
lon,
|
lon,
|
||||||
@@ -246,80 +248,12 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
if (lastFlightPromiseRef.current) viewer.camera.cancelFlight();
|
if (lastFlightPromiseRef.current) viewer.camera.cancelFlight();
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const flyToView = (viewer, priority, config, key = '') => {
|
|
||||||
if (!viewer || viewer.isDestroyed()) return false;
|
|
||||||
|
|
||||||
const state = flightStateRef.current;
|
|
||||||
const now = Date.now();
|
|
||||||
|
|
||||||
// 相同目标正在飞行,忽略重复请求
|
|
||||||
if (
|
|
||||||
state.flying &&
|
|
||||||
state.priority === priority &&
|
|
||||||
state.key === key &&
|
|
||||||
now - (state.startedAt || 0) < 3000
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 仅在当前飞行尚未结束时执行优先级比较
|
|
||||||
if (state.flying && priority < state.priority) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = ++state.token;
|
|
||||||
|
|
||||||
state.priority = priority;
|
|
||||||
state.key = key;
|
|
||||||
state.startedAt = now;
|
|
||||||
state.flying = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
viewer.camera.cancelFlight();
|
|
||||||
|
|
||||||
viewer.camera.flyTo({
|
|
||||||
...config,
|
|
||||||
|
|
||||||
complete: () => {
|
|
||||||
// 旧飞行的回调不能清除新飞行状态
|
|
||||||
if (flightStateRef.current.token !== token) return;
|
|
||||||
|
|
||||||
flightStateRef.current.flying = false;
|
|
||||||
flightStateRef.current.priority = -1;
|
|
||||||
flightStateRef.current.key = null;
|
|
||||||
|
|
||||||
config.complete?.();
|
|
||||||
},
|
|
||||||
|
|
||||||
cancel: () => {
|
|
||||||
if (flightStateRef.current.token !== token) return;
|
|
||||||
|
|
||||||
flightStateRef.current.flying = false;
|
|
||||||
flightStateRef.current.priority = -1;
|
|
||||||
flightStateRef.current.key = null;
|
|
||||||
|
|
||||||
config.cancel?.();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
if (flightStateRef.current.token === token) {
|
|
||||||
flightStateRef.current.flying = false;
|
|
||||||
flightStateRef.current.priority = -1;
|
|
||||||
flightStateRef.current.key = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.error('地图飞行失败:', error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function updateLiveObstacleBoxes(
|
function updateLiveObstacleBoxes(
|
||||||
viewer,
|
viewer,
|
||||||
message,
|
message,
|
||||||
) {
|
) {
|
||||||
|
console.log(message, "障碍物信息")
|
||||||
|
return;
|
||||||
const payload = message.data ?? message;
|
const payload = message.data ?? message;
|
||||||
const objects = payload.objects ?? [];
|
const objects = payload.objects ?? [];
|
||||||
|
|
||||||
@@ -404,6 +338,88 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const handleDetectFn = (res) => {
|
||||||
|
console.log(res, "监测到障碍物")
|
||||||
|
const viewer = viewerRef.current;
|
||||||
|
updateLiveObstacleBoxes(viewer, res);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const flyToView = (viewer, priority, config, key = '') => {
|
||||||
|
if (!viewer || viewer.isDestroyed()) return false;
|
||||||
|
|
||||||
|
const state = flightStateRef.current;
|
||||||
|
const now = Date.now();
|
||||||
|
|
||||||
|
// 相同目标正在飞行,忽略重复请求
|
||||||
|
if (
|
||||||
|
state.flying &&
|
||||||
|
state.priority === priority &&
|
||||||
|
state.key === key &&
|
||||||
|
now - (state.startedAt || 0) < 3000
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅在当前飞行尚未结束时执行优先级比较
|
||||||
|
if (state.flying && priority < state.priority) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = ++state.token;
|
||||||
|
|
||||||
|
state.priority = priority;
|
||||||
|
state.key = key;
|
||||||
|
state.startedAt = now;
|
||||||
|
state.flying = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
viewer.camera.cancelFlight();
|
||||||
|
|
||||||
|
viewer.camera.flyTo({
|
||||||
|
...config,
|
||||||
|
|
||||||
|
complete: () => {
|
||||||
|
// 旧飞行的回调不能清除新飞行状态
|
||||||
|
if (flightStateRef.current.token !== token) return;
|
||||||
|
|
||||||
|
flightStateRef.current.flying = false;
|
||||||
|
flightStateRef.current.priority = -1;
|
||||||
|
flightStateRef.current.key = null;
|
||||||
|
|
||||||
|
config.complete?.();
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel: () => {
|
||||||
|
if (flightStateRef.current.token !== token) return;
|
||||||
|
|
||||||
|
flightStateRef.current.flying = false;
|
||||||
|
flightStateRef.current.priority = -1;
|
||||||
|
flightStateRef.current.key = null;
|
||||||
|
|
||||||
|
config.cancel?.();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
if (flightStateRef.current.token === token) {
|
||||||
|
flightStateRef.current.flying = false;
|
||||||
|
flightStateRef.current.priority = -1;
|
||||||
|
flightStateRef.current.key = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error('地图飞行失败:', error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const clearDrawingPath = () => {
|
const clearDrawingPath = () => {
|
||||||
const viewer = viewerRef.current;
|
const viewer = viewerRef.current;
|
||||||
if (!viewer) return;
|
if (!viewer) return;
|
||||||
@@ -1626,11 +1642,11 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
);
|
);
|
||||||
const lat = Number(obstacle?.position?.lat);
|
const lat = Number(obstacle?.position?.lat);
|
||||||
const radius = Number(obstacle?.radius ?? 2);
|
const radius = Number(obstacle?.radius ?? 2);
|
||||||
// 形状配置:圆形走原有半径逻辑,矩形按长宽渲染
|
// 形状配置:圆形走原有半径逻辑,矩形按长宽渲染
|
||||||
const shapeConfig = obstacleShapes?.[idx] || {};
|
const shapeConfig = obstacleShapes?.[idx] || {};
|
||||||
const isRect = shapeConfig.shapeType === 'rect';
|
const isRect = shapeConfig.shapeType === 'rect';
|
||||||
const rectWidth = Math.max(0.1, Number(shapeConfig.width) || radius * 2);
|
const rectWidth = Math.max(0.1, Number(shapeConfig.width) || radius * 2);
|
||||||
const rectHeight = Math.max(0.1, Number(shapeConfig.height) || radius * 2);
|
const rectHeight = Math.max(0.1, Number(shapeConfig.height) || radius * 2);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!Number.isFinite(lon) ||
|
!Number.isFinite(lon) ||
|
||||||
@@ -1704,7 +1720,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
outlineColor: redColor,
|
outlineColor: redColor,
|
||||||
outlineWidth: isHighlighted ? 4 : 2,
|
outlineWidth: isHighlighted ? 4 : 2,
|
||||||
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|
||||||
// 圆心标记
|
// 圆心标记
|
||||||
@@ -1834,12 +1850,12 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const shapeConfig = obstacleShapes?.[index] || {};
|
const shapeConfig = obstacleShapes?.[index] || {};
|
||||||
const isRect = shapeConfig.shapeType === 'rect';
|
const isRect = shapeConfig.shapeType === 'rect';
|
||||||
const rectWidth = Math.max(
|
const rectWidth = Math.max(
|
||||||
0.1,
|
0.1,
|
||||||
Number(shapeConfig.width) || radius * 2
|
Number(shapeConfig.width) || radius * 2
|
||||||
);
|
);
|
||||||
const rectHeight = Math.max(
|
const rectHeight = Math.max(
|
||||||
0.1,
|
0.1,
|
||||||
Number(shapeConfig.height) || radius * 2
|
Number(shapeConfig.height) || radius * 2
|
||||||
);
|
);
|
||||||
|
|
||||||
draggingObstacleRef.current = {
|
draggingObstacleRef.current = {
|
||||||
@@ -1952,20 +1968,20 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const mouseLat = Cesium.Math.toDegrees(carto.latitude);
|
const mouseLat = Cesium.Math.toDegrees(carto.latitude);
|
||||||
|
|
||||||
const width = Math.max(
|
const width = Math.max(
|
||||||
0.2,
|
0.2,
|
||||||
2 *
|
2 *
|
||||||
Cesium.Cartesian3.distance(
|
Cesium.Cartesian3.distance(
|
||||||
dragging.center,
|
dragging.center,
|
||||||
Cesium.Cartesian3.fromDegrees(mouseLon, dragging.lat, 0)
|
Cesium.Cartesian3.fromDegrees(mouseLon, dragging.lat, 0)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
const height = Math.max(
|
const height = Math.max(
|
||||||
0.2,
|
0.2,
|
||||||
2 *
|
2 *
|
||||||
Cesium.Cartesian3.distance(
|
Cesium.Cartesian3.distance(
|
||||||
dragging.center,
|
dragging.center,
|
||||||
Cesium.Cartesian3.fromDegrees(dragging.lon, mouseLat, 0)
|
Cesium.Cartesian3.fromDegrees(dragging.lon, mouseLat, 0)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
dragging.width = width;
|
dragging.width = width;
|
||||||
@@ -1975,31 +1991,31 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const rectHandle = viewer.entities.getById(dragging.handleId);
|
const rectHandle = viewer.entities.getById(dragging.handleId);
|
||||||
|
|
||||||
if (rectEntity?.rectangle) {
|
if (rectEntity?.rectangle) {
|
||||||
rectEntity.rectangle.coordinates.setValue(
|
rectEntity.rectangle.coordinates.setValue(
|
||||||
getObstacleRectCoordinates(
|
getObstacleRectCoordinates(
|
||||||
dragging.lon,
|
dragging.lon,
|
||||||
dragging.lat,
|
dragging.lat,
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (rectHandle) {
|
if (rectHandle) {
|
||||||
rectHandle.position = new Cesium.ConstantPositionProperty(
|
rectHandle.position = new Cesium.ConstantPositionProperty(
|
||||||
getObstacleRectHandlePosition(
|
getObstacleRectHandlePosition(
|
||||||
dragging.lon,
|
dragging.lon,
|
||||||
dragging.lat,
|
dragging.lat,
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (rectEntity?.label) {
|
if (rectEntity?.label) {
|
||||||
const obstacle =
|
const obstacle =
|
||||||
stationOverlay.tempObstaclePoints?.[dragging.index];
|
stationOverlay.tempObstaclePoints?.[dragging.index];
|
||||||
rectEntity.label.text.setValue(
|
rectEntity.label.text.setValue(
|
||||||
`${obstacle?.alias || `障碍物点-${dragging.index + 1}`} (${width.toFixed(2)}×${height.toFixed(2)}m)`
|
`${obstacle?.alias || `障碍物点-${dragging.index + 1}`} (${width.toFixed(2)}×${height.toFixed(2)}m)`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
viewer.scene.requestRender();
|
viewer.scene.requestRender();
|
||||||
@@ -2064,34 +2080,34 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
setIsDraggingObstacle(false);
|
setIsDraggingObstacle(false);
|
||||||
|
|
||||||
if (viewer) {
|
if (viewer) {
|
||||||
const ctrl = viewer.scene.screenSpaceCameraController;
|
const ctrl = viewer.scene.screenSpaceCameraController;
|
||||||
ctrl.enableRotate = true;
|
ctrl.enableRotate = true;
|
||||||
ctrl.enableTranslate = true;
|
ctrl.enableTranslate = true;
|
||||||
ctrl.enableZoom = true;
|
ctrl.enableZoom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 矩形:打印信息并回传长宽给父组件(暂不走圆形保存逻辑)
|
// 矩形:打印信息并回传长宽给父组件(暂不走圆形保存逻辑)
|
||||||
if (dragging.shapeType === 'rect') {
|
if (dragging.shapeType === 'rect') {
|
||||||
const obstacle =
|
const obstacle =
|
||||||
stationOverlay.tempObstaclePoints?.[index];
|
stationOverlay.tempObstaclePoints?.[index];
|
||||||
const { width, height } = dragging;
|
const { width, height } = dragging;
|
||||||
|
|
||||||
logRectObstacleInfo(
|
logRectObstacleInfo(
|
||||||
obstacle,
|
obstacle,
|
||||||
index,
|
index,
|
||||||
dragging.lon,
|
dragging.lon,
|
||||||
dragging.lat,
|
dragging.lat,
|
||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
);
|
);
|
||||||
|
|
||||||
onObstacleRectResize?.(
|
onObstacleRectResize?.(
|
||||||
index,
|
index,
|
||||||
Number(width.toFixed(2)),
|
Number(width.toFixed(2)),
|
||||||
Number(height.toFixed(2))
|
Number(height.toFixed(2))
|
||||||
);
|
);
|
||||||
viewer?.scene.requestRender();
|
viewer?.scene.requestRender();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通知父组件更新列表
|
// 通知父组件更新列表
|
||||||
@@ -3553,6 +3569,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
resolve(dataUrl);
|
resolve(dataUrl);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
handleDetectFn(detectReportInfo)
|
||||||
|
}, [detectReportInfo])
|
||||||
|
|
||||||
// 暴露 ref 方法
|
// 暴露 ref 方法
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ export default function DeviceStatusPage() {
|
|||||||
const controllerRef = useRef<DeviceController | null>(null);
|
const controllerRef = useRef<DeviceController | null>(null);
|
||||||
|
|
||||||
const isFirstConnect = useRef(true);
|
const isFirstConnect = useRef(true);
|
||||||
|
const [detectReportInfo, setDeportInfo] = useState<any>(null);
|
||||||
|
|
||||||
// 标记本次会话是否已经发起过控制权限申请,避免手柄/方向盘高频更新时重复申请
|
// 标记本次会话是否已经发起过控制权限申请,避免手柄/方向盘高频更新时重复申请
|
||||||
|
|
||||||
@@ -1184,6 +1185,11 @@ export default function DeviceStatusPage() {
|
|||||||
mapRef.current?.flyToPosition?.(realtimePosition, { height: 300 });
|
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.handleArrivedPoint = handleFinishEdPoint;
|
||||||
|
|
||||||
|
controller.onDetectionReport = handleDetectionReport;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1511,6 +1520,14 @@ export default function DeviceStatusPage() {
|
|||||||
|
|
||||||
return;
|
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);
|
console.log('Gamepad state updated:', state);
|
||||||
@@ -2433,6 +2450,8 @@ export default function DeviceStatusPage() {
|
|||||||
ifClearNavLine={clearNavLine}
|
ifClearNavLine={clearNavLine}
|
||||||
|
|
||||||
ifClearPlanLine={clearPlanLine}
|
ifClearPlanLine={clearPlanLine}
|
||||||
|
detectReportInfo={detectReportInfo}
|
||||||
|
|
||||||
|
|
||||||
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
|
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
|
||||||
|
|
||||||
|
|||||||
@@ -144,14 +144,11 @@ export default function MapEditorPage() {
|
|||||||
};
|
};
|
||||||
loadDevices();
|
loadDevices();
|
||||||
}, [stationId]);
|
}, [stationId]);
|
||||||
useEffect(() => {
|
|
||||||
console.log("siteMapInfoId state:", siteMapInfoId);
|
|
||||||
}, [siteMapInfoId]);
|
|
||||||
const getSiteMapInfoFn = () => {
|
const getSiteMapInfoFn = () => {
|
||||||
getSiteMapInfo({ siteId: stationId }).then((res: any) => {
|
getSiteMapInfo({ siteId: stationId }).then((res: any) => {
|
||||||
if (res?.code === 200 && res.data) {
|
if (res?.code === 200 && res.data) {
|
||||||
setSiteMapInfoId(res.data.id ?? null);
|
setSiteMapInfoId(res.data.id ?? null);
|
||||||
console.log(res.data.id, "res.data.id")
|
|
||||||
setReturnPointConfigList(res?.data?.restPoints || []);
|
setReturnPointConfigList(res?.data?.restPoints || []);
|
||||||
// 同时加载已保存的障碍物点(tempObstaclePoints),方便编辑
|
// 同时加载已保存的障碍物点(tempObstaclePoints),方便编辑
|
||||||
const savedObstacles = (res?.data?.tempObstaclePoints || []).map((op: any) => ({
|
const savedObstacles = (res?.data?.tempObstaclePoints || []).map((op: any) => ({
|
||||||
@@ -160,12 +157,17 @@ export default function MapEditorPage() {
|
|||||||
lat: Number(op.position?.lat ?? 0),
|
lat: Number(op.position?.lat ?? 0),
|
||||||
name: op.alias || '',
|
name: op.alias || '',
|
||||||
radius: Number(op.radius) || 2.0,
|
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);
|
setObstaclePointConfigList(savedObstacles);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setSiteMapInfoId(null);
|
setSiteMapInfoId(null);
|
||||||
console.log("res.data.id111")
|
|
||||||
|
|
||||||
setReturnPointConfigList([]);
|
setReturnPointConfigList([]);
|
||||||
setObstaclePointConfigList([]);
|
setObstaclePointConfigList([]);
|
||||||
@@ -173,7 +175,6 @@ export default function MapEditorPage() {
|
|||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
setSiteMapInfoId(null);
|
setSiteMapInfoId(null);
|
||||||
console.log("res.data.id112221")
|
|
||||||
|
|
||||||
setReturnPointConfigList([]);
|
setReturnPointConfigList([]);
|
||||||
setObstaclePointConfigList([]);
|
setObstaclePointConfigList([]);
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ export default function RobotTaskPage() {
|
|||||||
const [taskList, setTaskList] = useState([]);
|
const [taskList, setTaskList] = useState([]);
|
||||||
const { modal } = App.useApp();
|
const { modal } = App.useApp();
|
||||||
const [polyPoints, setPolyPoints] = useState([]);
|
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); }
|
//if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
|
||||||
//setShowVideo(true);
|
//setShowVideo(true);
|
||||||
};
|
};
|
||||||
|
const handleDetectionReport = (res) => {
|
||||||
|
console.log('收到障碍物物信息', res);
|
||||||
|
setDeportInfo(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -298,6 +304,8 @@ export default function RobotTaskPage() {
|
|||||||
controller.deviceStatusChangedMsg = () => {
|
controller.deviceStatusChangedMsg = () => {
|
||||||
fetchAllData();
|
fetchAllData();
|
||||||
}
|
}
|
||||||
|
controller.onDetectionReport = handleDetectionReport;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1565,6 +1573,8 @@ export default function RobotTaskPage() {
|
|||||||
routeMode={routeMode}
|
routeMode={routeMode}
|
||||||
mapLayer={currentStation?.siteMapName}
|
mapLayer={currentStation?.siteMapName}
|
||||||
focusOverlay={focusOverlay}
|
focusOverlay={focusOverlay}
|
||||||
|
detectReportInfo={detectReportInfo}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 机器人状态悬浮面板 - 绝对定位左上角 */}
|
{/* 机器人状态悬浮面板 - 绝对定位左上角 */}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export default class DeviceController {
|
|||||||
this.onIsFinished = null;
|
this.onIsFinished = null;
|
||||||
this.onIsExecuting = null;
|
this.onIsExecuting = null;
|
||||||
this.handleArrivedPoint = null;
|
this.handleArrivedPoint = null;
|
||||||
|
this.onDetectionReport = null;
|
||||||
|
|
||||||
// 全量设备实时状态(mapPush)连接
|
// 全量设备实时状态(mapPush)连接
|
||||||
this.mapPushWs = null;
|
this.mapPushWs = null;
|
||||||
@@ -167,6 +168,23 @@ export default class DeviceController {
|
|||||||
console.log('route_post');
|
console.log('route_post');
|
||||||
this.onRoutePost?.(msg);
|
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);
|
this.deviceStatusChangedMsg?.(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'remoteControl':
|
case 'detectionReport':
|
||||||
|
this.onDetectionReport?.(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1451,6 +1451,8 @@
|
|||||||
cutterSpedd: 'cutterSpedd',
|
cutterSpedd: 'cutterSpedd',
|
||||||
controlOff: 'controlOff',
|
controlOff: 'controlOff',
|
||||||
localCpntrol: 'localCpntrol',
|
localCpntrol: 'localCpntrol',
|
||||||
|
noRemoteControl: "no RemoteControl Mode",
|
||||||
|
|
||||||
autoTask: 'autoTask',
|
autoTask: 'autoTask',
|
||||||
manualTask: 'manualTask',
|
manualTask: 'manualTask',
|
||||||
manualControl: 'manualControl',
|
manualControl: 'manualControl',
|
||||||
|
|||||||
@@ -394,6 +394,7 @@ const zh = {
|
|||||||
timelineMaintenanceDetail: '所有割草机返回充电站',
|
timelineMaintenanceDetail: '所有割草机返回充电站',
|
||||||
autoGenerateTodayPlan: '智能生成今日计划',
|
autoGenerateTodayPlan: '智能生成今日计划',
|
||||||
deviceEnvironment: '设备环境与状态',
|
deviceEnvironment: '设备环境与状态',
|
||||||
|
noRemoteControl: "非远程控制模式",
|
||||||
currentTemp: '当前温度',
|
currentTemp: '当前温度',
|
||||||
humidity: '环境湿度',
|
humidity: '环境湿度',
|
||||||
positionAccuracy: '定位精度',
|
positionAccuracy: '定位精度',
|
||||||
|
|||||||
Reference in New Issue
Block a user