This commit is contained in:
legop3
2026-01-21 03:01:29 -05:00
parent 720a010973
commit 1fd0de5b1e
4 changed files with 15 additions and 20 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -11,7 +11,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" /> <meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
<title>Multi Roomba Rover</title> <title>Multi Roomba Rover</title>
<script type="module" crossorigin src="/assets/index-DHJk2paN.js"></script> <script type="module" crossorigin src="/assets/index-CSPjf0W2.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BBEWYgmH.css"> <link rel="stylesheet" crossorigin href="/assets/index-BBEWYgmH.css">
</head> </head>
<body> <body>
@@ -66,7 +66,7 @@ export default function OvercurrentLimiterPanel() {
})} })}
<div className="surface text-[0.7rem] text-slate-400"> <div className="surface text-[0.7rem] text-slate-400">
<div>{`Heat up ${overcurrentLimiter?.config?.heatUpSec}s · Cool down ${overcurrentLimiter?.config?.coolDownSec}s`}</div> <div>{`Heat up ${overcurrentLimiter?.config?.heatUpSec}s · Cool down ${overcurrentLimiter?.config?.coolDownSec}s`}</div>
<div>{`Knee ${overcurrentLimiter?.config?.kneeSec}s · Curve k ${overcurrentLimiter?.config?.curveK} · Power ${overcurrentLimiter?.config?.curvePower}`}</div> <div>{`Knee ${overcurrentLimiter?.config?.kneeSec}s`}</div>
<div>{`Output rate ${overcurrentLimiter?.config?.outputRateMs}ms`}</div> <div>{`Output rate ${overcurrentLimiter?.config?.outputRateMs}ms`}</div>
</div> </div>
</div> </div>
+4 -9
View File
@@ -8,11 +8,9 @@ export const OVERCURRENT_GROUPS = [
]; ];
export const DEFAULT_OVERCURRENT_LIMITS = { export const DEFAULT_OVERCURRENT_LIMITS = {
heatUpSec: 7, heatUpSec: 4,
coolDownSec: 12, coolDownSec: 12,
kneeSec: 4, kneeSec: 1.5,
curveK: 4,
curvePower: 2,
outputRateMs: 250, outputRateMs: 250,
}; };
@@ -90,16 +88,13 @@ export function useOvercurrentLimiter(roverId, options = {}) {
}, [config.heatUpSec, config.coolDownSec]); }, [config.heatUpSec, config.coolDownSec]);
const scales = useMemo(() => { const scales = useMemo(() => {
const curveK = Number.isFinite(config.curveK) ? Math.max(0, config.curveK) : 0;
const curvePower = Number.isFinite(config.curvePower) ? Math.max(0.1, config.curvePower) : 1;
const kneeSec = Number.isFinite(config.kneeSec) ? Math.max(0, config.kneeSec) : 0; const kneeSec = Number.isFinite(config.kneeSec) ? Math.max(0, config.kneeSec) : 0;
const heatUpSec = Number.isFinite(config.heatUpSec) ? Math.max(0.001, config.heatUpSec) : 0.001; const heatUpSec = Number.isFinite(config.heatUpSec) ? Math.max(0.001, config.heatUpSec) : 0.001;
const kneeTemp = clampUnit(kneeSec / heatUpSec); const kneeTemp = clampUnit(kneeSec / heatUpSec);
const perGroup = OVERCURRENT_GROUPS.reduce((acc, group) => { const perGroup = OVERCURRENT_GROUPS.reduce((acc, group) => {
const temp = Number.isFinite(temperatures?.[group.key]) ? temperatures[group.key] : 0; const temp = Number.isFinite(temperatures?.[group.key]) ? temperatures[group.key] : 0;
const normalized = kneeTemp >= 1 ? 0 : clampUnit((temp - kneeTemp) / (1 - kneeTemp)); const normalized = kneeTemp >= 1 ? 0 : clampUnit((temp - kneeTemp) / (1 - kneeTemp));
const scaled = Math.exp(-curveK * Math.pow(normalized, curvePower)); acc[group.key] = clampUnit(1 - normalized);
acc[group.key] = clampUnit(scaled);
return acc; return acc;
}, {}); }, {});
return { return {
@@ -114,7 +109,7 @@ export function useOvercurrentLimiter(roverId, options = {}) {
vacuum: 1, vacuum: 1,
}, },
}; };
}, [config.curveK, config.curvePower, config.heatUpSec, config.kneeSec, temperatures]); }, [config.heatUpSec, config.kneeSec, temperatures]);
const overcurrent = useMemo(() => { const overcurrent = useMemo(() => {
const motors = {}; const motors = {};