Skip to content

Show playback #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 95 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
276feea
erm all the things gabe and i did
Kandles11 Mar 25, 2025
119c01e
format
democat3457 Mar 25, 2025
a208181
Extract robot grid component on simulator page
jasonappah Mar 8, 2025
e6eb8d0
Stuff
jasonappah Mar 11, 2025
4be9660
Rough spline editor UI
jasonappah Mar 25, 2025
23eebe9
Format
jasonappah Mar 25, 2025
dc130b2
Downgrade yarn version, install motion
jasonappah Mar 25, 2025
44400e4
Create bots on connection in bot manager. start parallel command testing
Kandles11 Apr 1, 2025
a93a44b
Load startHeading
democat3457 Apr 1, 2025
dd96950
drive tick command implementation! 🚙
Kandles11 Apr 1, 2025
421649b
Implement remaining context menu methods, render control points
jasonappah Apr 1, 2025
ad53991
Allow robot grid to take children
jasonappah Apr 12, 2025
68d6c82
Begin showfile schema
jasonappah Apr 12, 2025
98ba0a6
Begin shell of timeline UI
jasonappah Apr 12, 2025
812b21b
Add hotkeys, file opening/saving
jasonappah Apr 12, 2025
7f9dfc6
Make title editable, check for unsaved changes
jasonappah Apr 12, 2025
e1cddff
Format
jasonappah Apr 12, 2025
519d7a9
Refactor editor into separate files
jasonappah Apr 12, 2025
d7e625d
Change default show name
jasonappah Apr 12, 2025
34b444d
Lint + format
jasonappah Apr 12, 2025
b77c15f
Rough impl of play/pause
jasonappah Apr 13, 2025
962c446
Optimize renders, audio playback, timeline layer addition/deletion
jasonappah Apr 14, 2025
f8c7a9c
Format
jasonappah Apr 14, 2025
83e0359
Type fixes
jasonappah Apr 14, 2025
fc18af1
Fix bug in undo/redo hook
jasonappah Apr 14, 2025
909e86c
Make spline editor state controlled / hoist spline state to main edit…
jasonappah Apr 14, 2025
9917a16
Add button to load audio file
jasonappah Apr 14, 2025
02dd6c0
Move showfile state and callbacks to new function
jasonappah Apr 14, 2025
dd6ec54
Bump TypeScript version
jasonappah Apr 14, 2025
bd2e4d2
Move showfile hook to new file
jasonappah Apr 14, 2025
c057f64
Lower TS version
jasonappah Apr 14, 2025
bc5ce64
Add schemas and types from authoring-splines
jasonappah Apr 15, 2025
47775a2
Add comments
jasonappah Apr 15, 2025
7bff754
Merge branch 'showfile-schema' into authoring-splines
jasonappah Apr 15, 2025
1e467f4
Make timeline events reorderable
jasonappah Apr 15, 2025
67f19bb
Implement timeline event reordering and duration editing
jasonappah Apr 15, 2025
dda5fc8
Rename showfile state file
jasonappah Apr 15, 2025
09415aa
Format
jasonappah Apr 15, 2025
fceff55
Address comments on schemas and types
jasonappah Apr 15, 2025
1cef70a
Refactor TimelineLayerSchema as object instead of tuple for clarity
jasonappah Apr 16, 2025
e23180e
Move some timeline components into separate files
jasonappah Apr 16, 2025
ce98ac1
Add comments to state + light refactoring for clarity
jasonappah Apr 21, 2025
e626b2c
Add icon to timeline event drag handle
jasonappah Apr 21, 2025
4dfad77
Add pen tool for adding points to layer
jasonappah Apr 21, 2025
27f88fb
Format
jasonappah Apr 21, 2025
dd46a71
Layer selection
jasonappah Apr 21, 2025
f59bd22
Export robot, destructure props
jasonappah Apr 24, 2025
709a8f6
Fix bugs in undo/redo hook
jasonappah Apr 24, 2025
a5dcbbd
Wrap timeline event in context menu
jasonappah Apr 24, 2025
6d904d7
Prevent default undo on ctrl/cmd+z/y
jasonappah Apr 24, 2025
e76edc2
Format
jasonappah Apr 24, 2025
1256f1e
Forward robot ref
jasonappah Apr 24, 2025
521df29
Begin robot rendering, add showfile dump to UI
jasonappah Apr 24, 2025
0cb5f81
Rename type, nuke robot rendering stuff
jasonappah Apr 24, 2025
9b53a57
Scuffed/broken implementation of robot motion
jasonappah Apr 24, 2025
ed6aeba
Format
jasonappah Apr 25, 2025
a21fab5
Add web debug configuration
jasonappah Apr 25, 2025
697854d
Add delete to event context menu
jasonappah Apr 25, 2025
e96cb05
Add drag-to-seek, add wait event
jasonappah Apr 25, 2025
e670b80
Adjust opacity of non selected splines
jasonappah Apr 25, 2025
f6c2fe7
Format
jasonappah Apr 25, 2025
b8ec128
Try memoizing return value of `useShowfile`
jasonappah Apr 25, 2025
9823c28
create cubic and quadratic drive schemas
Kandles11 Apr 25, 2025
1247a40
create move commands
Kandles11 Apr 25, 2025
ef91309
Add Time Point and WaitCommand
democat3457 Apr 25, 2025
a4aece9
add spin schema and move.
Kandles11 Apr 25, 2025
a83479b
Format
jasonappah Apr 25, 2025
146c468
Add turn point schema
jasonappah Apr 25, 2025
1232f20
Add jump to point utility
jasonappah Apr 25, 2025
0850cc9
Jump to beginning on playback if last playback finished at end of tim…
jasonappah Apr 25, 2025
004637a
update quadratic and cubic to have multiple control points
Kandles11 Apr 25, 2025
feec1fa
Support jumping to timestamp on timeline
jasonappah Apr 25, 2025
40766fd
Allow turn events to be added on timeline
jasonappah Apr 25, 2025
b6fd5fc
Add scuffed support for copy/paste
jasonappah Apr 25, 2025
c47cbe9
change drive schema. update how send parallel works
Kandles11 Apr 25, 2025
580f019
Merge branch 'authoring-splines' into bot-synchronization-💃
ymmot239 Apr 25, 2025
ccd6718
bs gooo
ymmot239 Apr 26, 2025
522faf3
Fix bad merge
jasonappah Apr 26, 2025
b3d1b32
Fix server side use of window
jasonappah Apr 26, 2025
b645c98
DANCE MONKEY DANCE MONKEY DANCE MONKEY 🐒
BurbachGabriel Apr 26, 2025
56b2e7a
Small fix
BurbachGabriel Apr 26, 2025
1157a8d
Fix
BurbachGabriel Apr 26, 2025
f66d401
Format
jasonappah Apr 26, 2025
a99477d
Force bot server to listen on IPv4 address
jasonappah Apr 26, 2025
5f19c4b
Update default durations
jasonappah Apr 26, 2025
1eba4db
Minor refactoring to improve readability in /do-big endpoint
jasonappah Apr 26, 2025
d93469c
Fix type bug
jasonappah Apr 28, 2025
d4305fa
makes the control points explicit in the editor
BurbachGabriel Apr 28, 2025
ba9f446
bigger timedelta to ensure cmd runs
democat3457 Apr 29, 2025
e7a61a3
Add support for selecting individual events
jasonappah Apr 29, 2025
7b57010
Format
jasonappah Apr 29, 2025
d574c44
Merge branch 'main' into lol-bs
jasonappah Apr 30, 2025
bae8bf7
Force durations to ints
jasonappah Apr 29, 2025
d2aeec1
Begin inspector panel
jasonappah Apr 29, 2025
f6acdc7
Fix typo + make unique IDs for default events
jasonappah May 5, 2025
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
9 changes: 8 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug ChessBots Client",
"request": "launch",
"type": "chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Debug ChessBot Server",
"name": "Debug ChessBots Server",
"runtimeExecutable": "ts-node",
"program": "${workspaceFolder}/src/server/main.ts",
"restart": true,
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"task.autoDetect": "off",
"cSpell.words": [
"blueprintjs",
"cbor",
"Chessbots",
"Premoves",
"runtypes",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"chess.js": "^1.0.0-beta.6",
"eslint-plugin-tsdoc": "^0.2.17",
"typescript": "^4.9.3",
"typescript": "5.5.4",
"vite-express": "^0.11.1"
},
"devDependencies": {
Expand All @@ -39,12 +39,12 @@
"nodemon": "^3.0.3",
"prettier": "^3.2.4",
"ts-node": "^10.9.1",
"typedoc": "^0.23.0",
"typedoc": "^0.28.0",
"vite": "^4.5.5",
"vitest": "^3.0.8"
},
"optionalDependencies": {
"bufferutil": "^4.0.8"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
"packageManager": "yarn@1.19.0+sha512.40b88ca23f991e8da44f5ef1d6dedeaceea0cd1fbdc526b9cfb2e67a2d6a60cd528f7ef088816febb910707fa792c86c3b47f4dc89970a57e410a5209ec32b79"
}
9 changes: 9 additions & 0 deletions src/client/debug/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export function Debug() {
fetchIds();
}, [setRobotIds]);

