|
| 1 | +# Agent Guidelines for Background Documentation |
| 2 | + |
| 3 | +Guidelines for AI agents working with `docs/background/` theoretical documentation. |
| 4 | + |
| 5 | +## Purpose of This Directory |
| 6 | + |
| 7 | +`docs/background/` contains **theoretical background** derived from academic PDFs written by |
| 8 | +DART's original authors. This is reference material explaining the mathematics behind the code. |
| 9 | + |
| 10 | +| Directory | Content | Original Source | |
| 11 | +| ----------- | ----------------------------------------------- | ------------------- | |
| 12 | +| `dynamics/` | Lagrangian mechanics, articulated body dynamics | `docs/dynamics.pdf` | |
| 13 | +| `lcp/` | Linear Complementarity Problem solvers | `docs/lcp.pdf` | |
| 14 | + |
| 15 | +## Key Rules |
| 16 | + |
| 17 | +### 1. Attribution is Non-Negotiable |
| 18 | + |
| 19 | +Every page derived from the original PDFs **MUST** include the attribution header: |
| 20 | + |
| 21 | +```markdown |
| 22 | +> **Attribution**: This content is derived from "[Title]" by [Authors]. |
| 23 | +> The original PDF is preserved at `docs/[file].pdf`. |
| 24 | +``` |
| 25 | + |
| 26 | +**Never remove or obscure original authorship.** |
| 27 | + |
| 28 | +### 2. Original PDFs are Authoritative |
| 29 | + |
| 30 | +When in doubt about mathematical correctness, **defer to the original PDF**. |
| 31 | +The markdown versions are for maintainability; the PDFs are the authoritative source. |
| 32 | + |
| 33 | +```bash |
| 34 | +# To view original PDFs: |
| 35 | +# docs/dynamics.pdf - Multibody dynamics tutorial |
| 36 | +# docs/lcp.pdf - LCP contact handling |
| 37 | +``` |
| 38 | + |
| 39 | +### 3. Notation Consistency |
| 40 | + |
| 41 | +Use the notation glossary to map between PDF symbols and DART code: |
| 42 | + |
| 43 | +| PDF Notation | DART API | Notes | |
| 44 | +| ------------ | ----------------- | ---------------------- | |
| 45 | +| $q$ | `getPositions()` | Generalized positions | |
| 46 | +| $\dot{q}$ | `getVelocities()` | Generalized velocities | |
| 47 | +| $M(q)$ | `getMassMatrix()` | Mass matrix | |
| 48 | +| $\tau$ | `getForces()` | Generalized forces | |
| 49 | + |
| 50 | +See [`dynamics/notation-glossary.md`](dynamics/notation-glossary.md) for the complete mapping. |
| 51 | + |
| 52 | +### 4. LaTeX Math for Equations |
| 53 | + |
| 54 | +These docs use **LaTeX math syntax** for equations (GitHub renders this natively): |
| 55 | + |
| 56 | +```markdown |
| 57 | +✅ Correct: Inline math uses single dollars: $M(q)\ddot{q} + C(q,\dot{q}) = \tau$ |
| 58 | +✅ Correct: Display equations use double dollars: |
| 59 | +$$M(q)\ddot{q} + C(q,\dot{q}) + g(q) = \tau$$ |
| 60 | + |
| 61 | +❌ Avoid: Unicode math like `M(q)q̈ + C(q,q̇) = τ` (harder to read/search) |
| 62 | +❌ Avoid: Code blocks for equations (no rendering) |
| 63 | +``` |
| 64 | + |
| 65 | +GitHub renders LaTeX math natively since 2022. This provides better readability for complex equations. |
| 66 | + |
| 67 | +### 5. Cross-Reference to Code |
| 68 | + |
| 69 | +When explaining concepts, link to the implementing code: |
| 70 | + |
| 71 | +```markdown |
| 72 | +The mass matrix is computed by [`Skeleton::getMassMatrix()`][1]. |
| 73 | + |
| 74 | +[1]: ../../dart/dynamics/Skeleton.hpp |
| 75 | +``` |
| 76 | + |
| 77 | +Or use inline references: |
| 78 | + |
| 79 | +```markdown |
| 80 | +See `dart/dynamics/Skeleton.hpp` for the implementation. |
| 81 | +``` |
| 82 | + |
| 83 | +## When to Edit These Docs |
| 84 | + |
| 85 | +### DO Edit When: |
| 86 | + |
| 87 | +- Fixing typos or formatting errors |
| 88 | +- Adding cross-references to DART code |
| 89 | +- Updating notation glossary for new APIs |
| 90 | +- Adding navigation links |
| 91 | +- Clarifying content (mark additions clearly) |
| 92 | + |
| 93 | +### DO NOT Edit When: |
| 94 | + |
| 95 | +- The math seems wrong → Check the original PDF first |
| 96 | +- You want to "improve" explanations → Add commentary separately |
| 97 | +- API names changed → Update the notation glossary, not the derivations |
| 98 | + |
| 99 | +## File Organization |
| 100 | + |
| 101 | +``` |
| 102 | +docs/background/ |
| 103 | +├── README.md # Index and attribution summary |
| 104 | +├── ATTRIBUTION.md # Attribution template |
| 105 | +├── AGENTS.md # This file |
| 106 | +├── dynamics/ # From dynamics.pdf |
| 107 | +│ ├── 01_introduction.md |
| 108 | +│ ├── 02_lagrangian-dynamics.md |
| 109 | +│ ├── ... |
| 110 | +│ └── notation-glossary.md |
| 111 | +└── lcp/ # From lcp.pdf (already migrated) |
| 112 | + ├── 01_problem-statement.md |
| 113 | + ├── 02_overview.md |
| 114 | + └── ... |
| 115 | +``` |
| 116 | + |
| 117 | +## Migration Status |
| 118 | + |
| 119 | +| Source | Target | Status | |
| 120 | +| ------------------- | --------------------------- | ------------------------ | |
| 121 | +| `docs/lcp.pdf` | `docs/background/lcp/` | ✅ Complete (LaTeX math) | |
| 122 | +| `docs/dynamics.pdf` | `docs/background/dynamics/` | ✅ Complete (LaTeX math) | |
| 123 | + |
| 124 | +## Related Documentation |
| 125 | + |
| 126 | +- [`docs/onboarding/dynamics.md`](../onboarding/dynamics.md) — Code-level dynamics exploration |
| 127 | +- [`docs/onboarding/constraints.md`](../onboarding/constraints.md) — Constraint system internals |
| 128 | + |
| 129 | +## Quick Reference: Adding New Content |
| 130 | + |
| 131 | +1. **New page from PDF**: Copy structure, add attribution header, use LaTeX math syntax |
| 132 | +2. **New code reference**: Add to notation glossary, link to source file |
| 133 | +3. **Correction**: Note "Correction from original: [reason]" in a comment |
| 134 | +4. **Addition**: Mark clearly as "[Added for DART context]" |
0 commit comments