Skip to content

Commit d708b2e

Browse files
committed
add docs
1 parent 1c61385 commit d708b2e

9 files changed

Lines changed: 489 additions & 85 deletions

README.md

Lines changed: 13 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,29 @@
1-
# B.L.I.T.Z (Battle-Linked Intelligent Tactical Pi Swarm)
1+
## B.L.I.T.Z
22

3-
BLITZ is a robotics project designed to create a swarm of intelligent tactical Pi-based robots that can work together collaboratively.
3+
Multi-process robotics stack with a Python watchdog, codegen, and deploy tooling.
44

5-
## Overview
5+
## Docs
66

7-
The BLITZ system combines multiple components for sensing, positioning, AI detection, and coordinated movement. It uses a hybrid approach with both Python and Rust for different system components.
7+
Start here: `docs/README.md`
88

9-
## Features
10-
11-
- LiDAR-based obstacle detection and mapping (2D and 3D)
12-
- Computer vision for object recognition
13-
- AprilTag-based positioning system
14-
- Position extrapolation
15-
- Watchdog monitoring
16-
17-
## Technologies
18-
19-
### Languages
20-
- Python
21-
- Rust
22-
- TypeScript/JavaScript
23-
24-
### Major Dependencies
25-
- Python: PyTorch, OpenCV, Flask, NumPy, UltraLytics
26-
- Rust: Tokio, Nalgebra, Kiss3D
27-
- Communication: Protobuf, Thrift
28-
29-
## Getting Started
30-
31-
### Prerequisites
32-
- Python 3.x
33-
- Rust and Cargo
34-
- npm/Node.js
35-
36-
### Installation
37-
38-
Set up the Python environment and install dependencies:
9+
## Quickstart (local)
3910

4011
```bash
4112
make initiate-project
13+
echo "dev" > system_data/name.txt
14+
make generate
15+
make watchdog
4216
```
4317

44-
### Code Generation
45-
46-
Generate required protocol buffer and Thrift files:
18+
## Tests
4719

4820
```bash
49-
make generate
21+
make test
5022
```
5123

52-
## Usage
53-
54-
Start the various system components:
24+
## Deploy to a target machine
5525