const danceConfigLoad = async () => {
const response = await get("/do-parallel");
if (!response.ok) {
console.warn("Failed to load dance config");
}
};
// create the select and move buttons
let body: ReactNode;
if (robotIds === undefined) {
Expand All @@ -49,6 +55,9 @@ export function Debug() {
selectedRobotId={selectedRobotId}
onRobotIdSelected={setSelectedRobotId}
/>
<div className="debug-section">
<Button icon="play" minimal onClick={danceConfigLoad} />
</div>
{selectedRobotId === undefined ? null : (
<>
<div className="debug-section">
Expand Down
132 changes: 78 additions & 54 deletions src/client/debug/simulator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Card, Button, H1, Tooltip, Collapse } from "@blueprintjs/core";
import { useEffect, useReducer, useRef, useState } from "react";
import {
CSSProperties,
forwardRef,
type PropsWithChildren,
useEffect,
useReducer,
useRef,
useState,
} from "react";
import { useNavigate } from "react-router-dom";
import { get, useSocket } from "../api";
import {
Expand All @@ -22,9 +30,11 @@ import {
} from "../check-dark-mode";

const tileSize = 60;
const robotSize = tileSize / 2;
export const robotSize = tileSize / 2;
const cellCount = 12;

export type RobotState = { [robotId: string]: SimulatedRobotLocation };

/**
* Creates a robot simulator for testing robot commands
*
Expand All @@ -34,8 +44,6 @@ const cellCount = 12;
export function Simulator() {
const navigate = useNavigate();

type RobotState = { [robotId: string]: SimulatedRobotLocation };

type Action =
| { type: "SET_ALL_ROBOTS"; payload: RobotState }
| {
Expand Down Expand Up @@ -150,45 +158,7 @@ export function Simulator() {
</Button>
</div>
<div style={{ display: "flex", gap: "1rem", width: "95vw" }}>
<div
style={{
display: "grid",
gridTemplateColumns: `repeat(${cellCount}, ${tileSize}px)`,
gridTemplateRows: `repeat(${cellCount}, ${tileSize}px)`,
position: "relative",
}}
>
{new Array(cellCount * cellCount)
.fill(undefined)
.map((_, i) => {
const row = Math.floor(i / cellCount);
const col = i % cellCount;
const isCenterCell =
row >= 2 && row < 10 && col >= 2 && col < 10;
return (
<div
key={i}
style={{
borderWidth: "1px",
borderStyle: "solid",
borderColor: simBorderColor(),
backgroundColor:
!isCenterCell ? simRingCellColor()
: "transparent",
}}
/>
);
})}
{/* TODO: implement onTopOfRobots */}
{Object.entries(robotState).map(([robotId, pos]) => (
<Robot
pos={pos}
robotId={robotId}
key={robotId}
onTopOfRobots={[]}
/>
))}
</div>
<RobotGrid robotState={robotState} />
<div
style={{
width: "100%",
Expand Down Expand Up @@ -239,6 +209,54 @@ const openInEditor = async (frame: StackFrame) => {
await fetch(`/__open-in-editor?${params.toString()}`);
};

// TODO: refactor out of debug since we use it in more than just simulator?
export function RobotGrid({
robotState,
children,
}: PropsWithChildren<{ robotState: RobotState }>) {
return (
<div
style={{
display: "grid",
gridTemplateColumns: `repeat(${cellCount}, ${tileSize}px)`,
gridTemplateRows: `repeat(${cellCount}, ${tileSize}px)`,
position: "relative",
}}
>
{new Array(cellCount * cellCount).fill(undefined).map((_, i) => {
const row = Math.floor(i / cellCount);
const col = i % cellCount;
const isCenterCell =
row >= 2 && row < 10 && col >= 2 && col < 10;
return (
<div
key={i}
style={{
borderWidth: "1px",
borderStyle: "solid",
borderColor: simBorderColor(),
backgroundColor:
!isCenterCell ? simRingCellColor() : (
"transparent"
),
}}
/>
);
})}
{/* TODO: implement onTopOfRobots */}
{Object.entries(robotState).map(([robotId, pos]) => (
<Robot
pos={pos}
robotId={robotId}
key={robotId}
onTopOfRobots={[]}
/>
))}
{children}
</div>
);
}

/**
* the message log, used to show the commands sent to the robot
* @param props - the message and time
Expand Down Expand Up @@ -336,25 +354,31 @@ function LogEntry(props: { message: SimulatorUpdateMessage; ts: Date }) {
* @param props - the robot position and id
* @returns the robot icon scaled to the board
*/
function Robot(props: {
pos: SimulatedRobotLocation;
robotId: string;
onTopOfRobots: string[];
}) {
export const Robot = forwardRef<
HTMLDivElement,
{
pos: SimulatedRobotLocation;
robotId: string;
onTopOfRobots: string[];
style?: CSSProperties;
}
>(function Robot({ pos, robotId, onTopOfRobots, style }, ref) {
return (
<div
ref={ref}
className="robot"
style={{
position: "absolute",
left: `${props.pos.position.x * tileSize - 0.25 * tileSize}px`,
bottom: `${props.pos.position.y * tileSize - 0.25 * tileSize}px`,
left: `${pos.position.x * tileSize - 0.25 * tileSize}px`,
bottom: `${pos.position.y * tileSize - 0.25 * tileSize}px`,
...style,
}}
>
<Tooltip content={`${props.robotId}: ${JSON.stringify(props.pos)}`}>
<Tooltip content={`${robotId}: ${JSON.stringify(pos)}`}>
<div
className={robotColor(props.onTopOfRobots.length)}
className={robotColor(onTopOfRobots.length)}
style={{
transform: `rotate(-${clampHeading(props.pos.headingRadians)}rad)`,
transform: `rotate(-${clampHeading(pos.headingRadians)}rad)`,
borderRadius: "50%",
display: "flex",
justifyContent: "flex-end",
Expand All @@ -377,4 +401,4 @@ function Robot(props: {
</Tooltip>
</div>
);
}
});
Loading