限制低电量回充数值
This commit is contained in:
@@ -1161,6 +1161,22 @@ function buildDevicePlans(device: DeviceRecord): PatrolTask[] {
|
||||
];
|
||||
}
|
||||
|
||||
// 自动回充低电量阈值上限:必须低于车端"充电完成脱离阈值"(95%)并留出滞后余量,
|
||||
// 否则会出现"充到 95% 自动脱离 → 电量回落到阈值以下 → 又自动回充"的反复触发
|
||||
const MAX_LOW_BATTERY_THRESHOLD = 90;
|
||||
|
||||
// 阈值统一下限与默认值,和 charging_dock 节点保持一致的量级
|
||||
const MIN_LOW_BATTERY_THRESHOLD = 1;
|
||||
const DEFAULT_LOW_BATTERY_THRESHOLD = 30;
|
||||
|
||||
// 把阈值收敛到 [1, 90];非法值回落到默认阈值
|
||||
function clampLowBatteryThreshold(value: number | undefined) {
|
||||
if (typeof value !== "number" || !Number.isFinite(value)) {
|
||||
return DEFAULT_LOW_BATTERY_THRESHOLD;
|
||||
}
|
||||
return Math.min(MAX_LOW_BATTERY_THRESHOLD, Math.max(MIN_LOW_BATTERY_THRESHOLD, Math.round(value)));
|
||||
}
|
||||
|
||||
// 回充配置默认值与 charging_dock 节点保持一致:默认开启自动回充,阈值 30%
|
||||
function buildDockConfig(device: DeviceRecord): DockConfigState {
|
||||
return {
|
||||
@@ -1171,7 +1187,7 @@ function buildDockConfig(device: DeviceRecord): DockConfigState {
|
||||
preDockY: device.preDockY,
|
||||
preDockYaw: device.preDockYaw,
|
||||
autoRechargeEnabled: device.autoRechargeEnabled ?? true,
|
||||
lowBatteryThreshold: device.lowBatteryThreshold ?? 30,
|
||||
lowBatteryThreshold: clampLowBatteryThreshold(device.lowBatteryThreshold),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2522,6 +2538,16 @@ function fillDockPoseFromRobot(mode: "dock" | "preDock") {
|
||||
scheduleMapCanvasRender();
|
||||
}
|
||||
|
||||
// 输入框即时收敛阈值,避免页面上留下超过上限的值
|
||||
function normalizeDockThreshold() {
|
||||
if (!currentConfig.value) {
|
||||
return;
|
||||
}
|
||||
currentConfig.value.dock.lowBatteryThreshold = clampLowBatteryThreshold(
|
||||
currentConfig.value.dock.lowBatteryThreshold,
|
||||
);
|
||||
}
|
||||
|
||||
// 保存充电点与自动回充配置;后端保存后会同步下发给在线小车
|
||||
async function saveDockConfig() {
|
||||
const device = currentConfiguredDevice.value;
|
||||
@@ -2530,10 +2556,21 @@ async function saveDockConfig() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 阈值上限收敛:超过上限会与车端 95% 的自动脱离阈值形成自激反复
|
||||
const rawThreshold = Number(config.dock.lowBatteryThreshold);
|
||||
const overLimit = !Number.isFinite(rawThreshold) || rawThreshold > MAX_LOW_BATTERY_THRESHOLD;
|
||||
const threshold = clampLowBatteryThreshold(rawThreshold);
|
||||
config.dock.lowBatteryThreshold = threshold;
|
||||
|
||||
await updateRosCarDockConfig({
|
||||
id: device.id,
|
||||
...config.dock,
|
||||
lowBatteryThreshold: threshold,
|
||||
});
|
||||
|
||||
if (overLimit) {
|
||||
dockConfigMessage.value = `自动回充阈值最高 ${MAX_LOW_BATTERY_THRESHOLD}%,已按上限 ${threshold}% 保存`;
|
||||
}
|
||||
}
|
||||
|
||||
// 在地图上绘制充电点/预对接点标记
|
||||
@@ -3349,8 +3386,8 @@ watch(
|
||||
</label>
|
||||
<label class="dock-threshold">
|
||||
<span>阈值</span>
|
||||
<input v-model.number="currentConfig.dock.lowBatteryThreshold" max="99" min="1" step="1"
|
||||
type="number" />
|
||||
<input v-model.number="currentConfig.dock.lowBatteryThreshold" :max="MAX_LOW_BATTERY_THRESHOLD"
|
||||
:min="MIN_LOW_BATTERY_THRESHOLD" step="1" type="number" @change="normalizeDockThreshold" />
|
||||
<span>%</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user