5626
```bash
57-
# AI detection server
58-
make ai-server
59-
60-
# AprilTag positioning server
61-
make april-server
62-
63-
# 2D LiDAR reader
64-
make lidar-reader-2d
65-
66-
# LiDAR point processor
67-
make lidar-point-processor
68-
69-
# Position extrapolation system
70-
make position-extrapolator
71-
72-
# System monitoring watchdog
73-
make watchdog
27+
make send-to-target
28+
make deploy-to-target
7429
```
75-
76-
## Development
77-
78-
- Run linting: `make check-all`
79-
- Run tests: `make test`
80-
- Deploy to a target: `make send-to-target ARGS=<target-id>`
81-
82-
## Project Structure
83-
84-
- `project/`: Main source code
85-
- `lidar/`: LiDAR data processing components
86-
- `recognition/`: Computer vision and positioning
87-
- `pos_extrapolator/`: Position prediction system
88-
- `watchdog/`: System monitoring
89-
- `rust/`: Rust components for performance-critical operations
90-
- `proto/`: Protocol buffer definitions
91-
- `config/`: System configuration
92-
- `generated/`: Generated code (Protobuf, Thrift)
93-
- `scripts/`: Utility scripts
94-
95-
## License
96-
97-
ISC License
98-
99-
## Repository
100-
101-
GitHub: [https://github.com/PinewoodRobotics/B.L.I.T.Z](https://github.com/PinewoodRobotics/B.L.I.T.Z)

docs/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## BLITZ docs
2+
3+
These docs are organized as parts. Each part is a step toward a bigger workflow (setup, codegen, run, deploy, autostart, testing, troubleshooting).
4+
5+
## Parts (follow in order)
6+
7+
1. `docs/part-01-setup.md` (local setup + verify)
8+
2. `docs/part-02-codegen.md` (proto/codegen)
9+
3. `docs/part-03-run-local.md` (run core services locally)
10+
4. `docs/part-04-deploy.md` (deploy to target + restart)
11+
5. `docs/part-05-autostart.md` (autostart on target via systemd)
12+
6. `docs/part-06-testing-ci.md` (tests + repo expectations)
13+
7. `docs/part-07-troubleshooting.md` (common failures + recovery)
14+
15+
## Glossary
16+
17+
- **target**: the machine you deploy to (typically an Ubuntu host on the robot side).
18+
- **watchdog**: the Python service that exposes an API and manages subprocesses.
19+
- **basic system config**: `system_data/basic_system_config.json` (baseline ports/paths).
20+
- **generated proto**: Python output generated into `watchdog/generated/`.

docs/part-01-setup.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Part 1: Local setup + verify
2+
3+
## Goal
4+
5+
Get a working local Python environment and confirm the watchdog starts and responds.
6+
7+
## Prereqs
8+
9+
- `python3` (>= 3.8)
10+
- `make`
11+
- macOS: Homebrew (optional, for installing missing tools)
12+
13+
## Steps
14+
15+
1. From the repo root, create the venv and install dependencies:
16+
17+
```bash
18+
make initiate-project
19+
```
20+
21+
2. Set a local system name (required by the watchdog):
22+
23+
```bash
24+
echo "dev" > system_data/name.txt
25+
```
26+
27+
3. Start the watchdog:
28+
29+
```bash
30+
make watchdog
31+
```
32+
33+
4. In a second terminal, verify the HTTP API is up (default port is 5000):
34+
35+
```bash
36+
curl -sS http://localhost:5000/get/system/status
37+
```
38+
39+
## Expected result
40+
41+
- `make watchdog` stays running and prints startup logs.
42+
- `curl` returns JSON with keys like `status`, `active_processes`, `possible_processes`.
43+
44+
## Common failures
45+
46+
- **`system_data/name.txt does not exist`**: create it (step 2) and restart.
47+
- **`ModuleNotFoundError` inside the venv**: rerun `make initiate-project`.
48+
- **Port 5000 already in use**: stop the other process or change `watchdog.port` in `system_data/basic_system_config.json`.

docs/part-02-codegen.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Part 2: Proto/codegen
2+
3+
## Goal
4+
5+
Generate Python code from `.proto` files so the watchdog and other Python code can import the generated messages.
6+
7+
## Prereqs
8+
9+
- Part 1 completed (`make initiate-project`)
10+
- `protoc` installed and on your PATH
11+
- Ubuntu: `sudo apt install -y protobuf-compiler`
12+
- macOS: `brew install protobuf`
13+
14+
## Steps
15+
16+
1. Generate Python protobuf output:
17+
18+
```bash
19+
make generate
20+
```
21+
22+
2. Confirm outputs exist:
23+
24+
```bash
25+
ls watchdog/generated
26+
```
27+
28+
## What it does
29+
30+
- Inputs: all `.proto` files in `proto/`
31+
- Outputs: Python modules into `watchdog/generated/`
32+
- Post-step: runs `fix-protobuf-imports` from the venv to normalize imports
33+
34+
## When to rerun
35+
36+
- You edited any file under `proto/`
37+
- You pulled changes that modified `proto/`
38+
- You see an import error coming from `watchdog/generated/`
39+
40+
## Expected result
41+
42+
- `watchdog/generated/` contains Python files for each `.proto`
43+
- Imports from generated modules succeed when running `make watchdog`
44+
45+
## Common failures
46+
47+
- **`protoc: command not found`**: install protobuf compiler (see prereqs).
48+
- **`fix-protobuf-imports: No such file or directory`**: rerun `make initiate-project` to recreate the venv and dependencies.

docs/part-03-run-local.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
## Part 3: Run core services locally
2+
3+
## Goal
4+
5+
Start the watchdog locally and use it to view system state and manage processes.
6+
7+
## Prereqs
8+
9+
- Part 1 completed (venv + `system_data/name.txt`)
10+
11+
## Steps: run the watchdog
12+
13+
1. Start the watchdog:
14+
15+
```bash
16+
make watchdog
17+
```
18+
19+
2. Check status:
20+
21+
```bash
22+
curl -sS http://localhost:5000/get/system/status
23+
```
24+
25+
## Steps: set the runtime config (required before starting processes)
26+
27+
The watchdog refuses to start/stop managed processes until a config is set.
28+
29+
1. Create the config file:
30+
31+
```bash
32+
mkdir -p config
33+
printf "{}" > config/config.txt
34+
```
35+
36+
2. Tell the watchdog to load it:
37+
38+
```bash
39+
curl -sS -X POST http://localhost:5000/set/config \
40+
-H 'Content-Type: application/json' \
41+
-d '{"config":"{}"}'
42+
```
43+
44+
## Steps: managed processes (what exists today)
45+
46+
1. List possible processes:
47+
48+
```bash
49+
curl -sS http://localhost:5000/get/system/status
50+
```
51+
52+
2. If `possible_processes` is empty, that means there are no runnable modules registered in `backend/deploy.py` yet.
53+
54+
## How process launching is wired
55+
56+
- The watchdog gets process definitions from `backend.deploy.get_modules()`.
57+
- Only modules that implement runnable behavior are exposed via the API.
58+
- Today, `backend/deploy.py` returns an empty list, so the watchdog can’t start any extra processes beyond itself.
59+
60+
## Steps: start/stop a process (once modules exist)
61+
62+
1. Start one or more processes:
63+
64+
```bash
65+
curl -sS -X POST http://localhost:5000/start/process \
66+
-H 'Content-Type: application/json' \
67+
-d '{"process_types":["<process_name>"]}'
68+
```
69+
70+
2. Stop one or more processes:
71+
72+
```bash
73+
curl -sS -X POST http://localhost:5000/stop/process \
74+
-H 'Content-Type: application/json' \
75+
-d '{"process_types":["<process_name>"]}'
76+
```
77+
78+
## Expected result
79+
80+
- `get/system/status` shows the system name and watchdog state.
81+
- If runnable modules are registered, `possible_processes` lists them and `active_processes` changes as you start/stop processes.
82+
83+
## Common failures
84+
85+
- **`Config not set` from start/stop endpoints**: run the “set the runtime config” steps above.
86+
- **`Unknown process <name>`**: the name must match a process in `possible_processes`.

docs/part-04-deploy.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## Part 4: Deploy to a target + restart
2+
3+
## Goal
4+
5+
Sync the repo to the target machine and restart the systemd service.
6+
7+
## Prereqs
8+
9+
- You can SSH to the target as `ubuntu`
10+
- `sshpass` installed on your local machine
11+
- macOS: `make mac-deps`
12+
- Ubuntu: `sudo apt install -y sshpass`
13+
- The target has `rsync` installed
14+
15+
## What the Make targets do
16+
17+
- `make send-to-target`: rsyncs the repo to `TARGET_FOLDER` using `sudo rsync` on the target
18+
- `make deploy-to-target`: runs `send-to-target` and then restarts `startup.service` on the target
19+
20+
## Steps
21+
22+
1. Pick the target settings (defaults are in `Makefile`):
23+
24+
- `UBUNTU_TARGET` (e.g. `nathanhale.local`)
25+
- `TARGET_PORT` (default `22`)
26+
- `SSH_PASS` (default `ubuntu`)
27+
- `TARGET_FOLDER` (default `/opt/blitz/B.L.I.T.Z/`)
28+
29+
2. Deploy:
30+
31+
```bash
32+
make send-to-target UBUNTU_TARGET=<host_or_ip> TARGET_PORT=22 SSH_PASS=ubuntu
33+
```
34+
35+
3. Restart the system service:
36+
37+
```bash
38+
make deploy-to-target UBUNTU_TARGET=<host_or_ip> TARGET_PORT=22 SSH_PASS=ubuntu
39+
```
40+
41+
## Expected result
42+
43+
- The repo contents exist under `TARGET_FOLDER` on the target.
44+
- `startup.service` is restarted successfully.
45+
46+
## Common failures
47+
48+
- **`sshpass: command not found`**: install it (see prereqs).
49+
- **Permission errors on the target**: `send-to-target` uses `--rsync-path="sudo rsync"`; the `ubuntu` user needs sudo.
50+
- **Host key prompt / SSH failure**: confirm you can `ssh ubuntu@<host>` manually first.

0 commit comments

Comments
 (0)