This commit is contained in:
grove5_admin committed 2026-04-23 21:34:59 -07:00
1 parent 5e2e553dda
commit 474437ad15
2 files changed
+172 -86

No files matched your search

+171 -61
View File
@@ -1,112 +1,222 @@
# BagTag
**The machine-readable identification standard for Grove5 Cultivar Select bags.**
**A free, open identification standard for mushroom cultivation bags.**
BagTag uses two codes with two completely separate audiences and two completely separate jobs.
Designed by [Grove5](https://grove5.com) for the [Cultivar](https://grove5.com/cultivar) smart grow chamber — **given freely to the mycology community.**
BagTag encodes everything a machine needs to know about a bag: **substrate**, **species**, and **size**. No app. No typing. Just scan and grow.
---
## Two codes. Two audiences. Two jobs.
## Why BagTag Exists
| | AprilTag (Front) | QR Code (Back) |
Hobbyist mycologists face a familiar frustration: every bag needs labeling, but labels get wet, smudge, or fall off. QR codes work but require phones and apps. Barcodes are fragile. Handwriting is error-prone.
BagTag solves this with **industrial-grade machine vision made accessible**:
- **AprilTag 41h12** markers — readable in milliseconds, even at angles, through condensation, with mycelium creeping over the edges
- **Packed enumeration** — 1,970 valid bag configurations encoded into 2,115 available tag IDs
- **Graceful fallbacks** — damaged tag? Scan the QR. Custom substrate? Manual entry. Nothing is a dead end.
---
## The Philosophy: Maximum Obvious, Graceful Fallback
BagTag attempts to **load every obvious combination**:
- 104 mushroom species across 32 substrate formulations
- All common commercial varieties (Oysters, Shiitake, Lion's Mane, Reishi...)
- All-in-One bags (grain + bulk), spawn-only, and bulk-only variants
- Commercial strains and experimental lines
But BagTag doesn't pretend to know everything:
- **Custom substrates** (slots 14, 23, 31) accept any species code
- **Species 127** triggers manual entry — your unidentified wild isolate works fine
- **Reserved tag IDs** (1,970–2,114) leave room for future expansion
---
## How It Works
### Dual-Code Redundancy
| | **AprilTag (Front)** | **QR Code (Back)** |
|---|---|---|
| **Faces** | Cultivar camera | Human / phone |
| **Readable by** | Machine | Human and machine |
| **Payload** | 12-bit grow profile | Full GMP traceability record |
| **Capability** | 6DOF pose estimation | Unlimited data |
| **Job** | Predeterminant grow intelligence | Supply chain, recall, transparency |
| **Human input required** | Zero | On demand |
| **Readable by** | Cultivar camera | Any phone |
| **Speed** | < 100ms | 1–3 seconds |
| **Data** | 12-bit grow profile | Full GMP traceability record |
| **Robustness** | Works damaged, occluded, at angle | Works when tag is destroyed |
| **Human input** | Zero | Optional manual override |
The QR code is a strict superset of the AprilTag payload. If the AprilTag is damaged or obscured by mycelium growth, the human scans the QR and the Cultivar receives the same grow information. Neither code is a single point of failure.
**Neither code is a single point of failure.** The QR is a strict superset — if the AprilTag fails, the human scans the QR and the Cultivar receives identical grow information.
---
## How it works
The Cultivar camera reads one AprilTag41h12 tag at bag insertion. 12 bits. In milliseconds.
### The Encoding
```
Bit 0 → Small or Large bag (1 bit)
Bits 1–5 → Substrate recipe (5 bits = 32 slots)
Bits 6–12 → Species (7 bits = 128 slots, table selected by substrate)
Logical layout: 1 bit + 5 bits + 7 bits = 13 bits (theoretical)
Size Substrate Species
Physical reality: Packed enumeration → 0–1,969 (valid bags)
→ 1,970–2,114 (reserved)
```
**Physical encoding:** Packed enumeration maps only valid (size, substrate, species) combinations to sequential tag IDs 0–1905.
From those 12 bits the Cultivar knows:
From a tag ID, the Cultivar immediately knows:
- Temperature targets for colonization and fruiting
- Humidity profile
- CO₂ and FAE schedule
- Colonization timeline estimate
- Biological efficiency baseline for yield tracking
- Humidity profile and CO₂/FAE schedule
- Colonization timeline estimates
- Biological efficiency baselines
- Fruiting trigger conditions
**No app interaction. No human input. Just put the bag in.**
**Put the bag in. The machine does the rest.**
---
## Tag family
## Quick Start
**AprilTag41h12** — 2,115 valid tag IDs, Hamming distance 12.
### Decode a Tag
Co-recommended alongside 36h11 by industrial machine vision vendors. Selected for the Cultivar because:
```bash
cd tools
python decode.py 0
# Tag ID: 0
# Size: small
# Substrate: [00] Masters Mix + Millet
# Species: [00] Blue Oyster
# (Pleurotus ostreatus)
```
- Sufficient IDs for the full BagTag encoding space
- Hamming distance 12 tolerates up to 5 misread bits — robust against condensation, mycelium occlusion, and angle
- Native 6DOF pose estimation from a single camera frame
- Lightweight decode on vision coprocessor
### Explore All Tags
```bash
python decode.py --stats # Namespace summary
python decode.py --ranges # Tag ID ranges per substrate
python decode.py --tables # Full species tables
```
### Generate Tables
```bash
python generate_tables.py
# Generates:
# - ../tables/substrates.md (all 32 substrates)
# - ../tables/species/*.md (32 per-substrate species tables)
# - ../BAGTAG_MASTER_TABLE.md (complete 0–1,969 reference)
```
---
## Repository structure
## Repository Structure
```
BagTag/
├── README.md ← this file
├── SPEC.md ← full encoding specification
├── LICENSE ← MIT
├── README.md ← This file
├── SPEC.md ← Full technical specification
├── BAGTAG_MASTER_TABLE.md ← Complete tag ID reference (auto-generated)
├── LICENSE ← MIT + AprilTag BSD attribution
│
├── tables/
│ ├── substrates.md ← all 32 substrate slots
│ └── species/ ← per-substrate species lookup tables
│ ├── aio-00.md
│ ├── aio-01.md
│ └── ...
│ ├── substrates.md ← 32 substrate slots (auto-generated)
│ └── species/ ← Per-substrate species tables
│ ├── aio-0-flagship-mm.md
│ ├── aio-1-speed-mm.md
│ └── ... (32 total)
│
└── tools/
└── decode.py ← reference decoder (tag ID → substrate + species)
├── bagtag_data.py ← 🎯 Single source of truth
├── decode.py ← Reference decoder + CLI
├── generate_tables.py ← Table generator
└── generate_tags.py ← Tag image generator (placeholder)
```
**The entire encoding lives in `tools/bagtag_data.py`.** Change that file, run `generate_tables.py`, and all documentation updates automatically.
---
## Quick decode reference
## Technical Highlights
```python
tag_id = 2048
bits = format(tag_id, '012b') # '100000000000'
### AprilTag 41h12
- 2,115 valid IDs, Hamming distance 12
- Tolerates up to 5 misread bits
- Sub-centimeter 6DOF pose estimation
- Industrial machine vision standard
size = int(bits[0], 2) # 1 = Large
substrate = int(bits[1:6], 2) # 0 = Masters Mix + Millet
species_code = int(bits[6:], 2) # 0 = Hericium erinaceus (Lion's Mane)
```
### Packed Enumeration
Instead of wasting 75% of tag IDs on invalid (substrate, species) combinations, BagTag **enumerates only valid bags**:
See `tools/decode.py` for the full reference implementation with lookup tables.
| Approach | Valid IDs | Waste |
|----------|-----------|-------|
| Naive bit-fields (13 bits) | ~1,970 | ~75% |
| **BagTag packed enum** | **1,970** | **0%** |
Each tag ID maps to exactly one valid (size, substrate, species) triple. No ambiguous decodes. No partial reads.
### Species 127
Every substrate table reserves **code 127** as "Other/prompt":
- New wild isolates
- Proprietary commercial strains
- User experiments
The Cultivar falls back to QR scan or manual entry. Nothing breaks.
---
## Documentation
| Document | Purpose |
|----------|---------|
| [SPEC.md](SPEC.md) | Complete encoding specification, bit layouts, decision trees |
| [BAGTAG_MASTER_TABLE.md](BAGTAG_MASTER_TABLE.md) | Every valid tag ID 0–1,969 decoded |
| [tables/substrates.md](tables/substrates.md) | All 32 substrate slots with descriptions |
| [tables/species/](tables/species/) | 32 per-substrate species lookup tables |
---
## For Makers & Builders
BagTag is **hardware-agnostic**. The reference decoder is pure Python. Port it to:
- Arduino + camera module
- Raspberry Pi + OpenCV
- Android/iOS apps
- Industrial PLCs
The encoding is documented, the tables are generated, the data is free.
---
## License
MIT — see [LICENSE](LICENSE)
**MIT License** — see [LICENSE](LICENSE)
BagTag uses the AprilTag library (BSD 2-Clause License). See LICENSE for third-party attribution.
Third-party: AprilTag (BSD 2-Clause), University of Michigan
**You can:**
- Use BagTag in commercial products
- Modify and redistribute
- Build proprietary Cultivar clones
- Print your own BagTags for home use
**We ask:**
- Keep the attribution
- Consider contributing improvements back
- Spread good mycology practices
---
## Part of Grove5
BagTag is one component of the [Cultivar](https://grove5.com) ecosystem.
BagTag was created for **Cultivar** — Grove5's smart dual-chamber mushroom cultivation appliance — and released freely because standards work best when they're *actually* standard.
- **Cultivar** — smart dual-chamber home mushroom cultivation appliance
- **Cultivar Select** — subscription bag service
- **BagTag** — machine-readable bag identification standard
- **[Cultivar](https://grove5.com/cultivar)** — Smart grow chamber with BagTag-native vision
- **[Cultivar Select](https://grove5.com/select)** — Subscription bag service (BagTag-encoded)
- **BagTag** — This open standard, free for everyone
> Open source software, honest hardware.
> *Open source software, honest hardware.*
---
## Community
- **Issues & PRs:** Welcome on GitHub
- **Questions:** Tag `@grove5` on socials
- **Show & Tell:** Tag your BagTag projects — we amplify good work
**Grow well.**
+1 -25
View File
@@ -184,39 +184,15 @@ Full table: see [`tables/substrates.md`](tables/substrates.md)
### AIO Substrate Slots (0–14)
| Slot | Bulk Layer | Grain Layer | Character |
|------|-----------|-------------|-----------|
| 0 | Masters Mix (HWSD/Soy Hull 50:50) | Millet | Flagship. Broad species, high yield, fast colonization. |
| 1 | Masters Mix | Rye Berry | Speed variant. Fastest colonization. |
| 2 | Masters Mix | Wheat Berry | Woody species. Slower colonization suits Shiitake, Maitake. |
| 3 | MM Lite (HWSD/Wheat Bran 80:20) | Wheat Berry | Slow woody. Reishi, Turkey Tail, Shiitake. |
| 4 | CVG (Coco Coir + Verm + Gypsum) | Millet | Clean Oyster and Lion's Mane focus. |
| 5 | CVG | Oats | Budget Oyster. Economical. |
| 6 | Pasteurized Straw | Millet | Oyster dominant. |
| 7 | Pasteurized Straw | Barley | Economy Oyster. Very low cost. |
| 8 | HWSD 100% | Wheat Berry | Pure hardwood. Reishi, Turkey Tail, slow woodland species. |
| 9 | Rye + HWSD Blended 70:30 | — | Homogeneous blend. Fast colonization + hardwood structure. |
| 10 | Soy Hull Heavy 60:40 | Millet | Advanced. High yield, strict sterile technique required. |
| 11 | Soy Hull Heavy 60:40 | Rye Berry | Advanced. Maximum aggression. |
| 12 | Cardboard + Coffee Grounds 50:50 | None (LC) | Advanced. Waste-stream Oyster. LC inoculated directly. |
| 13 | Manure Based (composted) | Rye Berry | Advanced. Agaricus, Wine Cap, dung-loving species. |
| 14 | Custom AIO | → prompt | Cultivar prompts manual entry. QR fallback preferred. |
### Grain Substrate Slots (15–21)
_To be defined. See [`tables/substrates.md`](tables/substrates.md)_
### Bulk Substrate Slots (22–28)
_To be defined. See [`tables/substrates.md`](tables/substrates.md)_
### Reserved / Other (29–31)
| Slot | Use |
|------|-----|
| 29 | Other → prompt manual entry |
| 30 | Reserved |
| 31 | Reserved |
| 31 | Other -> prompt manual entry |
---