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
14 changes: 13 additions & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ LibXR 是跨平台的 C++ 兼容层,包含外设驱动、数据结构、通信

[XRobot Onboarding](https://xrobot.work/XRobot-Onboarding/)

![XRobot Logo](/img/XRobot.png)
import ThemedImage from '@theme/ThemedImage';
import useBaseUrl from '@docusaurus/useBaseUrl';

<ThemedImage
className="xr-doc-logo"
alt="XRobot"
width={175}
height={64}
sources={{
light: useBaseUrl('/img/xrobot-wordmark.svg'),
dark: useBaseUrl('/img/xrobot-wordmark-paper.svg'),
}}
/>
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
trailingSlash: false,
onBrokenLinks: 'throw',
onDuplicateRoutes: 'warn',
favicon: 'img/XRobot.png',
favicon: 'img/favicon.svg',

organizationName: 'xrobot-org',
projectName: 'xrobot-org.github.io',
Expand Down
14 changes: 13 additions & 1 deletion i18n/en/docusaurus-plugin-content-docs/current/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ The debug interfaces, XRUSB, advanced programming, design concepts and performan

[XRobot Onboarding](https://xrobot.work/XRobot-Onboarding/) (Chinese)

![XRobot Logo](/img/XRobot.png)
import ThemedImage from '@theme/ThemedImage';
import useBaseUrl from '@docusaurus/useBaseUrl';

<ThemedImage
className="xr-doc-logo"
alt="XRobot"
width={175}
height={64}
sources={{
light: useBaseUrl('/img/xrobot-wordmark.svg'),
dark: useBaseUrl('/img/xrobot-wordmark-paper.svg'),
}}
/>
37 changes: 29 additions & 8 deletions src/components/showcase/RobotModules/arm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
*
* drawArm() paints through the engine's `g` wrapper onto a canvas; here, as in the exporter (of which makeXR5 / Rec / makeG
* are a port), a recording canvas collects the fills, strokes and texts, and they become SVG
* markup with the colours of the current theme (TOKENS in armRig.js, both themes). The static file keeps the
* same elements at the rest pose with theme variables, so the still frame and the first animated frame match.
* markup with the colours of the current theme, read from the page's CSS variables (xrstyle-tokens.css,
* xrstyle-materials.css) when each frame is drawn. The static file keeps the same elements at the rest pose with
* theme variables, so the still frame and the first animated frame match.
* Only loaded in the browser (dynamic import from index.tsx); nothing here touches the DOM at module level.
*/
import { ANCHORS, ARM_K, ARM_KEYS, TOKENS, loadArmBeat } from './armRig.js';
import { ANCHORS, ARM_K, ARM_KEYS, loadArmBeat } from './armRig.js';
import type { ArmPose } from './sim';

export { ARM_KEYS };

type Theme = 'light' | 'dark';
type Tokens = (name: string) => string;
type Pt = [number, number];
type Grad = { lg: true; p0: Pt; p1: Pt; stops: Array<[number, string]>; addColorStop?: (u: number, c: string) => void };
type El =
Expand All @@ -28,10 +30,28 @@ const depth = (p: number[]) => p[1] - p[0] + (p[2] || 0);
const sub = (a: number[], b: number[]) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
const f1 = (v: number) => (Math.round(v * 10) / 10).toString();

// ------------------------------------------------------------------ theme colours from the page's CSS variables
// The drawing shades and mixes its colours (rgb(), shade(), mixc() in armRig.js), so it needs resolved values, not
// var() references: they are read from <html>, whose data-theme is the theme being drawn. XRobot Style has no accent
// colour; the beat's `hero` (the active-joint marker, not drawn in the teach motion) is drawn in ink.
const TOKEN_ALIAS: Record<string, string> = { hero: 'ink' };
function cssTokens(): Tokens {
const style = getComputedStyle(document.documentElement);
const memo = new Map<string, string>();
return (name) => {
let v = memo.get(name);
if (v === undefined) {
v = style.getPropertyValue('--' + (TOKEN_ALIAS[name] || name)).trim();
if (!v) throw new Error('token ' + name);
memo.set(name, v);
}
return v;
};
}

