Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/dimensional.command-center-extension-0.0.1.foxe
Git LFS file not shown
13 changes: 13 additions & 0 deletions dimos/web/command-center-extension/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from "react";
import Connection from "./Connection";
import ExplorePanel from "./ExplorePanel";
import GpsButton from "./GpsButton";
import Button from "./Button";
import KeyboardControlPanel from "./KeyboardControlPanel";
import VisualizerWrapper from "./components/VisualizerWrapper";
import LeafletMap from "./components/LeafletMap";
Expand Down Expand Up @@ -77,6 +78,16 @@ export default function App(): React.ReactElement {
connectionRef.current?.stopMoveCommand();
}, []);

const handleReturnHome = React.useCallback(() => {
connectionRef.current?.worldClick(0, 0);
}, []);

const handleStop = React.useCallback(() => {
if (state.robotPose) {
connectionRef.current?.worldClick(state.robotPose.coords[0]!, state.robotPose.coords[1]!);
}
}, [state.robotPose]);
Comment on lines +85 to +89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: handleStop uses stale state.robotPose from closure. If robot moves between render and button click, it will send goal to outdated position instead of truly stopping.

Suggested change
const handleStop = React.useCallback(() => {
if (state.robotPose) {
connectionRef.current?.worldClick(state.robotPose.coords[0]!, state.robotPose.coords[1]!);
}
}, [state.robotPose]);
const handleStop = React.useCallback(() => {
connectionRef.current?.stopMoveCommand();
}, []);


return (
<div style={{ position: "relative", width: "100%", height: "100%" }}>
{isGpsMode ? (
Expand Down Expand Up @@ -105,6 +116,8 @@ export default function App(): React.ReactElement {
onUseCostmap={() => setIsGpsMode(false)}
></GpsButton>
<ExplorePanel onStartExplore={handleStartExplore} onStopExplore={handleStopExplore} />
<Button onClick={handleReturnHome} isActive={false}>Go Home</Button>
<Button onClick={handleStop} isActive={false}>Stop</Button>
<KeyboardControlPanel
onSendMoveCommand={handleSendMoveCommand}
onStopMoveCommand={handleStopMoveCommand}
Expand Down
Loading