+
);
}
diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx
new file mode 100644
index 0000000..98b69cc
--- /dev/null
+++ b/src/app/not-found.tsx
@@ -0,0 +1,27 @@
+import type { Metadata } from "next";
+
+import { PageFrame } from "@/components/SectionPage";
+import { href } from "@/components/siteData";
+
+export const metadata: Metadata = {
+ title: "Page not found",
+};
+
+// Any URL with no page. The export writes it to 404.html, which GitHub
+// Pages serves for every path it has no file for.
+export default function NotFound() {
+ return (
+
+ );
+}
diff --git a/src/app/og.png/route.tsx b/src/app/og.png/route.tsx
index 373ea29..50ec3c3 100644
--- a/src/app/og.png/route.tsx
+++ b/src/app/og.png/route.tsx
@@ -32,9 +32,9 @@ const font = (file: string) =>
export async function GET() {
const [medium, semibold, mono] = await Promise.all([
- font("InterTight-Medium.ttf"),
- font("InterTight-SemiBold.ttf"),
- font("IBMPlexMono-Medium.ttf"),
+ font("inter-tight-medium.ttf"),
+ font("inter-tight-semibold.ttf"),
+ font("ibm-plex-mono-medium.ttf"),
]);
return new ImageResponse(
@@ -160,8 +160,7 @@ export async function GET() {
height: OG_IMAGE.height,
fonts: [
{ name: "Inter Tight", data: medium, weight: 500 },
- // The file is the 650 cut, the weight the site sets the name in;
- // Satori only takes the standard steps, so it is filed under 600
+ // SemiBold (600), the weight the hero sets the name in
{ name: "Inter Tight", data: semibold, weight: 600 },
{ name: "IBM Plex Mono", data: mono, weight: 500 },
],
diff --git a/src/app/(site)/page.tsx b/src/app/page.tsx
similarity index 89%
rename from src/app/(site)/page.tsx
rename to src/app/page.tsx
index bed0d46..e7861fb 100644
--- a/src/app/(site)/page.tsx
+++ b/src/app/page.tsx
@@ -2,6 +2,10 @@ import { ControlSection } from "@/components/ControlSection";
import { Hero } from "@/components/Hero";
import { TimingStrip } from "@/components/TimingStrip";
+import { pageMetadata } from "./shared-metadata";
+
+export const metadata = pageMetadata("/");
+
// The thesis, then the proof: a handshake that meets its deadline, a
// control loop you can make late, and the same handshake missing it
export default function Home() {
diff --git a/src/app/projects/page.tsx b/src/app/projects/page.tsx
new file mode 100644
index 0000000..d5ed2c5
--- /dev/null
+++ b/src/app/projects/page.tsx
@@ -0,0 +1,9 @@
+import { SectionPage } from "@/components/SectionPage";
+
+import { sectionMetadata } from "../shared-metadata";
+
+export const metadata = sectionMetadata("projects");
+
+export default function ProjectsPage() {
+ return ;
+}
diff --git a/src/app/shared-metadata.ts b/src/app/shared-metadata.ts
index 83581e4..4fb0e98 100644
--- a/src/app/shared-metadata.ts
+++ b/src/app/shared-metadata.ts
@@ -2,15 +2,21 @@ import type { Metadata } from "next";
import { href, section, type Section } from "@/components/siteData";
+export const SITE_NAME = "ML³ Labs";
+
export const description =
"McMaster Low Latency Labs. A deadline is a correctness condition.";
+// "Team · ML³ Labs", or the site name alone
+export const titleFor = (title?: string) =>
+ title ? `${title} · ${SITE_NAME}` : SITE_NAME;
+
// The preview card, built by og.png/route.tsx
export const OG_IMAGE = {
url: "/og.png",
width: 1200,
height: 630,
- alt: "ML³ Labs: McMaster Low Latency Labs. A deadline is a correctness condition.",
+ alt: `${SITE_NAME}: ${description}`,
} as const;
export const twitter = {
@@ -23,24 +29,27 @@ export const twitter = {
// into it, so every page spreads these in
export const openGraph = {
type: "website",
- siteName: "ML³ Labs",
+ siteName: SITE_NAME,
description,
images: OG_IMAGE,
locale: "en_US",
} as const;
-// Without its own canonical and og:url, a section page would inherit the
-// root's "/" and tell crawlers it is a copy of the landing page
-export function sectionMetadata(slug: Section["slug"]): Metadata {
- const { title } = section(slug);
- const url = href(slug);
- // The tab title gets " · ML³ Labs" from the (site) layout's template;
- // og and twitter titles are not templated, so they carry it themselves
- const full = `${title} · ML³ Labs`;
+// A page's canonical URL and link-preview titles. Without its own
+// canonical and og:url, a page would inherit the root's "/" and tell
+// crawlers it is a copy of the landing page. The og and twitter titles
+// are not templated like the tab title, so they carry the site name.
+export function pageMetadata(url: string, title?: string): Metadata {
+ const full = titleFor(title);
return {
- title,
alternates: { canonical: url },
openGraph: { ...openGraph, url, title: full },
twitter: { ...twitter, title: full },
};
}
+
+// The tab title gets the site name from the root layout's template
+export function sectionMetadata(slug: Section["slug"]): Metadata {
+ const { title } = section(slug);
+ return { title, ...pageMetadata(href(slug), title) };
+}
diff --git a/src/app/sponsors/page.tsx b/src/app/sponsors/page.tsx
new file mode 100644
index 0000000..9e08971
--- /dev/null
+++ b/src/app/sponsors/page.tsx
@@ -0,0 +1,17 @@
+import { SectionPage } from "@/components/SectionPage";
+import { EMAIL } from "@/components/siteData";
+
+import { sectionMetadata } from "../shared-metadata";
+
+export const metadata = sectionMetadata("sponsors");
+
+export default function SponsorsPage() {
+ // The landing page's calls to action lead here, so until the page has
+ // content it still offers a way to reach the club
+ return (
+
+ );
+}
diff --git a/src/app/team/page.tsx b/src/app/team/page.tsx
new file mode 100644
index 0000000..8e1ebaa
--- /dev/null
+++ b/src/app/team/page.tsx
@@ -0,0 +1,9 @@
+import { SectionPage } from "@/components/SectionPage";
+
+import { sectionMetadata } from "../shared-metadata";
+
+export const metadata = sectionMetadata("team");
+
+export default function TeamPage() {
+ return ;
+}
diff --git a/src/components/CartPoleDrawings.tsx b/src/components/CartPoleDrawings.tsx
new file mode 100644
index 0000000..e0c2616
--- /dev/null
+++ b/src/components/CartPoleDrawings.tsx
@@ -0,0 +1,316 @@
+import type { Ref } from "react";
+
+import { MODEL, SCENARIO_MS } from "@/lib/cartpole";
+
+import {
+ type MechFrame,
+ type MechGeom,
+ SCOPE_H,
+ type ScopeFrame,
+ type ScopeGeom,
+ signed,
+} from "./cartpolePaint";
+import styles from "./ControlToy.module.css";
+
+// The cart-pole figure's two drawings, as their first frame. ControlToy
+// animates them afterwards through the nodes marked data-k, which
+// mechNodes() and scopeNodes() in cartpolePaint.ts look up by those names:
+// rename one here and rename it there.
+
+export function Mechanism({
+ ref,
+ g,
+ f0,
+ hatchId,
+}: {
+ ref: Ref;
+ g: MechGeom;
+ f0: MechFrame;
+ hatchId: string;
+}) {
+ return (
+
+ );
+}
+
+export function Scope({
+ ref,
+ sg,
+ sc0,
+ reduced,
+ clipId,
+ traceId,
+}: {
+ ref: Ref;
+ sg: ScopeGeom;
+ sc0: ScopeFrame;
+ reduced: boolean;
+ clipId: string;
+ traceId: string;
+}) {
+ const secTicks: number[] = [];
+ for (let k = 0; k <= SCENARIO_MS / 1000; k++) secTicks.push(k);
+ const yOf = (deg: number) => sg.mid - deg * sg.degPx;
+
+ return (
+
+ );
+}
diff --git a/src/components/ControlSection.tsx b/src/components/ControlSection.tsx
index bc4b5e3..92dc74f 100644
--- a/src/components/ControlSection.tsx
+++ b/src/components/ControlSection.tsx
@@ -3,6 +3,8 @@ import { findDeadline, linearDelayMargin } from "@/lib/cartpole";
import styles from "./ControlSection.module.css";
import { ControlToy } from "./ControlToy";
import { Crosses, VRule } from "./Grid";
+import { ModelDetails } from "./ModelDetails";
+import { Tex } from "./Tex";
export function ControlSection() {
// Bisection over the same simulation the toy runs (about 10 ms of
@@ -27,12 +29,18 @@ export function ControlSection() {
Make the controller late.
- It sees the pole d ms late. Push d past{" "}
- {deadline} ms and it falls.
+ It sees the pole d ms late. Past {deadline}{" "}
+ ms it can no longer settle. Push further and it falls.
-
+ d, theta: {"\\theta"} }}
+ details={
+
+ }
+ />
);
}
diff --git a/src/components/ControlToy.module.css b/src/components/ControlToy.module.css
index 9224537..9831d77 100644
--- a/src/components/ControlToy.module.css
+++ b/src/components/ControlToy.module.css
@@ -37,28 +37,13 @@
/* ----------------------------------------------------------------- header */
.meta {
- composes: row from "./Grid.module.css";
- display: flex;
+ composes: figHead from "./Grid.module.css";
flex-wrap: wrap;
- align-items: center;
- justify-content: space-between;
- gap: 10px 16px;
- min-height: 44px;
- padding: 10px calc(var(--late) + var(--pad)) 10px var(--pad);
- font-family: var(--mono);
- font-size: 11px;
- font-weight: 500;
- letter-spacing: 0.08em;
- text-transform: uppercase;
- color: var(--ink-muted);
+ padding-top: 10px;
+ padding-bottom: 10px;
}
.metaFig {
- color: var(--ink);
- white-space: nowrap;
-}
-.metaFig span {
- margin-left: 10px;
- color: var(--ink-muted);
+ composes: figNo from "./Grid.module.css";
}
/* Phones: the figure name and tag on one line, the readouts under them */
@@ -79,25 +64,18 @@
.readouts dt {
font-size: 10.5px;
}
-.readouts dt i {
- font: italic 400 13px/1 var(--sans);
- letter-spacing: 0;
- text-transform: none;
-}
.readouts dd {
margin: 0;
color: var(--ink);
font-variant-numeric: tabular-nums;
+}
+.readouts dd:not(.status) {
letter-spacing: 0.02em;
text-transform: none;
}
.readouts dd[data-late="true"] {
color: var(--accent);
}
-.readouts .status {
- letter-spacing: 0.14em;
- text-transform: uppercase;
-}
/* Missed snaps to a filled maroon chip, like a pressed button */
.readouts .status[data-late="true"] {
border-color: var(--accent);
@@ -107,9 +85,6 @@
@media (min-width: 900px) {
.meta {
- display: grid;
- grid-template-columns: calc(var(--c3) - var(--pad)) 1fr auto;
- gap: 0;
padding-top: 0;
padding-bottom: 0;
}
@@ -366,6 +341,7 @@
}
.scopeHead {
+ composes: numbered from "./Grid.module.css";
display: flex;
flex-wrap: wrap;
justify-content: space-between;
@@ -376,22 +352,15 @@
font-size: 10.5px;
line-height: 1.5;
}
-.scopeHead b {
- margin-right: 10px;
- color: var(--ink);
- font-weight: 500;
- letter-spacing: 0.08em;
- text-transform: uppercase;
-}
.scopeKey {
display: flex;
flex-wrap: wrap;
gap: 2px 12px;
}
+/* Its height is SCOPE_H, set inline */
.scopeBox {
position: relative;
- height: 112px;
margin: 0 var(--pad);
}
.scope {
@@ -464,14 +433,10 @@
/* ---------------------------------------------------------------- caption */
.caption {
- composes: row split from "./Grid.module.css";
+ composes: row split caption from "./Grid.module.css";
row-gap: 12px;
padding-top: 16px;
padding-bottom: 32px;
- color: var(--ink-muted);
- font-family: var(--mono);
- font-size: 11px;
- line-height: 1.55;
}
.capLabel {
composes: label from "./Grid.module.css";
@@ -484,88 +449,12 @@
max-width: 62em;
margin: 0;
}
-.capText b {
- margin-right: 10px;
- color: var(--ink);
- font-weight: 500;
- letter-spacing: 0.08em;
- text-transform: uppercase;
-}
.capText .tag {
display: inline-block;
margin-left: 4px;
vertical-align: 1px;
}
-.caption i {
- font: italic 400 12.5px/1 var(--sans);
-}
-
-/* Closed by default; the summary is a quiet mono toggle */
-.more {
- margin-top: 12px;
-}
-.more summary {
- width: fit-content;
- cursor: pointer;
- list-style: none;
- color: var(--ink);
- letter-spacing: 0.08em;
- text-transform: uppercase;
-}
-.more summary::-webkit-details-marker {
- display: none;
-}
-.more summary::before {
- content: "+";
- display: inline-block;
- width: 2ch;
- color: var(--accent);
-}
-.more[open] summary::before {
- content: "−";
-}
-.more summary:hover {
- color: var(--accent);
-}
-.more summary:focus-visible {
- outline: 1px solid var(--accent);
- outline-offset: 3px;
-}
-
-/* Each entry under its own hairline, two to a row on wide screens */
-.model {
- display: grid;
- grid-template-columns: minmax(0, 1fr);
- gap: 14px 32px;
- margin: 14px 0 0;
-}
-.model > div {
- padding-top: 8px;
- border-top: 1px solid var(--rule);
-}
-.model dt {
- margin-bottom: 4px;
- color: var(--ink-muted);
- font-size: 10px;
- font-weight: 500;
- letter-spacing: 0.1em;
- text-transform: uppercase;
-}
-.model dd {
- margin: 0;
-}
-.model b {
- color: var(--ink);
- font-weight: 500;
-}
-
-@media (min-width: 600px) {
- .model {
- grid-template-columns: repeat(2, minmax(0, 1fr));
- }
-}
-
@media (min-width: 900px) {
.caption {
padding-top: 22px;
diff --git a/src/components/ControlToy.tsx b/src/components/ControlToy.tsx
index 694ef9b..c5b64bc 100644
--- a/src/components/ControlToy.tsx
+++ b/src/components/ControlToy.tsx
@@ -2,7 +2,9 @@
import {
type MouseEvent,
+ type ReactNode,
useEffect,
+ useLayoutEffect,
useId,
useMemo,
useRef,
@@ -11,17 +13,15 @@ import {
} from "react";
import {
- AUTO_NUDGE_MS,
type CartPole,
DEG,
- GAINS,
MAX_DELAY_MS,
MODEL,
- NUDGE,
SCENARIO_MS,
runScenario,
} from "@/lib/cartpole";
import { onFrame } from "@/lib/frameLoop";
+import { prefersReducedMotion, subscribeReducedMotion } from "@/lib/motion";
import {
applyMech,
@@ -38,28 +38,26 @@ import {
scopeNodes,
} from "./cartpolePaint";
import styles from "./ControlToy.module.css";
+import { Mechanism, Scope } from "./CartPoleDrawings";
import { Crosses, VRule } from "./Grid";
import { LatencyKnob } from "./LatencyKnob";
const INITIAL_DELAY_MS = 30;
const CATCH_TILT = 0.5 * DEG;
-const RM = "(prefers-reduced-motion: reduce)";
-function subscribeRM(cb: () => void) {
- const mq = window.matchMedia(RM);
- mq.addEventListener("change", cb);
- return () => mq.removeEventListener("change", cb);
-}
-const getRM = () => window.matchMedia(RM).matches;
-const getRMServer = () => false;
-
type Props = {
deadlineMs: number; // from findDeadline(), run at build time
- marginMs: number; // from linearDelayMargin()
+ // Typeset by the server (Tex), so KaTeX never ships to the browser
+ math: { d: ReactNode; theta: ReactNode };
+ details: ReactNode;
};
-export function ControlToy({ deadlineMs, marginMs }: Props) {
- const reduced = useSyncExternalStore(subscribeRM, getRM, getRMServer);
+export function ControlToy({ deadlineMs, math, details }: Props) {
+ const reduced = useSyncExternalStore(
+ subscribeReducedMotion,
+ prefersReducedMotion,
+ () => false,
+ );
const [delay, setDelay] = useState(INITIAL_DELAY_MS);
const [liveFall, setLiveFall] = useState(null);
const [size, setSize] = useState({ w: 640, h: 320, sw: 640 });
@@ -80,8 +78,8 @@ export function ControlToy({ deadlineMs, marginMs }: Props) {
const shown = useMemo(() => runScenario(scenarioDelay), [scenarioDelay]);
const mg = useMemo(() => mechGeom(size.w, size.h), [size.w, size.h]);
const sg = useMemo(() => scopeGeom(size.sw), [size.sw]);
- const f0 = mechFrame(shown, mg);
- const sc0 = scopeFrame(shown, sg);
+ const f0 = useMemo(() => mechFrame(shown, mg), [shown, mg]);
+ const sc0 = useMemo(() => scopeFrame(shown, sg), [shown, sg]);
const fall = reduced
? shown.fallen
@@ -123,7 +121,8 @@ export function ControlToy({ deadlineMs, marginMs }: Props) {
const mech = mechRef.current;
const scope = scopeRef.current;
if (!stage || !box || !mech || !scope) return;
- if (!simRef.current) simRef.current = runScenario(INITIAL_DELAY_MS);
+ // Live, the still frame is the 8 s warm-up: carry on from a copy
+ if (!simRef.current) simRef.current = shown.clone();
const sim = simRef.current;
const mn = mechNodes(mech);
const sn = scopeNodes(scope);
@@ -202,15 +201,18 @@ export function ControlToy({ deadlineMs, marginMs }: Props) {
document.removeEventListener("visibilitychange", onVisibility);
wakeRef.current = null;
};
- }, [reduced]);
+ }, [reduced, shown]);
+ // Also when the live loop starts, so a simulation created after the
+ // knob has moved runs at the knob's delay
useEffect(() => {
if (simRef.current) simRef.current.delay = delay;
- }, [delay]);
+ }, [delay, reduced]);
// A React render re-applies the first-frame attributes only when they
- // change (a resize). Put the live pose back straight away.
- useEffect(() => {
+ // change: a resize, or the drawings remounting. Put the live pose back
+ // before the browser paints.
+ useLayoutEffect(() => {
if (reduced) return;
const sim = simRef.current;
const mech = mechRef.current;
@@ -218,7 +220,7 @@ export function ControlToy({ deadlineMs, marginMs }: Props) {
if (!sim || !mech || !scope) return;
applyMech(mechNodes(mech), mechFrame(sim, mg), true);
applyScope(scopeNodes(scope), scopeFrame(sim, sg));
- });
+ }, [reduced, mg, sg]);
function nudge(dir: 1 | -1) {
const sim = simRef.current;
@@ -239,10 +241,9 @@ export function ControlToy({ deadlineMs, marginMs }: Props) {
function onStageClick(e: MouseEvent) {
if ((e.target as Element).closest("[data-overlay]")) return;
const sim = simRef.current;
- const g = geomRef.current?.mg;
- if (reduced || !sim || !g || sim.fallen) return;
+ if (reduced || !sim || sim.fallen) return;
const rect = e.currentTarget.getBoundingClientRect();
- const bobX = rect.left + (bobScreenX(sim, g) * rect.width) / g.w;
+ const bobX = rect.left + (bobScreenX(sim, mg) * rect.width) / mg.w;
nudge(e.clientX < bobX ? 1 : -1);
}
@@ -252,9 +253,6 @@ export function ControlToy({ deadlineMs, marginMs }: Props) {
const clipId = `${uid}-clip`;
const traceId = `${uid}-trace`;
const capId = `${uid}-cap`;
- const secTicks: number[] = [];
- for (let k = 0; k <= SCENARIO_MS / 1000; k++) secTicks.push(k);
- const yOf = (deg: number) => sg.mid - deg * sg.degPx;
return (
@@ -270,9 +268,7 @@ export function ControlToy({ deadlineMs, marginMs }: Props) {
Fig. 3A cart-pole under state feedback, read{" "}
- d ms late.{" "}
+ {math.d} ms late.{" "}
Simulated
- {/* The model's parameters, collapsed under the figure */}
-
- Model details
-
-
-
Plant
-
- Cart {MODEL.cartMass.toFixed(1)} kg on a ±
- {MODEL.trackHalf} m track. Pole:{" "}
- {MODEL.poleMass} kg point mass on a{" "}
- {MODEL.poleLength} m massless rod.
-
-
-
-
Controller
-
- u = {GAINS.th}θ + {GAINS.om}ω + {GAINS.x}x +{" "}
- {GAINS.v}v, clipped to ±{MODEL.forceLimit}{" "}
- N. LQR gains, rounded. It reads the state
- from a ring buffer, d steps back.
-
-
-
-
Physics
-
- RK4, fixed {MODEL.stepMs} ms step. The
- controller runs every step (1 kHz). Test
- nudge: {NUDGE} rad/s every{" "}
- {AUTO_NUDGE_MS / 1000} s, alternating sides.
-
-
-
-
Deadline
-
- {deadlineMs} ms: the largest d{" "}
- at which a 1 µrad tilt still dies out, found
- by bisection on this simulation at build
- time. The linearised loop's delay
- margin, {marginMs.toFixed(1)} ms, agrees to
- within a step.
-
-
-
-
+ {details}
diff --git a/src/components/EmptySection.tsx b/src/components/EmptySection.tsx
deleted file mode 100644
index 185c166..0000000
--- a/src/components/EmptySection.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import { ButtonLink } from "./Button";
-import styles from "./EmptySection.module.css";
-import { Crosses, VRule } from "./Grid";
-import { CONTACTS, EMAIL, SECTIONS, type Section } from "./siteData";
-import { TimingStrip } from "./TimingStrip";
-
-const two = (n: number) => String(n).padStart(2, "0");
-
-// Every nav page until it has content: its name, an undefined ACK, and a
-// line on what will go there. Contact is the exception: it already has its
-// content, the ways to reach the club.
-export function EmptySection({ slug }: { slug: Section["slug"] }) {
- const i = SECTIONS.findIndex((s) => s.slug === slug);
- const page = SECTIONS[i];
- const contact = slug === "contact";
-
- return (
- <>
-
-
-
-