mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
guh
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>webui</title>
|
<title>webui</title>
|
||||||
<script type="module" crossorigin src="/assets/index-DgBoZ7rI.js"></script>
|
<script type="module" crossorigin src="/assets/index-BlaZqU9Q.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-BaCUS21F.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-BaCUS21F.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ export function ControlSystemProvider({ children }) {
|
|||||||
|
|
||||||
const setDriveVector = useCallback(
|
const setDriveVector = useCallback(
|
||||||
(vector, meta = {}) => {
|
(vector, meta = {}) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[control] setDriveVector', vector, meta);
|
||||||
const computed = computeDifferentialSpeeds(vector);
|
const computed = computeDifferentialSpeeds(vector);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'control/update-drive',
|
type: 'control/update-drive',
|
||||||
@@ -77,6 +79,8 @@ export function ControlSystemProvider({ children }) {
|
|||||||
|
|
||||||
const setAuxMotors = useCallback(
|
const setAuxMotors = useCallback(
|
||||||
(values = {}) => {
|
(values = {}) => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[control] setAuxMotors', values);
|
||||||
const payload = pipeline.sendAuxMotors(values) ?? values;
|
const payload = pipeline.sendAuxMotors(values) ?? values;
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'control/set-aux-motors',
|
type: 'control/set-aux-motors',
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ export function useCommandPipeline() {
|
|||||||
left: clampRange(speeds?.left ?? 0, [-500, 500]),
|
left: clampRange(speeds?.left ?? 0, [-500, 500]),
|
||||||
right: clampRange(speeds?.right ?? 0, [-500, 500]),
|
right: clampRange(speeds?.right ?? 0, [-500, 500]),
|
||||||
};
|
};
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[pipeline] sendDriveDirect', payload);
|
||||||
emitCommand({
|
emitCommand({
|
||||||
type: 'drive',
|
type: 'drive',
|
||||||
data: { driveDirect: payload },
|
data: { driveDirect: payload },
|
||||||
@@ -59,6 +61,8 @@ export function useCommandPipeline() {
|
|||||||
side: clampRange(side, AUX_LIMITS.side),
|
side: clampRange(side, AUX_LIMITS.side),
|
||||||
vacuum: clampRange(vacuum, AUX_LIMITS.vacuum),
|
vacuum: clampRange(vacuum, AUX_LIMITS.vacuum),
|
||||||
};
|
};
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[pipeline] sendAuxMotors', payload);
|
||||||
emitCommand({
|
emitCommand({
|
||||||
type: 'motors',
|
type: 'motors',
|
||||||
data: { motorPwm: payload },
|
data: { motorPwm: payload },
|
||||||
|
|||||||
@@ -194,6 +194,8 @@ export default function KeyboardInputManager() {
|
|||||||
vector.y !== lastVectorRef.current.y ||
|
vector.y !== lastVectorRef.current.y ||
|
||||||
vector.boost !== lastVectorRef.current.boost
|
vector.boost !== lastVectorRef.current.boost
|
||||||
) {
|
) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[keyboard] drive vector', Array.from(tokensSnapshot), vector);
|
||||||
lastVectorRef.current = vector;
|
lastVectorRef.current = vector;
|
||||||
setDriveVector(vector, { source: SOURCE });
|
setDriveVector(vector, { source: SOURCE });
|
||||||
}
|
}
|
||||||
@@ -202,6 +204,8 @@ export default function KeyboardInputManager() {
|
|||||||
aux.side !== lastAuxRef.current.side ||
|
aux.side !== lastAuxRef.current.side ||
|
||||||
aux.vacuum !== lastAuxRef.current.vacuum
|
aux.vacuum !== lastAuxRef.current.vacuum
|
||||||
) {
|
) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[keyboard] aux state', Array.from(tokensSnapshot), aux);
|
||||||
lastAuxRef.current = aux;
|
lastAuxRef.current = aux;
|
||||||
setAuxMotors(aux);
|
setAuxMotors(aux);
|
||||||
}
|
}
|
||||||
@@ -229,18 +233,26 @@ export default function KeyboardInputManager() {
|
|||||||
const ensureServoLoop = useCallback(() => {
|
const ensureServoLoop = useCallback(() => {
|
||||||
const direction = computeServoDirection();
|
const direction = computeServoDirection();
|
||||||
if (direction === 0) {
|
if (direction === 0) {
|
||||||
|
if (servoIntervalRef.current) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[keyboard] servo loop stop');
|
||||||
|
}
|
||||||
stopServoLoop();
|
stopServoLoop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (servoIntervalRef.current) {
|
if (servoIntervalRef.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[keyboard] servo loop start', direction);
|
||||||
const tick = () => {
|
const tick = () => {
|
||||||
const nextDirection = computeServoDirection();
|
const nextDirection = computeServoDirection();
|
||||||
if (nextDirection === 0) {
|
if (nextDirection === 0) {
|
||||||
stopServoLoop();
|
stopServoLoop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[keyboard] servo tick', nextDirection);
|
||||||
nudgeServo(nextDirection * servoStep);
|
nudgeServo(nextDirection * servoStep);
|
||||||
servoIntervalRef.current = setTimeout(tick, SERVO_REPEAT_MS);
|
servoIntervalRef.current = setTimeout(tick, SERVO_REPEAT_MS);
|
||||||
};
|
};
|
||||||
@@ -264,6 +276,8 @@ export default function KeyboardInputManager() {
|
|||||||
if (tokens.some((token) => actionTokens.has(token))) {
|
if (tokens.some((token) => actionTokens.has(token))) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[keyboard] keydown', { key: event.key, code: event.code, tokens });
|
||||||
const newlyPressed = tokens.filter((token) => !activeTokensRef.current.has(token));
|
const newlyPressed = tokens.filter((token) => !activeTokensRef.current.has(token));
|
||||||
newlyPressed.forEach((token) => activeTokensRef.current.add(token));
|
newlyPressed.forEach((token) => activeTokensRef.current.add(token));
|
||||||
|
|
||||||
@@ -283,6 +297,8 @@ export default function KeyboardInputManager() {
|
|||||||
|
|
||||||
function handleKeyUp(event) {
|
function handleKeyUp(event) {
|
||||||
const tokens = tokensFromEvent(event);
|
const tokens = tokensFromEvent(event);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.debug('[keyboard] keyup', { key: event.key, code: event.code, tokens });
|
||||||
tokens.forEach((token) => activeTokensRef.current.delete(token));
|
tokens.forEach((token) => activeTokensRef.current.delete(token));
|
||||||
ensureServoLoop();
|
ensureServoLoop();
|
||||||
driveFromKeys();
|
driveFromKeys();
|
||||||
|
|||||||
Reference in New Issue
Block a user