Skip to content
Draft
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
37 changes: 31 additions & 6 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@
- Start with minimal, lean implementations focused on proof-of-concept
- Avoid creating new files until asked
- Avoid implementing things from scratch
- Avoid defensive error handling for hypothetical failures
- Avoid defensive error handling for hypothetical situations
For example, rather than using:
```python
...
try:
import some_package
except:
print("some_package not available")
exit(1)
...
```
Instead, allow errors to bubble up naturally so you can address directly and reactively rather than being overly proactive
```python
...
import some_package
...

```
> `ModuleNotFoundError: No module named 'package_name'`
- Use print statements and logging sparingly, unless asked
- Avoid light wrappers and custom classes, unless asked
- Avoid creating functions and classes, until asked
- Avoid `if __name__ == "__main__"` patterns in package code, unless asked
For example, rather than using:
```python
Expand All @@ -24,6 +42,7 @@
- Skip unit tests unless explicitly requested
- Follow patterns in CONTRIBUTING.md when present
- Prefer writing Python if no language specified
- For complex code changes, use your Serena MCP tools (e.g., `find_symbol`, `find_referencing_symbols`, and `insert_after_symbol`) for symbol-based code editing instead of always relying on regex for code modifications

## Git Operations

Expand All @@ -32,16 +51,19 @@

## External Resources

- Validate and access link content using available MCP tools (Playwright and/or Perplexity)
- Validate and access link content using your available MCP tools (Playwright and/or Perplexity)
- Search GitHub for relevant open-source alternatives to commercial tools
- Prioritize official package documentation over inferred usage by using Context7 MCP tool
- Always utilize official package documentation via e.g., your Context7 MCP tool

## Communication Style

- Use minimal emoji and special symbols
- Use emoji and special symbols sparingly, if at all
- Prioritize clarity and brevity in responses
- Ask clarifying questions when needed
- Don't infer requirements or create workarounds unless asked
- Don't infer requirements or create workarounds unless asked. For example, instead of taking a fallback approach such as:
> Let me take a different approach - I'll create a simpler standalone demo that shows the concept without needing external dependencies
You should instead try additional ways to get the real dependencies installed. If you can't get it installed, update `.github/workflows/copilot-setup-steps.yml` with code that will pre-install it into your environment and then report back immediately with something like:
> After trying <command A> with <error message A>, <command B> with <error message B>, <command C> with <error message C>, ... <command Z> with <error message Z>, I was unable to install external dependencies. Per user's custom instructions, I will report back immediately. I will also provide useful links or web search keywords that will help the user debug and troubleshoot the installation failures.
- Put documentation content in comment replies, not separate files, unless asked
- Comments should not leave a trace of the development process
- Avoid sycophancy, favor objectiveness
Expand All @@ -59,3 +81,6 @@
- Include plots directly in your comment reply via `![image name](https://github.com/<user/org>/<repo>/blob/<shortened-commit-hash>/<filename>?raw=true)`. Truncate the commit hash to the first 7 characters only. For example, `https://github.com/AccelerationConsortium/evaluation-metrics/blob/52754e7/scripts/bo_benchmarks/demonstrations/branin_campaign_demonstration_results.png?raw=true`. For provenance, ensure you use the shortened (7-character) commit hash, not the branch name
- If you mention files in your comment reply, add direct hyperlinks based on the shortened (7-character) commit hash
- Use the following environment secrets: `HIVEMQ_HOST`, `HIVEMQ_USERNAME`, and `HIVEMQ_PASSWORD` for testing. Never echo or expose these, even in your logs

## Repo-specific
- IMPORTANT: run `conda activate ac-dev-lab` in your terminal before running any code (e.g., installing packages, running scripts, etc.). Alternatively, use the full path to `pip` or `python` within the `ac-dev-lab` environment
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ src/ac_training_lab/apriltag_demo/tag25_09_00000.png
src/ac_training_lab/apriltag_demo/tag36_11_00000.png
src/ac_training_lab/apriltag_demo/tag49_12_00000.png
scripts/playwright/sem-open-close/chat.json
src/ac_training_lab/label_printer/ql810w_ql820nwb_use_ug_06.pdf
src/ac_training_lab/label_printer/ql820nwb_810w_useng_qsg_d017p7001_03.pdf
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]
### Added
- Brother QL-810W label printer automation with AprilTags in `src/ac_training_lab/label_printer/` including MWE print script and Gradio web app with MQTT integration.
- Support for both `rpicam-vid` (Raspberry Pi OS Trixie) and `libcamera-vid` (Raspberry Pi OS Bookworm) camera commands in `src/ac_training_lab/picam/device.py` to ensure compatibility across different OS versions.
- Comprehensive Unit Operations section in `docs/index.md` documenting all available capabilities including dispensing, synthesis, characterization, and robotics operations.
- Expanded Training Workflows section in `docs/index.md` with 10 educational workflows including RGB/RYB color matching, titration, yeast growth optimization, vision-enabled 3D printing optimization, microscopy image stitching, and AprilTag robot path planning.
Expand Down
Binary file added apriltag_quick_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 123 additions & 0 deletions src/ac_training_lab/label_printer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Brother QL-810W Label Printer Automation with AprilTags

