Skip to content

Add spatialmath worksheet game for learning spatial transformations#5902

Draft
NickPPC wants to merge 4 commits intomainfrom
worktree-spatial-math-worksheet-game
Draft

Add spatialmath worksheet game for learning spatial transformations#5902
NickPPC wants to merge 4 commits intomainfrom
worktree-spatial-math-worksheet-game

Conversation

@NickPPC
Copy link
Copy Markdown
Member

@NickPPC NickPPC commented Apr 1, 2026

Summary

Interactive CLI tool that teaches spatialmath transformations through guided exercises with 3D visualization. Inspired by the educational worksheet in a7c997a, this builds a 5-level progressive game covering Compose, PoseInverse, and PoseBetween with motion-tools visualization.

Changes

  • spatialmath/worksheet/cmd/main.go: Entry point with --level N flag to jump to any level (1-5) or run all
  • spatialmath/worksheet/game.go: Game engine with Question/Level types, interactive flow (show code, wait for user, reveal answer), and per-question color legend for the 3D visualizer
  • spatialmath/worksheet/levels.go: 5 progressive levels:
    • Level 1: Pure translation (Compose adds vectors)
    • Level 2: Rotation from origin (orientation affects translation direction)
    • Level 3: Compose with orientations (non-commutativity, PoseBetween)
    • Level 4: Full 3D composition (multi-axis, PoseInverse)
    • Level 5: Practical robotics scenarios (forward kinematics, frame chains)
  • spatialmath/worksheet/format.go: Pose/point/orientation display helpers with aggressive float rounding for clean output
  • spatialmath/worksheet/visualize.go: Motion-tools integration drawing asymmetric 10x20x30 boxes (blue/green/yellow inputs, red result, white origin) so orientation is visually unambiguous

Testing

  • go build ./spatialmath/worksheet/cmd compiles cleanly
  • go vet ./spatialmath/worksheet/... passes
  • go run ./spatialmath/worksheet/cmd — run all levels interactively
  • go run ./spatialmath/worksheet/cmd --level 2 — jump to a specific level
  • All answers are computed from real spatialmath calls, guaranteeing correctness
  • Visualization degrades gracefully to text-only when motion-tools is not running

Claude Code Prompts Used

  • "I would like to create a small Go command to play an educational game to learn about rdk's spatialmath library"
  • "We should visualize all the answers using the motion-tools client. We should create a box with dimensions 10, 20, 30 so people can easily see which way the pose is pointing"
  • "The game should explain which box corresponds to which situation"
  • "For level 1 question 1 we seem to be giving the explanation of the answer as part of the question / For level 1 question 4 the visualizer was cleared before I could see the results"

🤖 Generated with Claude Code

Interactive CLI tool with 5 progressive levels teaching Compose,
PoseInverse, and PoseBetween through guided exercises. Visualizes
poses as asymmetric 10x20x30 boxes via motion-tools.

Run with: go run ./spatialmath/worksheet/cmd
Jump to level: go run ./spatialmath/worksheet/cmd --level 2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Apr 1, 2026
- Wrap fmt.Print/Println/Printf in nolint helpers for CLI output
- Handle reader.ReadString errors with _ assignment
- Break long string literals to stay under 140 char limit

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 2, 2026
- Run gofumpt -extra and gci for proper formatting/import ordering
- Add package comment for revive/stylecheck
- Use nolint:errcheck for interactive ReadString calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 2, 2026
InputPoses map keys now use the actual variable names from the Setup
code (e.g. "rot", "point", "endEffector") instead of generic "a", "b".
Colors are assigned by sorted order rather than by hardcoded name map.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Availability

Scene # viamrobotics:main viamrobotics:worktree-spatial-math-worksheet-game Percent Improvement Health
1 100% 100% 0%
2 100% 100% 0%
3 100% 100% 0%
4 100% 100% 0%
5 100% 100% 0%
6 100% 100% 0%
7 100% 100% 0%
8 100% 100% 0%
9 100% 100% 0%
10 100% 100% 0%
11 100% 100% 0%

Quality

Scene # viamrobotics:main viamrobotics:worktree-spatial-math-worksheet-game Percent Improvement Probability of Improvement Health
1 1.31±0.00 1.31±0.00 0% 51%
2 0.94±0.01 0.94±0.01 0% 56%
3 6.13±0.00 6.13±0.00 -0% 50%
4 1.98±0.27 1.98±0.27 0% 50%
5 8.78±1.87 8.78±1.87 -0% 50%
6 9.33±2.99 8.94±2.48 4% 54%
7 1.95±0.38 1.95±0.38 0% 50%
8 0.94±0.01 0.94±0.01 0% 55%
9 4.54±0.41 4.54±0.41 -0% 50%
10 12.63±0.03 12.63±0.03 -0% 50%
11 0.62±0.00 0.62±0.00 -0% 49%

Performance

Scene # viamrobotics:main viamrobotics:worktree-spatial-math-worksheet-game Percent Improvement Probability of Improvement Health
1 0.02±0.00 0.02±0.00 8% 75%
2 0.03±0.00 0.03±0.00 3% 57%
3 0.02±0.00 0.02±0.01 -18% 37%
4 0.29±0.05 0.28±0.03 6% 62%
5 1.30±0.16 1.24±0.21 4% 58%
6 1.54±0.40 1.51±0.41 2% 52%
7 0.75±0.09 0.72±0.09 4% 60%
8 0.03±0.00 0.03±0.00 16% 88%
9 1.30±0.25 1.22±0.23 6% 59%
10 3.53±0.39 3.54±0.41 -0% 50%
11 0.61±0.06 0.56±0.08 8% 69%

The above data was generated by running scenes defined in the motion-testing repository
The SHA1 for viamrobotics:main is: 34f56ff99b6db31130a351e0791da3dc0fabb01c
The SHA1 for viamrobotics:worktree-spatial-math-worksheet-game is: 34f56ff99b6db31130a351e0791da3dc0fabb01c

  • 11 samples were taken for each scene

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test This pull request is marked safe to test from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants