寻车功能 和返航按键 还有 任务excuting 推送 刷新功能 但是 没用,另一个电脑还没有 连接ws呢 难搞 加 另一个车道辅助线 组件实现
This commit is contained in:
@@ -71,6 +71,8 @@ import { dataUrlToFile } from '@/lib/utils.ts';
|
||||
import { useUnitFormatter } from '@/lib/units';
|
||||
import { PauseOutlined, PlayCircleOutlined } from '@ant-design/icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import CarReverseGuideLine from './CarReverseGuideLine';
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
const { Text } = Typography;
|
||||
@@ -94,6 +96,9 @@ export default function DeviceStatusPage() {
|
||||
const hasRequestedControlRef = useRef(false);
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
|
||||
const [direction, setDirection] = useState<'forward' | 'reverse'>('reverse');
|
||||
const [steer, setSteer] = useState(0);
|
||||
|
||||
|
||||
// 视频播放开关
|
||||
const [isVideoPlaying, setIsVideoPlaying] = useState(false);
|
||||
@@ -463,25 +468,53 @@ export default function DeviceStatusPage() {
|
||||
heading: currentDroneData.heading || 0,
|
||||
};
|
||||
}
|
||||
// 无人机没有实时数据时,用 lastRunningStatus 兜底
|
||||
const baseLon = device?.lastRunningStatus?.longitude || device?.longitude;
|
||||
const baseLat = device?.lastRunningStatus?.latitude || device?.latitude;
|
||||
if (baseLon && baseLat) {
|
||||
return {
|
||||
lon: Number(baseLon),
|
||||
lat: Number(baseLat),
|
||||
heading: device?.lastRunningStatus?.heading || 0,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 2. 机器人:从 wsDeviceInfo / runningStatus 取实时经纬度
|
||||
const robotLon = runningStatus?.longitude || wsDeviceInfo?.longitude;
|
||||
const robotLat = runningStatus?.latitude || wsDeviceInfo?.latitude;
|
||||
// 2. 机器人:优先从 wsDeviceInfo / runningStatus / locationInfo 取实时经纬度
|
||||
let robotLon = runningStatus?.longitude || wsDeviceInfo?.longitude || locationInfo?.longitude;
|
||||
let robotLat = runningStatus?.latitude || wsDeviceInfo?.latitude || locationInfo?.latitude;
|
||||
|
||||
// 3. 没有实时经纬度时,从 lastRunningStatus 兜底
|
||||
if ((!robotLon || !robotLat) && (device?.lastRunningStatus || device?.locationMessage)) {
|
||||
robotLon = robotLon || device?.lastRunningStatus?.longitude || device?.locationMessage?.longitude;
|
||||
robotLat = robotLat || device?.lastRunningStatus?.latitude || device?.locationMessage?.latitude;
|
||||
}
|
||||
// 4. 最终兜底:设备静态经纬度
|
||||
if ((!robotLon || !robotLat) && device) {
|
||||
robotLon = robotLon || device.longitude;
|
||||
robotLat = robotLat || device.latitude;
|
||||
}
|
||||
|
||||
if (robotLon && robotLat) {
|
||||
return {
|
||||
lon: robotLon,
|
||||
lat: robotLat,
|
||||
//heading: -98
|
||||
heading: runningStatus?.yaw || wsDeviceInfo?.yaw || 0,
|
||||
heading: runningStatus?.yaw || wsDeviceInfo?.yaw || locationInfo?.yaw || device?.lastRunningStatus?.heading || 0,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}, [isUAV, currentDroneData, runningStatus, wsDeviceInfo]);
|
||||
}, [isUAV, currentDroneData, runningStatus, wsDeviceInfo, locationInfo, device]);
|
||||
|
||||
// 寻车:地图定位到当前设备位置
|
||||
const handleFindCar = () => {
|
||||
if (!realtimePosition) {
|
||||
messageApi.warning(t('devices.locationUnknown'));
|
||||
return;
|
||||
}
|
||||
mapRef.current?.flyToPosition?.(realtimePosition, { height: 300 });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new DeviceController(userInfo, messageApi);
|
||||
@@ -927,6 +960,8 @@ export default function DeviceStatusPage() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div style={{ background: 'linear-gradient(180deg, #f0f4f8 0%, #e8eef5 100%)', minHeight: '100%', padding: 0 }}>
|
||||
<style>{`
|
||||
@@ -936,6 +971,34 @@ export default function DeviceStatusPage() {
|
||||
<div style={{ padding: '4px 0px 8px' }}>
|
||||
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('devices.deviceStatus')}</Typography.Title>
|
||||
</div>
|
||||
|
||||
|
||||
{/*<div style={{ marginBottom: 16 }}>
|
||||
<button onClick={() => setDirection('reverse')} style={{ marginRight: 8 }}>倒车</button>
|
||||
<button onClick={() => setDirection('forward')}>前进</button>
|
||||
<div style={{ marginTop: 8 }}>
|
||||
方向盘转角:{steer}°
|
||||
<br />
|
||||
<input
|
||||
type="range"
|
||||
min={-45}
|
||||
max={45}
|
||||
value={steer}
|
||||
onChange={(e) => setSteer(Number(e.target.value))}
|
||||
/>
|
||||
<p>左滑:左转(负数)|右滑:右转(正数)</p>
|
||||
</div>
|
||||
</div>
|
||||
<CarReverseGuideLine
|
||||
direction="reverse"
|
||||
steer={steer}
|
||||
width={640}
|
||||
height={480}
|
||||
bottomGap={280} // 车尾端两条线间距
|
||||
topGap={100} // 远端顶部两条线间距
|
||||
/>*/}
|
||||
|
||||
|
||||
<div style={{ padding: 0 }}>
|
||||
{contextHolder}
|
||||
|
||||
@@ -1096,6 +1159,14 @@ export default function DeviceStatusPage() {
|
||||
}
|
||||
extra={
|
||||
<Space size={4}>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon={<EnvironmentOutlined />}
|
||||
onClick={handleFindCar}
|
||||
>
|
||||
{t('devices.features.findCar')}
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
@@ -1297,7 +1368,10 @@ export default function DeviceStatusPage() {
|
||||
|
||||
{/* 倒车影像叠加层:根据方向盘 xy 显示转向辅助线 */}
|
||||
{/*{isVideoPlaying && (*/}
|
||||
<ReverseCameraOverlay x={steerXY.x} y={steerXY.y} visible={true} />
|
||||
{/*<CarReverseGuideLine direction={direction} steer={steer} />*/}
|
||||
|
||||
|
||||
{/*<ReverseCameraOverlay x={steerXY.x} y={steerXY.y} visible={true} />*/}
|
||||
{/*//)}*/}
|
||||
|
||||
{/* 视频未加载 / 停止播放的占位 */}
|
||||
@@ -1395,6 +1469,14 @@ export default function DeviceStatusPage() {
|
||||
}
|
||||
extra={
|
||||
<Space size={4}>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon={<EnvironmentOutlined />}
|
||||
onClick={handleFindCar}
|
||||
>
|
||||
{t('devices.features.findCar')}
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
|
||||
Reference in New Issue
Block a user