This module integrates with the repository's existing AprilTag resources rather than reimplementing tag generation or detection. See the apriltag_demo notebook and the cobot280pi utility for examples and helpers:

- apriltag_demo notebook: src/ac_training_lab/apriltag_demo/apriltag_demo.ipynb (also runnable in Colab)
- Simulated tag generator: src/ac_training_lab/cobot280pi/_scripts/pose_2025/generate_test_apriltag.py

A lightweight helper script generate_apriltag.py is provided here for quick tag image generation and testing.
## Hardware

- **Printer**: Brother QL-810W (wireless label printer)
- **Labels**: DK-2251 (black/red on white) or DK-4205 (removable, black on white)

## Setup

### 1. Install brother_ql

```bash
pip install brother_ql Pillow
```

### 2. Find printer

For USB connection:
```bash
brother_ql discover
```

For network connection, use the printer's IP address:
```
tcp://192.168.1.XXX:9100
```

### 3. Disable Editor Lite mode

If your printer has "Editor Lite" mode enabled, disable it by holding the button until the LED turns off. This is required for USB printing.

### 4. Test print

```bash
export BROTHER_QL_PRINTER=tcp://192.168.1.XXX:9100
export BROTHER_QL_MODEL=QL-810W
brother_ql print -l 62 test_image.png
```

## Files

- `mwe_print.py` - Minimal working example for sending a print command
- `app.py` - Gradio web app for AprilTag printing with MQTT integration

## Usage

### MWE (Minimum Working Example)

Configure environment variables and run:
```bash
export BROTHER_QL_PRINTER=tcp://192.168.1.XXX:9100
export BROTHER_QL_MODEL=QL-810W
export BROTHER_QL_LABEL=62
python mwe_print.py
```

### Gradio App

Configure MQTT credentials and run:
```bash
export HIVEMQ_HOST=your-broker.hivemq.cloud
export HIVEMQ_USERNAME=your-username
export HIVEMQ_PASSWORD=your-password
python app.py
```

The Gradio app provides:
- AprilTag generation with configurable tag family and ID
- Print preview before sending to printer
- MQTT integration for remote printing via HiveMQ

## Troubleshooting

### Raspberry Pi Setup

The brother_ql library communicates directly with the printer, bypassing CUPS drivers. This is especially useful on Raspberry Pi where Brother's official i386 drivers are incompatible with ARM architecture.

For USB on Linux, ensure proper permissions:
```bash
sudo usermod -a -G lp $USER
```

Or set up udev rules for the printer.

### Backend Options

- `pyusb` - Cross-platform USB (requires libusb)
- `network` - TCP/IP for WiFi-enabled printers
- `linux_kernel` - Uses /dev/usb/lp0 on Linux

## Windows-Specific Setup (Prototyping/Testing)

For testing and prototyping on Windows with USB connection:

1. Install Brother drivers from the [official site](https://support.brother.com/g/b/downloadtop.aspx?c=us&lang=en&prod=lpql810weus) in advance
1. Connect the Brother QL-810W via USB and ensure it's recognized by Windows.
1. Disable Editor Lite mode: Hold the power button until the LED turns off (this mode prevents USB access for third-party libraries).
1. Download Zadig from [https://zadig.akeo.ie/](https://zadig.akeo.ie/).
1. Run Zadig as administrator.
1. Select `Options` > `List All Devices`.
1. Select the Brother QL-810W printer from the device list.
1. Choose "libusb-win32" from the driver dropdown.
1. Click "Install Driver" (or "Replace Driver").
1. Restart your computer if necessary.

This replaces the default Brother USB driver with libusb, allowing `brother_ql` to access the printer directly. For production use, switch to Raspberry Pi or network mode, as USB on Windows requires this manual driver replacement.

## Related Issues

- [ac-dev-lab #70](https://github.com/AccelerationConsortium/ac-dev-lab/issues/70) - Set up QL810WC label printer automation with AprilTags
- [echem-cell #4](https://github.com/AccelerationConsortium/echem-cell/issues/4) - Electrocatalyst experiment equipment
- [brother_ql #162](https://github.com/pklaus/brother_ql/issues/162) - Brother QL-810W Printer Not Printing on Raspberry Pi

## References

- [brother_ql documentation](https://github.com/pklaus/brother_ql)
- [Brother QL-810W manual](https://support.brother.com/g/b/manualtop.aspx?c=ca&lang=en&prod=lpql810weus)
Loading
Loading