机器状态页面 样式优化 对接新的 设备状态数据 ,xbox和 方向盘 需要 互斥控制 中英文优化,方向盘加入 点火熄火等功能,等待对接状态和远程控制和倒车影像
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { ChevronUp, ChevronDown, ChevronLeft, ChevronRight, Circle } from 'lucide-react';
|
import { ChevronUp, ChevronDown, ChevronLeft, ChevronRight, Circle, ShieldAlert } from 'lucide-react';
|
||||||
|
|
||||||
export interface GamepadState {
|
export interface GamepadState {
|
||||||
buttons: boolean[];
|
buttons: boolean[];
|
||||||
@@ -13,6 +13,7 @@ interface DPadControlProps {
|
|||||||
onGamepadUpdate?: (state: GamepadState) => void;
|
onGamepadUpdate?: (state: GamepadState) => void;
|
||||||
onSpeedChange?: (speed: number) => void;
|
onSpeedChange?: (speed: number) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
onEmergencyStop?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 键盘按键映射
|
// 键盘按键映射
|
||||||
@@ -31,7 +32,7 @@ const KEY_MAP: Record<string, string> = {
|
|||||||
D: 'right',
|
D: 'right',
|
||||||
};
|
};
|
||||||
|
|
||||||
const DPadControl: React.FC<DPadControlProps> = ({ onGamepadUpdate, onSpeedChange, disabled = false }) => {
|
const DPadControl: React.FC<DPadControlProps> = ({ onGamepadUpdate, onSpeedChange, disabled = false, onEmergencyStop }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [pressed, setPressed] = useState<Record<string, boolean>>({});
|
const [pressed, setPressed] = useState<Record<string, boolean>>({});
|
||||||
const [speed, setSpeed] = useState(0.5);
|
const [speed, setSpeed] = useState(0.5);
|
||||||
@@ -181,6 +182,29 @@ const DPadControl: React.FC<DPadControlProps> = ({ onGamepadUpdate, onSpeedChang
|
|||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const startEmergency = () => {
|
||||||
|
if (disabled) return;
|
||||||
|
pressedRef.current = { ...pressedRef.current, center: true };
|
||||||
|
setPressed(pressedRef.current);
|
||||||
|
onEmergencyStop?.();
|
||||||
|
window.setTimeout(() => {
|
||||||
|
pressedRef.current = { ...pressedRef.current, center: false };
|
||||||
|
setPressed(pressedRef.current);
|
||||||
|
}, 350);
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderEmergency = () => (
|
||||||
|
<button
|
||||||
|
aria-label={t('devices.emergencyStop')}
|
||||||
|
disabled={disabled}
|
||||||
|
className={`${btnBase} ${pressed.center ? 'border-red-500 bg-red-500/40 text-white shadow-[0_0_16px_rgba(239,68,68,0.6)]' : 'border-red-500/70 bg-red-500/10 text-red-400 hover:bg-red-500/20'} ${disabled ? 'opacity-40 cursor-not-allowed' : 'cursor-pointer'}`}
|
||||||
|
onClick={() => startEmergency()}
|
||||||
|
onTouchStart={(e) => { e.preventDefault(); startEmergency(); }}
|
||||||
|
>
|
||||||
|
<ShieldAlert className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center gap-1 w-full">
|
<div className="flex flex-col items-center gap-1 w-full">
|
||||||
{/* 十字方向键 */}
|
{/* 十字方向键 */}
|
||||||
@@ -189,7 +213,7 @@ const DPadControl: React.FC<DPadControlProps> = ({ onGamepadUpdate, onSpeedChang
|
|||||||
{renderBtn('up', <ChevronUp className="w-6 h-6" />, t('devices.dpad.up'))}
|
{renderBtn('up', <ChevronUp className="w-6 h-6" />, t('devices.dpad.up'))}
|
||||||
<div />
|
<div />
|
||||||
{renderBtn('left', <ChevronLeft className="w-6 h-6" />, t('devices.dpad.left'))}
|
{renderBtn('left', <ChevronLeft className="w-6 h-6" />, t('devices.dpad.left'))}
|
||||||
{renderBtn('center', <Circle className="w-5 h-5 fill-current" />, t('devices.dpad.center'))}
|
{onEmergencyStop ? renderEmergency() : renderBtn('center', <Circle className="w-5 h-5 fill-current" />, t('devices.dpad.center'))}
|
||||||
{renderBtn('right', <ChevronRight className="w-6 h-6" />, t('devices.dpad.right'))}
|
{renderBtn('right', <ChevronRight className="w-6 h-6" />, t('devices.dpad.right'))}
|
||||||
<div />
|
<div />
|
||||||
{renderBtn('down', <ChevronDown className="w-6 h-6" />, t('devices.dpad.down'))}
|
{renderBtn('down', <ChevronDown className="w-6 h-6" />, t('devices.dpad.down'))}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,6 @@ export type RobotFeature =
|
|||||||
| 'findCar'
|
| 'findCar'
|
||||||
| 'autoback';
|
| 'autoback';
|
||||||
|
|
||||||
|
|
||||||
export interface FeatureConfig {
|
export interface FeatureConfig {
|
||||||
key: RobotFeature;
|
key: RobotFeature;
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
@@ -28,71 +27,86 @@ export interface FeatureConfig {
|
|||||||
inactiveColor: string;
|
inactiveColor: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 功能方块:方块样式展示,不再包含急停(急停已移至方向盘中键)
|
||||||
const FEATURES: FeatureConfig[] = [
|
const FEATURES: FeatureConfig[] = [
|
||||||
{ key: 'emergencyStop', icon: <ShieldAlert className="w-5 h-5" />, activeColor: '#ef4444', inactiveColor: '#94a3b8' },
|
{ key: 'obstacleAvoidance', icon: <Siren className="w-6 h-6" />, activeColor: '#3b82f6', inactiveColor: '#94a3b8' },
|
||||||
{ key: 'obstacleAvoidance', icon: <Siren className="w-5 h-5" />, activeColor: '#3b82f6', inactiveColor: '#94a3b8' },
|
{ key: 'lowBatteryReturn', icon: <BatteryWarning className="w-6 h-6" />, activeColor: '#f59e0b', inactiveColor: '#94a3b8' },
|
||||||
{ key: 'lowBatteryReturn', icon: <BatteryWarning className="w-5 h-5" />, activeColor: '#f59e0b', inactiveColor: '#94a3b8' },
|
{ key: 'tiltProtection', icon: <MoveVertical className="w-6 h-6" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
|
||||||
{ key: 'tiltProtection', icon: <MoveVertical className="w-5 h-5" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
|
{ key: 'autoback', icon: <Zap className="w-6 h-6" />, activeColor: '#22c55e', inactiveColor: '#94a3b8' },
|
||||||
//{ key: 'findCar', icon: <Zap className="w-5 h-5" />, activeColor: '#22c55e', inactiveColor: '#c4158c' },
|
{ key: 'findCar', icon: <ShieldAlert className="w-6 h-6" />, activeColor: '#ef4444', inactiveColor: '#94a3b8' },
|
||||||
{ key: 'autoback', icon: <Zap className="w-5 h-5" />, activeColor: '#22c55e', inactiveColor: '#133c75' },
|
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// 急停方块(仅在 showEmergencyStop 时展示,兼容其他页面)
|
||||||
|
const EMERGENCY: FeatureConfig = {
|
||||||
|
key: 'emergencyStop',
|
||||||
|
icon: <ShieldAlert className="w-6 h-6" />,
|
||||||
|
activeColor: '#ef4444',
|
||||||
|
inactiveColor: '#ef4444',
|
||||||
|
};
|
||||||
|
|
||||||
interface RobotFeatureButtonsProps {
|
interface RobotFeatureButtonsProps {
|
||||||
activeFeatures?: RobotFeature[];
|
activeFeatures?: RobotFeature[];
|
||||||
onToggle?: (feature: RobotFeature, enabled: boolean) => void;
|
onToggle?: (feature: RobotFeature, enabled: boolean) => void;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
showEmergencyStop?: boolean;
|
||||||
|
sendFindCar: () => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||||
activeFeatures = [],
|
activeFeatures = [],
|
||||||
onToggle,
|
onToggle,
|
||||||
className = '',
|
className = '',
|
||||||
|
showEmergencyStop = true,
|
||||||
|
sendFindCar,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||||
const [active, setActive] = useState<Set<RobotFeature>>(new Set(activeFeatures));
|
const [active, setActive] = useState<Set<RobotFeature>>(new Set(activeFeatures));
|
||||||
|
|
||||||
|
const list = showEmergencyStop ? [EMERGENCY, ...FEATURES] : FEATURES;
|
||||||
|
|
||||||
const handleClick = (feature: RobotFeature) => {
|
const handleClick = (feature: RobotFeature) => {
|
||||||
|
// 急停:点击时直接下发 button7(绕过控制权限校验)
|
||||||
|
if (feature === 'emergencyStop') {
|
||||||
|
sendEmergencyStop(userInfo);
|
||||||
|
onToggle?.(feature, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 寻车:下发指令的同时,与其他功能一样切换选中状态(toggle 效果)
|
||||||
|
if (feature === 'findCar') {
|
||||||
|
sendFindCar?.();
|
||||||
|
}
|
||||||
const next = !active.has(feature);
|
const next = !active.has(feature);
|
||||||
const nextSet = new Set(active);
|
const nextSet = new Set(active);
|
||||||
if (next) nextSet.add(feature);
|
if (next) nextSet.add(feature);
|
||||||
else nextSet.delete(feature);
|
else nextSet.delete(feature);
|
||||||
setActive(nextSet);
|
setActive(nextSet);
|
||||||
// 急停:点击时直接下发 button7(绕过控制权限校验)
|
|
||||||
if (feature === 'emergencyStop') sendEmergencyStop(userInfo);
|
|
||||||
onToggle?.(feature, next);
|
onToggle?.(feature, next);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex flex-wrap gap-2 ${className}`}>
|
<div className={`flex gap-2 w-full ${className}`}>
|
||||||
{FEATURES.map((f) => {
|
{list.map((f) => {
|
||||||
const isActive = active.has(f.key);
|
const isActive = active.has(f.key);
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={f.key}
|
key={f.key}
|
||||||
onClick={() => handleClick(f.key)}
|
onClick={() => handleClick(f.key)}
|
||||||
className={`flex items-center gap-1 px-1 py-1 rounded-lg border transition-all duration-200 select-none
|
className="flex flex-col items-center justify-center gap-1.5 rounded-lg border transition-all duration-200 select-none hover:shadow-md"
|
||||||
${isActive
|
|
||||||
? 'border-current shadow-lg'
|
|
||||||
: 'border-slate-700 hover:border-slate-500'
|
|
||||||
}`}
|
|
||||||
style={{
|
style={{
|
||||||
|
aspectRatio: '1 / 1',
|
||||||
|
height: 64,
|
||||||
color: isActive ? f.activeColor : f.inactiveColor,
|
color: isActive ? f.activeColor : f.inactiveColor,
|
||||||
backgroundColor: isActive ? `${f.activeColor}1a` : 'transparent',
|
backgroundColor: isActive ? `${f.activeColor}1a` : '#fafafa',
|
||||||
|
borderColor: isActive ? f.activeColor : '#e5e7eb',
|
||||||
boxShadow: isActive ? `0 0 12px ${f.activeColor}33` : 'none',
|
boxShadow: isActive ? `0 0 12px ${f.activeColor}33` : 'none',
|
||||||
}}
|
}}
|
||||||
title={t(`devices.features.${f.key}`)}
|
title={t(`devices.features.${f.key}`)}
|
||||||
>
|
>
|
||||||
<span className="flex items-center justify-center">{f.icon}</span>
|
<span className="flex items-center justify-center">{f.icon}</span>
|
||||||
<span className="text-xs font-medium whitespace-nowrap">
|
<span className="text-xs font-medium text-center leading-tight px-1" style={{ color: isActive ? f.activeColor : '#595959' }}>
|
||||||
{t(`devices.features.${f.key}`)}
|
{t(`devices.features.${f.key}`)}
|
||||||
</span>
|
</span>
|
||||||
<span
|
|
||||||
className="ml-1 w-2 h-2 rounded-full transition-all"
|
|
||||||
style={{ backgroundColor: isActive ? f.activeColor : '#475569' }}
|
|
||||||
/>
|
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
153
src/components/devices/Steerbutton.tsx
Normal file
153
src/components/devices/Steerbutton.tsx
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
|
interface SteerButtonProps {
|
||||||
|
icon: React.ReactNode;
|
||||||
|
label: string;
|
||||||
|
color: string;
|
||||||
|
onPressStart?: () => void;
|
||||||
|
onPressEnd?: () => void;
|
||||||
|
interval?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SteerButton = ({
|
||||||
|
icon,
|
||||||
|
label,
|
||||||
|
color,
|
||||||
|
onPressStart,
|
||||||
|
onPressEnd,
|
||||||
|
interval = 100,
|
||||||
|
}: SteerButtonProps) => {
|
||||||
|
const [pressed, setPressed] = useState(false);
|
||||||
|
|
||||||
|
// 是否处于按下状态
|
||||||
|
const holdingRef = useRef(false);
|
||||||
|
|
||||||
|
// 定时发送句柄
|
||||||
|
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
|
// 保存最新的回调,避免定时器使用过期闭包
|
||||||
|
const onPressStartRef = useRef(onPressStart);
|
||||||
|
const onPressEndRef = useRef(onPressEnd);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onPressStartRef.current = onPressStart;
|
||||||
|
}, [onPressStart]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onPressEndRef.current = onPressEnd;
|
||||||
|
}, [onPressEnd]);
|
||||||
|
|
||||||
|
// 停止长按
|
||||||
|
const stopHold = useCallback(() => {
|
||||||
|
if (!holdingRef.current) return;
|
||||||
|
|
||||||
|
holdingRef.current = false;
|
||||||
|
|
||||||
|
if (timerRef.current !== null) {
|
||||||
|
clearTimeout(timerRef.current);
|
||||||
|
timerRef.current = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPressed(false);
|
||||||
|
|
||||||
|
// 只在有效按压结束时发送一次释放数据
|
||||||
|
onPressEndRef.current?.();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 开始长按
|
||||||
|
const startHold = useCallback(() => {
|
||||||
|
// 防止重复触发
|
||||||
|
if (holdingRef.current) return;
|
||||||
|
|
||||||
|
holdingRef.current = true;
|
||||||
|
setPressed(true);
|
||||||
|
|
||||||
|
// 立即发送第一帧
|
||||||
|
onPressStartRef.current?.();
|
||||||
|
|
||||||
|
// 持续发送
|
||||||
|
const scheduleNext = () => {
|
||||||
|
if (!holdingRef.current) return;
|
||||||
|
|
||||||
|
timerRef.current = setTimeout(() => {
|
||||||
|
if (!holdingRef.current) return;
|
||||||
|
|
||||||
|
onPressStartRef.current?.();
|
||||||
|
|
||||||
|
scheduleNext();
|
||||||
|
}, interval);
|
||||||
|
};
|
||||||
|
|
||||||
|
scheduleNext();
|
||||||
|
}, [interval]);
|
||||||
|
|
||||||
|
// 组件卸载时清理定时器
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
holdingRef.current = false;
|
||||||
|
|
||||||
|
if (timerRef.current !== null) {
|
||||||
|
clearTimeout(timerRef.current);
|
||||||
|
timerRef.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={label}
|
||||||
|
aria-pressed={pressed}
|
||||||
|
onPointerDown={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
// 仅响应鼠标左键,触摸和笔不受影响
|
||||||
|
if (e.pointerType === 'mouse' && e.button !== 0) return;
|
||||||
|
|
||||||
|
// 捕获指针,确保在按钮外松开也能收到事件
|
||||||
|
e.currentTarget.setPointerCapture(e.pointerId);
|
||||||
|
|
||||||
|
startHold();
|
||||||
|
}}
|
||||||
|
onPointerUp={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
stopHold();
|
||||||
|
}}
|
||||||
|
onPointerCancel={stopHold}
|
||||||
|
onLostPointerCapture={stopHold}
|
||||||
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
|
style={{
|
||||||
|
flex: '1 1 0',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: 4,
|
||||||
|
minHeight: 46,
|
||||||
|
padding: '6px 4px',
|
||||||
|
borderRadius: 8,
|
||||||
|
background: pressed ? `${color}30` : '#1e293b',
|
||||||
|
border: `1px solid ${pressed ? color : `${color}55`}`,
|
||||||
|
color,
|
||||||
|
cursor: 'pointer',
|
||||||
|
userSelect: 'none',
|
||||||
|
touchAction: 'none',
|
||||||
|
transform: pressed ? 'scale(0.94)' : 'scale(1)',
|
||||||
|
boxShadow: pressed ? `0 0 14px ${color}66` : 'none',
|
||||||
|
transition:
|
||||||
|
'transform .08s, background .12s, border-color .12s, box-shadow .12s',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span style={{ display: 'inline-flex', fontSize: 16, lineHeight: 1 }}>
|
||||||
|
{icon}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span style={{ fontSize: 11, fontWeight: 600, whiteSpace: 'nowrap' }}>
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default SteerButton;
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useEffect, useState, useRef } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
const XboxController = ({ onGamepadUpdate, onConnectionChange }) => {
|
||||||
const XboxController = ({ onGamepadUpdate }) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [gamepadState, setGamepadState] = useState<{
|
const [gamepadState, setGamepadState] = useState<{
|
||||||
buttons: boolean[];
|
buttons: boolean[];
|
||||||
@@ -12,22 +11,20 @@ const XboxController = ({ onGamepadUpdate }) => {
|
|||||||
axes: [0, 0, 0, 0],
|
axes: [0, 0, 0, 0],
|
||||||
connected: false,
|
connected: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const requestRef = useRef<number>(null);
|
const requestRef = useRef<number>(null);
|
||||||
// 用 ref 保存最新的回调,避免 RAF 循环闭包捕获旧 props 导致权限判断失效
|
// 用 ref 保存最新的回调,避免 RAF 循环闭包捕获旧 props 导致权限判断失效
|
||||||
const onGamepadUpdateRef = useRef(onGamepadUpdate);
|
const onGamepadUpdateRef = useRef(onGamepadUpdate);
|
||||||
onGamepadUpdateRef.current = onGamepadUpdate;
|
onGamepadUpdateRef.current = onGamepadUpdate;
|
||||||
|
const onConnectionChangeRef = useRef(onConnectionChange);
|
||||||
|
onConnectionChangeRef.current = onConnectionChange;
|
||||||
const DEAD_ZONE = 0.08;
|
const DEAD_ZONE = 0.08;
|
||||||
|
|
||||||
const normalizeAxis = (v: number) =>
|
const normalizeAxis = (v: number) =>
|
||||||
Math.abs(v) < DEAD_ZONE ? 0 : Number(v.toFixed(2));
|
Math.abs(v) < DEAD_ZONE ? 0 : Number(v.toFixed(2));
|
||||||
const lastSendRef = useRef(0);
|
const lastSendRef = useRef(0);
|
||||||
const SEND_INTERVAL = 1000 / 10; // 20Hz
|
const SEND_INTERVAL = 1000 / 10; // 20Hz
|
||||||
const lastPayloadRef = useRef('');
|
const lastPayloadRef = useRef('');
|
||||||
|
|
||||||
const updateGamepad = () => {
|
const updateGamepad = () => {
|
||||||
const gp = navigator.getGamepads()[0];
|
const gp = navigator.getGamepads()[0];
|
||||||
|
|
||||||
if (gp) {
|
if (gp) {
|
||||||
const state = {
|
const state = {
|
||||||
buttons: gp.buttons.map(b => b.pressed),
|
buttons: gp.buttons.map(b => b.pressed),
|
||||||
@@ -35,16 +32,12 @@ const XboxController = ({ onGamepadUpdate }) => {
|
|||||||
connected: true,
|
connected: true,
|
||||||
ts: Date.now(),
|
ts: Date.now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
setGamepadState(state);
|
setGamepadState(state);
|
||||||
|
|
||||||
const payload = JSON.stringify({
|
const payload = JSON.stringify({
|
||||||
buttons: state.buttons,
|
buttons: state.buttons,
|
||||||
axes: state.axes,
|
axes: state.axes,
|
||||||
});
|
});
|
||||||
|
|
||||||
const now = performance.now();
|
const now = performance.now();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
now - lastSendRef.current > SEND_INTERVAL
|
now - lastSendRef.current > SEND_INTERVAL
|
||||||
// payload !== lastPayloadRef.current
|
// payload !== lastPayloadRef.current
|
||||||
@@ -59,74 +52,54 @@ const XboxController = ({ onGamepadUpdate }) => {
|
|||||||
requestRef.current = requestAnimationFrame(updateGamepad);
|
requestRef.current = requestAnimationFrame(updateGamepad);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestRef.current = requestAnimationFrame(updateGamepad);
|
requestRef.current = requestAnimationFrame(updateGamepad);
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
requestRef.current = requestAnimationFrame(updateGamepad);
|
requestRef.current = requestAnimationFrame(updateGamepad);
|
||||||
|
|
||||||
const onFocus = () => {
|
const onFocus = () => {
|
||||||
// 页面重新获得焦点 → 立刻重拉一次
|
// 页面重新获得焦点 → 立刻重拉一次
|
||||||
requestRef.current = requestAnimationFrame(updateGamepad);
|
requestRef.current = requestAnimationFrame(updateGamepad);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('focus', onFocus);
|
window.addEventListener('focus', onFocus);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (requestRef.current) cancelAnimationFrame(requestRef.current);
|
if (requestRef.current) cancelAnimationFrame(requestRef.current);
|
||||||
window.removeEventListener('focus', onFocus);
|
window.removeEventListener('focus', onFocus);
|
||||||
};
|
};
|
||||||
}, []); // ✅ 空依赖
|
}, []); // ✅ 空依赖
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.focus();
|
window.focus();
|
||||||
navigator.getGamepads(); // 🔥 强制触发一次
|
navigator.getGamepads(); // 🔥 强制触发一次
|
||||||
}, 0);
|
}, 0);
|
||||||
}, [/* 页面切换依赖 */]);
|
}, [/* 页面切换依赖 */]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleConnect = (e: GamepadEvent) => {
|
const handleConnect = (e: GamepadEvent) => {
|
||||||
console.log('🎮 Gamepad connected:', e.gamepad.id);
|
console.log('🎮 Gamepad connected:', e.gamepad.id);
|
||||||
setGamepadState(prev => ({ ...prev, connected: true }));
|
setGamepadState(prev => ({ ...prev, connected: true }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDisconnect = (e: GamepadEvent) => {
|
const handleDisconnect = (e: GamepadEvent) => {
|
||||||
console.log('❌ Gamepad disconnected');
|
console.log('❌ Gamepad disconnected');
|
||||||
//handleControlModal({ control: false });
|
//handleControlModal({ control: false });
|
||||||
setGamepadState(prev => ({ ...prev, connected: false }));
|
setGamepadState(prev => ({ ...prev, connected: false }));
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('gamepadconnected', handleConnect);
|
window.addEventListener('gamepadconnected', handleConnect);
|
||||||
window.addEventListener('gamepaddisconnected', handleDisconnect);
|
window.addEventListener('gamepaddisconnected', handleDisconnect);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('gamepadconnected', handleConnect);
|
window.removeEventListener('gamepadconnected', handleConnect);
|
||||||
window.removeEventListener('gamepaddisconnected', handleDisconnect);
|
window.removeEventListener('gamepaddisconnected', handleDisconnect);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// UI mapping for Xbox Gamepad
|
// UI mapping for Xbox Gamepad
|
||||||
|
//点火熄火 上面俩 AB升降底盘 XY割刀加减速 button8急停 BUTTON4点火 BUTTON5熄火
|
||||||
//点火熄火 上面俩 AB升降底盘 XY割刀加减速 button7急停
|
|
||||||
// Buttons: 0:A, 1:B, 2:X, 3:Y, 4:LB, 5:RB, 6:LT, 7:RT, 8:Back, 9:Start, 10:LS, 11:RS, 12:Up, 13:Down, 14:Left, 15:Right
|
|
||||||
const { buttons, axes, connected } = gamepadState;
|
const { buttons, axes, connected } = gamepadState;
|
||||||
|
|
||||||
const getAxisStyle = (axisX: number, axisY: number) => ({
|
const getAxisStyle = (axisX: number, axisY: number) => ({
|
||||||
transform: `translate(${axisX * 6}px, ${axisY * 6}px)`,
|
transform: `translate(${axisX * 6}px, ${axisY * 6}px)`,
|
||||||
});
|
});
|
||||||
|
useEffect(() => {
|
||||||
|
onConnectionChangeRef.current?.(gamepadState.connected);
|
||||||
|
}, [gamepadState.connected]);
|
||||||
return (
|
return (
|
||||||
<div className="relative h-[252px] aspect-[4/3] flex items-center justify-center">
|
<div className="relative h-[252px] aspect-[4/3] flex items-center justify-center">
|
||||||
{/* 手柄硬件连接状态指示(仅表示物理手柄是否连接) */}
|
|
||||||
<div
|
|
||||||
className={`absolute top-0 right-0 px-2 py-0.5 rounded text-[8px] font-bold tracking-widest border ${connected
|
|
||||||
? 'bg-cyan-500/20 text-cyan-400 border-cyan-500/30'
|
|
||||||
: 'bg-slate-800 text-slate-500 border-white/5'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{connected ? t('devices.controllerConnected') : t('devices.controllerNotConnected')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<svg viewBox="0 0 400 300" className="w-full h-full drop-shadow-[0_0_20px_rgba(34,211,238,0.15)]">
|
<svg viewBox="0 0 400 300" className="w-full h-full drop-shadow-[0_0_20px_rgba(34,211,238,0.15)]">
|
||||||
{/* Main Body */}
|
{/* Main Body */}
|
||||||
@@ -138,22 +111,23 @@ const XboxController = ({ onGamepadUpdate }) => {
|
|||||||
transform="scale(1, 1.08)"
|
transform="scale(1, 1.08)"
|
||||||
transformOrigin="200px 180px"
|
transformOrigin="200px 180px"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Triggers & Bumpers */}
|
{/* Triggers & Bumpers */}
|
||||||
|
|
||||||
<rect x="70" y="50" width="50" height="25" rx="5" fill={buttons[4] ? "#22d3ee" : "#0f172a"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[4] ? 1 : 0.3} />
|
<rect x="70" y="50" width="50" height="25" rx="5" fill={buttons[4] ? "#22d3ee" : "#0f172a"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[4] ? 1 : 0.3} />
|
||||||
|
<text x="95" y="66" textAnchor="middle" fill={buttons[4] ? "#fff" : "#15414b"} fontSize="12" fontWeight="bold">LB</text>
|
||||||
<rect x="280" y="50" width="50" height="25" rx="5" fill={buttons[5] ? "#22d3ee" : "#0f172a"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[5] ? 1 : 0.3} />
|
<rect x="280" y="50" width="50" height="25" rx="5" fill={buttons[5] ? "#22d3ee" : "#0f172a"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[5] ? 1 : 0.3} />
|
||||||
|
<text x="305" y="66" textAnchor="middle" fill={buttons[5] ? "#fff" : "#15414b"} fontSize="12" fontWeight="bold">RB</text>
|
||||||
|
{/* 左右耳朵标识:左=点火 右=熄火 */}
|
||||||
|
|
||||||
{/* LT / RT Indicators */}
|
{/* LT / RT Indicators */}
|
||||||
<path d="M80 30 L110 30 Q115 45 95 50 L80 50 Z" fill={buttons[6] ? "#22d3ee" : "transparent"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[6] ? 1 : 0.2} />
|
<path d="M80 30 L110 30 Q115 45 95 50 L80 50 Z" fill={buttons[6] ? "#22d3ee" : "transparent"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[6] ? 1 : 0.2} />
|
||||||
<path d="M320 30 L290 30 Q285 45 305 50 L320 50 Z" fill={buttons[7] ? "#22d3ee" : "transparent"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[7] ? 1 : 0.2} />
|
<path d="M320 30 L290 30 Q285 45 305 50 L320 50 Z" fill={buttons[7] ? "#22d3ee" : "transparent"} stroke="#22d3ee" strokeWidth="1" opacity={buttons[7] ? 1 : 0.2} />
|
||||||
|
|
||||||
{/* Left Stick Area */}
|
{/* Left Stick Area */}
|
||||||
<circle cx="120" cy="140" r="35" fill="#0f172a" stroke="#22d3ee" strokeWidth="1" strokeDasharray="2 2" />
|
<circle cx="120" cy="140" r="35" fill="#0f172a" stroke="#22d3ee" strokeWidth="1" strokeDasharray="2 2" />
|
||||||
<g style={getAxisStyle(axes[0] || 0, axes[1] || 0)}>
|
<g style={getAxisStyle(axes[0] || 0, axes[1] || 0)}>
|
||||||
<circle cx="120" cy="140" r="28" fill="#1e293b" stroke="#22d3ee" strokeWidth="2" />
|
<circle cx="120" cy="140" r="28" fill="#1e293b" stroke="#22d3ee" strokeWidth="2" />
|
||||||
<circle cx="120" cy="140" r="12" fill={buttons[10] ? "#22d3ee" : "transparent"} stroke="#22d3ee" strokeWidth="1" />
|
<circle cx="120" cy="140" r="12" fill={buttons[10] ? "#22d3ee" : "transparent"} stroke="#22d3ee" strokeWidth="1" />
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
{/* Right Stick Area */}
|
{/* Right Stick Area */}
|
||||||
<g transform="translate(0, 20)">
|
<g transform="translate(0, 20)">
|
||||||
<circle
|
<circle
|
||||||
@@ -165,7 +139,6 @@ const XboxController = ({ onGamepadUpdate }) => {
|
|||||||
strokeWidth="1"
|
strokeWidth="1"
|
||||||
strokeDasharray="2 2"
|
strokeDasharray="2 2"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<g style={getAxisStyle(axes[2] || 0, axes[3] || 0)}>
|
<g style={getAxisStyle(axes[2] || 0, axes[3] || 0)}>
|
||||||
<circle
|
<circle
|
||||||
cx="280"
|
cx="280"
|
||||||
@@ -185,7 +158,6 @@ const XboxController = ({ onGamepadUpdate }) => {
|
|||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
{/* D-Pad */}
|
{/* D-Pad */}
|
||||||
<g transform="translate(130, 220)">
|
<g transform="translate(130, 220)">
|
||||||
<path d="M0 -25 L0 25 M-25 0 L25 0" stroke="#334155" strokeWidth="15" strokeLinecap="round" />
|
<path d="M0 -25 L0 25 M-25 0 L25 0" stroke="#334155" strokeWidth="15" strokeLinecap="round" />
|
||||||
@@ -194,21 +166,28 @@ const XboxController = ({ onGamepadUpdate }) => {
|
|||||||
<path d="M-25 0 L-10 0" stroke={buttons[14] ? "#22d3ee" : "#64748b"} strokeWidth="12" strokeLinecap="round" />
|
<path d="M-25 0 L-10 0" stroke={buttons[14] ? "#22d3ee" : "#64748b"} strokeWidth="12" strokeLinecap="round" />
|
||||||
<path d="M25 0 L10 0" stroke={buttons[15] ? "#22d3ee" : "#64748b"} strokeWidth="12" strokeLinecap="round" />
|
<path d="M25 0 L10 0" stroke={buttons[15] ? "#22d3ee" : "#64748b"} strokeWidth="12" strokeLinecap="round" />
|
||||||
</g>
|
</g>
|
||||||
|
{/* Buttons (ABXY) + Text Label */}
|
||||||
{/* Buttons (ABXY) */}
|
|
||||||
<g transform="translate(280, 140)">
|
<g transform="translate(280, 140)">
|
||||||
<circle cx="0" cy="20" r="12" fill={buttons[0] ? "#22c55e" : "#0f172a"} stroke="#22c55e" strokeWidth="1" opacity={buttons[0] ? 1 : 0.6} /> {/* A */}
|
<circle cx="0" cy="20" r="12" fill={buttons[0] ? "#22c55e" : "#0f172a"} stroke="#22c55e" strokeWidth="1" opacity={buttons[0] ? 1 : 0.6} /> {/* A */}
|
||||||
<circle cx="20" cy="0" r="12" fill={buttons[1] ? "#ef4444" : "#0f172a"} stroke="#ef4444" strokeWidth="1" opacity={buttons[1] ? 1 : 0.6} /> {/* B */}
|
<text x="0" y="24" textAnchor="middle" fill={buttons[0] ? "#fff" : "#22c55e"} fontSize="14" fontWeight="bold">A</text>
|
||||||
<circle cx="-20" cy="0" r="12" fill={buttons[2] ? "#3b82f6" : "#0f172a"} stroke="#3b82f6" strokeWidth="1" opacity={buttons[2] ? 1 : 0.6} /> {/* X */}
|
|
||||||
<circle cx="0" cy="-20" r="12" fill={buttons[3] ? "#eab308" : "#0f172a"} stroke="#eab308" strokeWidth="1" opacity={buttons[3] ? 1 : 0.6} /> {/* Y */}
|
|
||||||
</g>
|
|
||||||
|
|
||||||
{/* Menu Buttons */}
|
<circle cx="20" cy="0" r="12" fill={buttons[1] ? "#ef4444" : "#0f172a"} stroke="#ef4444" strokeWidth="1" opacity={buttons[1] ? 1 : 0.6} /> {/* B */}
|
||||||
|
<text x="20" y="4" textAnchor="middle" fill={buttons[1] ? "#fff" : "#ef4444"} fontSize="14" fontWeight="bold">B</text>
|
||||||
|
|
||||||
|
<circle cx="-20" cy="0" r="12" fill={buttons[2] ? "#3b82f6" : "#0f172a"} stroke="#3b82f6" strokeWidth="1" opacity={buttons[2] ? 1 : 0.6} /> {/* X */}
|
||||||
|
<text x="-20" y="4" textAnchor="middle" fill={buttons[2] ? "#fff" : "#3b82f6"} fontSize="14" fontWeight="bold">X</text>
|
||||||
|
|
||||||
|
<circle cx="0" cy="-20" r="12" fill={buttons[3] ? "#eab308" : "#0f172a"} stroke="#eab308" strokeWidth="1" opacity={buttons[3] ? 1 : 0.6} /> {/* Y */}
|
||||||
|
<text x="0" y="-16" textAnchor="middle" fill={buttons[3] ? "#fff" : "#eab308"} fontSize="14" fontWeight="bold">Y</text>
|
||||||
|
</g>
|
||||||
|
{/* Menu Buttons + Text Label button8=急停, button9=Menu */}
|
||||||
<circle cx="180" cy="140" r="6" fill={buttons[8] ? "#22d3ee" : "#334155"} />
|
<circle cx="180" cy="140" r="6" fill={buttons[8] ? "#22d3ee" : "#334155"} />
|
||||||
|
<text x="180" y="152" textAnchor="middle" fill={buttons[8] ? "#22d3ee" : "#64748b"} fontSize="9" fontWeight="bold">急停</text>
|
||||||
|
|
||||||
<circle cx="220" cy="140" r="6" fill={buttons[9] ? "#22d3ee" : "#334155"} />
|
<circle cx="220" cy="140" r="6" fill={buttons[9] ? "#22d3ee" : "#334155"} />
|
||||||
|
<text x="220" y="152" textAnchor="middle" fill={buttons[9] ? "#22d3ee" : "#64748b"} fontSize="9" fontWeight="bold">Menu</text>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default XboxController;
|
export default XboxController;
|
||||||
|
|||||||
@@ -286,7 +286,7 @@
|
|||||||
idle: 'Idle',
|
idle: 'Idle',
|
||||||
busy: 'Busy',
|
busy: 'Busy',
|
||||||
error: 'Error',
|
error: 'Error',
|
||||||
deviceControl: 'Device Control',
|
deviceControl: 'Robot Control',
|
||||||
realtimeVideo: 'Live Video',
|
realtimeVideo: 'Live Video',
|
||||||
takeoff: 'Take Off',
|
takeoff: 'Take Off',
|
||||||
land: 'Land',
|
land: 'Land',
|
||||||
@@ -632,6 +632,57 @@
|
|||||||
landingDockSnLabel: 'Landing Dock Sn Label',
|
landingDockSnLabel: 'Landing Dock Sn Label',
|
||||||
leftView: 'Left View',
|
leftView: 'Left View',
|
||||||
leftWheelDrive: 'Left Wheel Drive',
|
leftWheelDrive: 'Left Wheel Drive',
|
||||||
|
gamepadControl: 'Gamepad Control',
|
||||||
|
steeringControl: 'Steering Control',
|
||||||
|
disconnectGamepadFirst: 'Please disconnect the gamepad first',
|
||||||
|
liveBadge: 'Live',
|
||||||
|
totalWorkArea: 'Total Work Area',
|
||||||
|
totalWorkDuration: 'Total Work Duration',
|
||||||
|
totalWorkDistance: 'Total Work Distance',
|
||||||
|
motionStatus: 'Motion Status',
|
||||||
|
motionMoving: 'Moving',
|
||||||
|
motionStopped: 'Stopped',
|
||||||
|
motionBlocked: 'Blocked',
|
||||||
|
rtEmergency: 'Emergency Stop',
|
||||||
|
estopTriggered: 'Triggered',
|
||||||
|
estopNormal: 'Normal',
|
||||||
|
rtLeftTargetRpm: 'Left Target RPM',
|
||||||
|
rtRightTargetRpm: 'Right Target RPM',
|
||||||
|
rtLeftMeasureRpm: 'Left Measured RPM',
|
||||||
|
rtRightMeasureRpm: 'Right Measured RPM',
|
||||||
|
rtLeftMotorRpm: 'Left Motor RPM',
|
||||||
|
rtRightMotorRpm: 'Right Motor RPM',
|
||||||
|
gamepad: {
|
||||||
|
leftStick: 'Left Stick',
|
||||||
|
leftStickDesc: 'Control direction',
|
||||||
|
rightStick: 'Right Stick',
|
||||||
|
rightStickDesc: 'Control arm',
|
||||||
|
aKey: 'A Key',
|
||||||
|
aKeyDesc: 'Raise chassis',
|
||||||
|
bKey: 'B Key',
|
||||||
|
bKeyDesc: 'Lower chassis',
|
||||||
|
xKey: 'X Key',
|
||||||
|
xKeyDesc: 'Cutter faster',
|
||||||
|
yKey: 'Y Key',
|
||||||
|
yKeyDesc: 'Cutter slower',
|
||||||
|
lbKey: 'LB',
|
||||||
|
lbDesc: 'Ignition',
|
||||||
|
rbKey: 'RB',
|
||||||
|
rbDesc: 'Shut Down',
|
||||||
|
},
|
||||||
|
steer: {
|
||||||
|
ignition: 'Ignition',
|
||||||
|
ignitionHint: 'Start engine',
|
||||||
|
shutdown: 'Shut Down',
|
||||||
|
shutdownHint: 'Stop engine',
|
||||||
|
chassisUp: 'Raise Chassis',
|
||||||
|
chassisUpHint: 'Chassis up',
|
||||||
|
chassisDown: 'Lower Chassis',
|
||||||
|
chassisDownHint: 'Chassis down',
|
||||||
|
cutterControl: 'Cutter Control',
|
||||||
|
cutterAccel: 'Cutter Faster',
|
||||||
|
cutterDecel: 'Cutter Slower',
|
||||||
|
},
|
||||||
features: {
|
features: {
|
||||||
title: 'Feature Control',
|
title: 'Feature Control',
|
||||||
emergencyStop: 'Emergency Stop',
|
emergencyStop: 'Emergency Stop',
|
||||||
@@ -802,6 +853,8 @@
|
|||||||
realtimePicture: 'Realtime Picture',
|
realtimePicture: 'Realtime Picture',
|
||||||
realtimePowerData: 'Realtime Power Data',
|
realtimePowerData: 'Realtime Power Data',
|
||||||
realtimeSpeed: 'Realtime Speed',
|
realtimeSpeed: 'Realtime Speed',
|
||||||
|
forwardSpeed: 'Forward Speed',
|
||||||
|
turnSpeed: 'Turn Speed',
|
||||||
realtimeVideoMonitor: 'Realtime Video Monitor',
|
realtimeVideoMonitor: 'Realtime Video Monitor',
|
||||||
rechargeBtn: 'Recharge Btn',
|
rechargeBtn: 'Recharge Btn',
|
||||||
rechargeCommandSent: 'Recharge Command Sent',
|
rechargeCommandSent: 'Recharge Command Sent',
|
||||||
@@ -852,6 +905,7 @@
|
|||||||
routeSavedLocal: 'Route Saved Local',
|
routeSavedLocal: 'Route Saved Local',
|
||||||
rtBattery: 'Battery',
|
rtBattery: 'Battery',
|
||||||
rtHeadingAngle: 'rt Heading Angle',
|
rtHeadingAngle: 'rt Heading Angle',
|
||||||
|
rtRollAngle: 'rt Roll Angle',
|
||||||
rtHeadingStatus: 'rt Heading Status',
|
rtHeadingStatus: 'rt Heading Status',
|
||||||
rtInitialized: 'rt Initialized',
|
rtInitialized: 'rt Initialized',
|
||||||
rtLeftMotor: 'Left Motor',
|
rtLeftMotor: 'Left Motor',
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ const zh = {
|
|||||||
idle: '空闲',
|
idle: '空闲',
|
||||||
busy: '忙碌',
|
busy: '忙碌',
|
||||||
error: '故障',
|
error: '故障',
|
||||||
deviceControl: '设备控制',
|
deviceControl: '机器人控制',
|
||||||
realtimeVideo: '实时视频',
|
realtimeVideo: '实时视频',
|
||||||
takeoff: '起飞',
|
takeoff: '起飞',
|
||||||
land: '降落',
|
land: '降落',
|
||||||
@@ -657,6 +657,59 @@ const zh = {
|
|||||||
leftWheelDrive: '左轮驱动',
|
leftWheelDrive: '左轮驱动',
|
||||||
locationUnknown: '定位未知',
|
locationUnknown: '定位未知',
|
||||||
|
|
||||||
|
gamepadControl: '手柄控制',
|
||||||
|
steeringControl: '方向盘控制',
|
||||||
|
disconnectGamepadFirst: '请先断开手柄',
|
||||||
|
liveBadge: '直播中',
|
||||||
|
totalWorkArea: '累计作业面积',
|
||||||
|
totalWorkDuration: '累计作业时长',
|
||||||
|
totalWorkDistance: '累计作业里程',
|
||||||
|
motionStatus: '运动状态',
|
||||||
|
motionMoving: '行进中',
|
||||||
|
motionStopped: '已停止',
|
||||||
|
motionBlocked: '受阻',
|
||||||
|
rtEmergency: '急停状态',
|
||||||
|
estopTriggered: '已触发',
|
||||||
|
estopNormal: '正常',
|
||||||
|
rtLeftTargetRpm: '左目标转速',
|
||||||
|
rtRightTargetRpm: '右目标转速',
|
||||||
|
rtLeftMeasureRpm: '左测量转速',
|
||||||
|
rtRightMeasureRpm: '右测量转速',
|
||||||
|
rtLeftMotorRpm: '左电机转速',
|
||||||
|
rtRightMotorRpm: '右电机转速',
|
||||||
|
forwardSpeed: '前进速度',
|
||||||
|
turnSpeed: '转向速度',
|
||||||
|
gamepad: {
|
||||||
|
leftStick: '左摇杆',
|
||||||
|
leftStickDesc: '控制行进方向',
|
||||||
|
rightStick: '右摇杆',
|
||||||
|
rightStickDesc: '控制左右',
|
||||||
|
aKey: 'A 键',
|
||||||
|
aKeyDesc: '升底盘',
|
||||||
|
bKey: 'B 键',
|
||||||
|
bKeyDesc: '降底盘',
|
||||||
|
xKey: 'X 键',
|
||||||
|
xKeyDesc: '割刀加速',
|
||||||
|
yKey: 'Y 键',
|
||||||
|
yKeyDesc: '割刀减速',
|
||||||
|
lbKey: 'LB 键',
|
||||||
|
lbDesc: '点火',
|
||||||
|
rbKey: 'RB 键',
|
||||||
|
rbDesc: '熄火',
|
||||||
|
},
|
||||||
|
steer: {
|
||||||
|
ignition: '点火',
|
||||||
|
ignitionHint: '发动机启动',
|
||||||
|
shutdown: '熄火',
|
||||||
|
shutdownHint: '关闭发动机',
|
||||||
|
chassisUp: '底盘升起',
|
||||||
|
chassisUpHint: '底盘上升',
|
||||||
|
chassisDown: '底盘下降',
|
||||||
|
chassisDownHint: '底盘下降',
|
||||||
|
cutterControl: '割刀控制',
|
||||||
|
cutterAccel: '割刀加速',
|
||||||
|
cutterDecel: '割刀减速',
|
||||||
|
},
|
||||||
features: {
|
features: {
|
||||||
title: '功能控制',
|
title: '功能控制',
|
||||||
emergencyStop: '急停',
|
emergencyStop: '急停',
|
||||||
@@ -882,16 +935,17 @@ const zh = {
|
|||||||
rtHeadingAngle: '航向角度',
|
rtHeadingAngle: '航向角度',
|
||||||
rtHeadingStatus: '航向状态',
|
rtHeadingStatus: '航向状态',
|
||||||
rtInitialized: '已初始化',
|
rtInitialized: '已初始化',
|
||||||
rtLeftMotor: '左电机',
|
rtLeftMotor: '左电机电流',
|
||||||
rtLeftSpeed: '左速度',
|
rtLeftSpeed: '左速度',
|
||||||
rtLeftTemp: '左温度',
|
rtLeftTemp: '左电机温度',
|
||||||
rtMainTemp: '主温度',
|
rtMainTemp: '芯片温度',
|
||||||
rtMode: '模式',
|
rtMode: '模式',
|
||||||
rtPitchAngle: '俯仰角度',
|
rtPitchAngle: '俯仰角度',
|
||||||
|
rtRollAngle: '翻滚角度',
|
||||||
rtPositioning: '定位',
|
rtPositioning: '定位',
|
||||||
rtRightMotor: '右电机',
|
rtRightMotor: '右电机电流',
|
||||||
rtRightSpeed: '右速度',
|
rtRightSpeed: '右速度',
|
||||||
rtRightTemp: '右温度',
|
rtRightTemp: '右电机温度',
|
||||||
rtSatellites: '卫星数量',
|
rtSatellites: '卫星数量',
|
||||||
rtVoltage: '电压',
|
rtVoltage: '电压',
|
||||||
rthMode: '返航模式',
|
rthMode: '返航模式',
|
||||||
@@ -920,7 +974,7 @@ const zh = {
|
|||||||
selectWayline: '选择航线',
|
selectWayline: '选择航线',
|
||||||
selectedWaylineColon: '已选航线',
|
selectedWaylineColon: '已选航线',
|
||||||
signalSatellite: '信号卫星',
|
signalSatellite: '信号卫星',
|
||||||
situationMap: '态势地图',
|
situationMap: '地图',
|
||||||
smartAssign: '智能分配',
|
smartAssign: '智能分配',
|
||||||
standbyCount: '待机数量',
|
standbyCount: '待机数量',
|
||||||
startBtn: '开始按钮',
|
startBtn: '开始按钮',
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default function DeviceIndexPage() {
|
|||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{ key: 'overview', label: t('devices.equipmentOverview'), icon: <AppstoreOutlined /> },
|
{ key: 'overview', label: t('devices.equipmentOverview'), icon: <AppstoreOutlined /> },
|
||||||
{ key: 'status', label: t('devices.deviceStatus'), icon: <SettingOutlined /> },
|
{ key: 'status', label: t('devices.deviceControl'), icon: <SettingOutlined /> },
|
||||||
{ key: 'wayLineTask', label: t('devices.waylineTask'), icon: <AimOutlined /> },
|
{ key: 'wayLineTask', label: t('devices.waylineTask'), icon: <AimOutlined /> },
|
||||||
{ key: 'robotTask', label: t('devices.robotTask'), icon: <BranchesOutlined /> },
|
{ key: 'robotTask', label: t('devices.robotTask'), icon: <BranchesOutlined /> },
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user