// ------------------------------------------------------------------ XR5 stub: enough engine for the beat to load and draw
/* eslint-disable @typescript-eslint/no-explicit-any */
function makeXR5(theme: { v: Theme }): any {
const T = () => (TOKENS as Record<Theme, Record<string, string>>)[theme.v];
function makeXR5(theme: { v: Theme; tok: Tokens }): any {
const noop = () => {};
const callable = (): any =>
new Proxy(function () {}, { get: (_t, k) => (k === Symbol.toPrimitive ? () => 0 : callable()), apply: () => callable() });
Expand All @@ -44,8 +64,8 @@ function makeXR5(theme: { v: Theme }): any {
ease: (t: number) => t * t * (3 - 2 * t),
},
iso: { PJ, C, depth, add: (a: number[], b: number[]) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]], mul: (a: number[], k: number) => [a[0] * k, a[1] * k, a[2] * k], sub },
tok: (n: string) => { const v = T()[n]; if (v === undefined) throw new Error('token ' + n); return v; },
mat: (m: string) => [T()['m-' + m], T()['m-' + m + '-l'], T()['m-' + m + '-f']],
tok: (n: string) => theme.tok(n),
mat: (m: string) => [theme.tok('m-' + m), theme.tok('m-' + m + '-l'), theme.tok('m-' + m + '-f')],
theme: () => theme.v,
anchor: (n: string) => { const a = (ANCHORS as Record<string, number[]>)[n]; if (!a) throw new Error('anchor ' + n); return a.slice(); },
clock: { t: 0, te: 0 }, reduced: () => true,
Expand Down Expand Up @@ -188,12 +208,13 @@ function markup(els: El[]): string {
export type ArmRig = { draw(pose: ArmPose, theme: Theme): string };

export function createArmRig(): ArmRig {
const theme = { v: 'light' as Theme };
const theme: { v: Theme; tok: Tokens } = { v: 'light', tok: () => { throw new Error('no theme yet'); } };
const X = loadArmBeat(makeXR5(theme), stubDocument);
X.resetSim();
return {
draw(pose, th) {
theme.v = th;
theme.tok = cssTokens();
X.SIM.q = pose.q.map((d) => (d * Math.PI) / 180);
X.SIM.grip = pose.grip;
const g = makeG(ARM_K);
Expand Down
4 changes: 2 additions & 2 deletions src/components/showcase/RobotModules/armRig.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Robot arm drawing for RobotModules/arm.ts. Generated from the arm beat 5-1 of the XRobot Style harness
// (export_svg.py export_arm_rig), then reduced to the drawing: drawArm() and the geometry, kinematics and helpers it
// calls, with the token tables of both themes and the scene anchors it reads. arm.ts drives it along ARM_KEYS.
// calls, and the scene anchors it reads. arm.ts drives it along ARM_KEYS and supplies the colours from the page's
// CSS variables (xrstyle-tokens.css, xrstyle-materials.css).
/* eslint-disable */
// @ts-nocheck
export const TOKENS = {"light":{"paper":"#f2f3f2","paper-raised":"#ffffff","paper-sunken":"#e6e8e6","line":"#d3d6d3","line-strong":"#7c827e","ink":"#111312","ink-muted":"#4d524f","on-ink":"#f2f3f2","ch0":"#7a5c00","ch1":"#006573","ch2":"#a1206f","ch3":"#2a6e1b","pass":"#16693a","fail":"#b42318","blocked":"#7d5100","hero":"#00838f","focus":"#111312","link":"#111312","ln-sil":"#111312e6","ln-face":"#111312c7","ln-fold":"#11131273","ln-detail":"#11131247","ln-wire":"#1113129e","m-plinth":"#ffffff","m-plinth-l":"#e8e8e8","m-plinth-f":"#d1d1d1","m-neutral":"#e5e6e4","m-neutral-l":"#cecfcd","m-neutral-f":"#b8b9b7","m-pcb-own":"#3e6aa4","m-pcb-own-l":"#2a568e","m-pcb-own-f":"#164278","m-pcb-green":"#397054","m-pcb-green-l":"#245c41","m-pcb-green-f":"#0c482f","m-pcb-black":"#40454c","m-pcb-black-l":"#2e3339","m-pcb-black-f":"#1d2228","m-pcb-red":"#914743","m-pcb-red-l":"#7b3330","m-pcb-red-f":"#651f1e","m-gold":"#deb866","m-gold-l":"#c7a24f","m-gold-f":"#b18c38","m-silk":"#f2f2ef","m-silk-l":"#dbdbd8","m-silk-f":"#c4c4c1","m-ic":"#262a28","m-ic-l":"#161918","m-ic-f":"#070a08","m-alu":"#dee2e5","m-alu-l":"#c7cbce","m-alu-f":"#b1b5b8","m-graphite":"#3a3d41","m-graphite-l":"#282b2f","m-graphite-f":"#181a1e","m-plastic-white":"#e4e3df","m-plastic-white-l":"#cdccc8","m-plastic-white-f":"#b7b6b2","m-cream":"#f0e7d6","m-cream-l":"#d9d0bf","m-cream-f":"#c2baa9","m-xt-yellow":"#e1c15d","m-xt-yellow-l":"#caab45","m-xt-yellow-f":"#b4952b","m-print-blue":"#6689b3","m-print-blue-l":"#52749d","m-print-blue-f":"#3e6087","m-copper":"#b97c52","m-copper-l":"#a2673d","m-copper-f":"#8c5329","m-fr4-edge":"#cbc9a8","m-fr4-edge-l":"#b5b392","m-fr4-edge-f":"#9f9d7d","m-mannequin":"#d6d0c9","m-mannequin-l":"#bfbab3","m-mannequin-f":"#a9a49d","m-passive":"#c9b28c","m-passive-l":"#b39c77","m-passive-f":"#9d8762","m-glass":"#17262e","m-glass-l":"#07161d","m-glass-f":"#00070d","m-screen":"#0f1211","m-screen-l":"#030504","m-screen-f":"#000000","m-led-r":"#c35045","m-led-r-l":"#ab3a31","m-led-r-f":"#93221d","m-led-g":"#2a904b","m-led-g-l":"#027b37","m-led-g-f":"#006623","m-led-b":"#2e69b2","m-led-b-l":"#17549b","m-led-b-f":"#004085","f-top":"#e5e6e4","f-left":"#cecfcd","f-front":"#b8b9b7","f-dark":"#262a28","hero-t":"#40a8b4","hero-f":"#00606b","hero-glow":"#00838f59","log-d":"#ff85cb","log-i":"#4fdded","log-p":"#8be36a","log-w":"#ffd84d","log-e":"#ff8a7a","space-1":"4px","space-2":"8px","space-3":"12px","space-4":"16px","space-6":"24px","space-8":"32px","space-12":"48px","space-16":"64px","radius-none":"0","chamfer":"8px","stroke":"1px","stroke-strong":"2px","duration-fast":"80ms","t-press":"120ms","duration-base":"160ms","measure-prose":"40em","measure-code":"100ch","measure-page":"1200px","size-control":"36px","size-target":"32px","size-nav":"56px","font-sans":"system-ui, -apple-system, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei UI\", \"Microsoft YaHei\", \"Noto Sans CJK SC\", \"Source Han Sans SC\", sans-serif","font-mono":"ui-monospace, \"SF Mono\", \"Cascadia Mono\", \"JetBrains Mono\", Consolas, \"Noto Sans Mono CJK SC\", monospace"},"dark":{"paper":"#0c0e0d","paper-raised":"#151816","paper-sunken":"#070908","line":"#2a2e2c","line-strong":"#6f7672","ink":"#e6e8e6","ink-muted":"#a3a9a5","on-ink":"#0c0e0d","ch0":"#ffd84d","ch1":"#4fdded","ch2":"#ff85cb","ch3":"#8be36a","pass":"#5bd68a","fail":"#ff8a7a","blocked":"#f0b54a","hero":"#4fdded","focus":"#e6e8e6","link":"#e6e8e6","ln-sil":"#e6e8e68c","ln-face":"#e6e8e675","ln-fold":"#e6e8e638","ln-detail":"#e6e8e629","ln-wire":"#e6e8e680","m-plinth":"#151816","m-plinth-l":"#0a0d0b","m-plinth-f":"#040604","m-neutral":"#464b48","m-neutral-l":"#393e3b","m-neutral-f":"#2f3331","m-pcb-own":"#2c4e7b","m-pcb-own-l":"#1f406c","m-pcb-own-f":"#143560","m-pcb-green":"#28523c","m-pcb-green-l":"#1a442f","m-pcb-green-f":"#0e3a25","m-pcb-black":"#32363b","m-pcb-black-l":"#26292e","m-pcb-black-f":"#1c2024","m-pcb-red":"#6c3531","m-pcb-red-l":"#5d2824","m-pcb-red-f":"#511d1a","m-gold":"#b89a5a","m-gold-l":"#a88b4b","m-gold-f":"#9c7f3f","m-silk":"#d1d1ce","m-silk-l":"#c1c1be","m-silk-f":"#b4b4b1","m-ic":"#1b1e1c","m-ic-l":"#101311","m-ic-f":"#080a08","m-alu":"#6b6f73","m-alu-l":"#5d6165","m-alu-f":"#525659","m-graphite":"#3a3e43","m-graphite-l":"#2d3136","m-graphite-f":"#24272c","m-plastic-white":"#484845","m-plastic-white-l":"#3b3b38","m-plastic-white-f":"#31312e","m-cream":"#b1aa9c","m-cream-l":"#a19b8d","m-cream-f":"#958e81","m-xt-yellow":"#b69c4b","m-xt-yellow-l":"#a68d3b","m-xt-yellow-f":"#9a802d","m-print-blue":"#496588","m-print-blue-l":"#3b5779","m-print-blue-f":"#314c6d","m-copper":"#936240","m-copper-l":"#845432","m-copper-f":"#774927","m-fr4-edge":"#898870","m-fr4-edge-l":"#7a7962","m-fr4-edge-f":"#6f6e56","m-mannequin":"#5c5752","m-mannequin-l":"#4e4945","m-mannequin-f":"#433f3a","m-passive":"#8e7b5e","m-passive-l":"#7f6c50","m-passive-f":"#736145","m-glass":"#111c22","m-glass-l":"#061116","m-glass-f":"#02080d","m-screen":"#0f1211","m-screen-l":"#050807","m-screen-f":"#020302","m-led-r":"#c65a4f","m-led-r-l":"#b54b41","m-led-r-f":"#a73e35","m-led-g":"#3b9555","m-led-g-l":"#298647","m-led-g-f":"#187a3b","m-led-b":"#467cc0","m-led-b-l":"#376db0","m-led-b-f":"#2c61a3","f-top":"#464b48","f-left":"#393e3b","f-front":"#2f3331","f-dark":"#1b1e1c","hero-t":"#7dffff","hero-f":"#02b6c6","hero-glow":"#4fdded59","log-d":"#ff85cb","log-i":"#4fdded","log-p":"#8be36a","log-w":"#ffd84d","log-e":"#ff8a7a","space-1":"4px","space-2":"8px","space-3":"12px","space-4":"16px","space-6":"24px","space-8":"32px","space-12":"48px","space-16":"64px","radius-none":"0","chamfer":"8px","stroke":"1px","stroke-strong":"2px","duration-fast":"80ms","t-press":"120ms","duration-base":"160ms","measure-prose":"40em","measure-code":"100ch","measure-page":"1200px","size-control":"36px","size-target":"32px","size-nav":"56px","font-sans":"system-ui, -apple-system, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei UI\", \"Microsoft YaHei\", \"Noto Sans CJK SC\", \"Source Han Sans SC\", sans-serif","font-mono":"ui-monospace, \"SF Mono\", \"Cascadia Mono\", \"JetBrains Mono\", Consolas, \"Noto Sans Mono CJK SC\", monospace"}};
export const ANCHORS = {"arm.base":[0.0,120.0,0.0],"armmat.ring":[-440.0,-16.0,6.0],"armmat.c":[-300.0,-15.0,6.0],"arm.panel":[-110.3,-26.0,84.0],"arm.led":[-110.3,46.0,62.0],"arm.plug":[0.0,123.5,28.0],"arm.o":[0.0,0.0,0.0],"arm.S":[0.0,0.0,316.0],"arm.j2":[0.0,84.0,316.0],"arm.j3":[-187.78862511435634,60.0,669.1790371435707],"arm.j4":[-511.1478406547085,28.0,564.1132590560885],"arm.grip":[-511.1478406547085,-16.0,344.1132590560885],"arm.top":[-187.78862511435634,0.0,757.1790371435707],"arm.back":[130.0,-130.0,0.0],"arm.front":[-500.0,200.0,0.0],"arm.envL":[-600.0,-60.0,240.0],"arm.envT":[-200.0,60.0,810.0]};
export const ARM_REST = {"q": [35, 62, -80, -72], "grip": 20};
export const ARM_K = 0.55;
Expand Down
Loading
Loading