Metadata-Version: 2.4
Name: field_coverage
Version: 0.1.0
Summary: Pathfinding for autonomous robots
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: pathfinding
Requires-Dist: numpy
Requires-Dist: ortools
Requires-Dist: matplotlib
Requires-Dist: networkx>=3.6.1
Requires-Dist: requests
Requires-Dist: shapely
Requires-Dist: pydantic
Requires-Dist: pandas
Requires-Dist: pyarrow
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov>=7.0.0; extra == "dev"

# Louis Cutteridge FYP: Coverage Path Planning for Agricultural Fields
---
## Abstract
Coverage path planning addresses the problem of finding a route that traverses every point within an environment. In applications such as agricultural seeding, coverage is destructive; subsequent passes to the same point undo the result of the first, making revisits undesirable. I formalise this as an optimisation problem: find a path that covers every cell in the grid while minimising the total number of revisits and turns. I present a systematic evaluation of my algorithm and evaluate its performance. This is followed by the creation of a web-app (AuTo-mato) which generates coverage paths for agricultural fields in the UK.

---

## Key Contributions

- Formalising CPP as a GTSP problem
- Rigorously proving the algorithm for complete coverage
- Solving the optimisation problem
- Creating the **AuTo-mato** web-app, which uses the algorithm as a backend

---

## Repository Structure

| Directory | Contents |
|---|---|
| `docs/` | Diagrams and documentation assets |
| `field_coverage/` | Backend |
| `field_coverage_ui/` | Frontend |
| `results/` | Experiments, CSV files, and graphs |
| `data/` | GeoJSON files |

---

## Setup
Note, this docker image has not been tested on a non arm CPU. Results and setup may differ.
### 1. Docker Container
Build the image from the root of `field_coverage/`:
```bash
docker build -f decomp/dockerfile -t fields2cover-api:v3 --platform linux/arm64 .
```

Run the container:
```bash
docker run -d -p 8000:8000 --platform linux/arm64 fields2cover-api:v3
```

### 2. Install Dependencies
Install [uv](https://github.com/astral-sh/uv), then:
```bash
uv pip install -e .
```
If this does not download `field_coverage` as well:
```bash
uv pip install field_coverage
```

### 3. Start the Backend
From the root of `field_coverage/`:
```bash
uvicorn coverage_api:app --reload --port 8000
```

### 4. Start the Frontend
From the root of `field_coverage_ui/`:
```bash
npm run dev
```

---

## Running Tests
```bash
pytest
```

To view the coverage report, open the following in your browser:
```
file:///<path-to-repo>/htmlcov/index.html
```

## Architecture 
The entire OOP architecture of the project:
<div align="center">
<img src="./docs/uml_diagram.png" alt="Backend UML" width="800">
</div>

## Flowcharts
### ACO
Flowchart for parallel ACO:
<div align="center">
<img src="./docs/aco_flowchart.png" alt="ACO Flowchart" width="500">
</div>

### SA
Flowchart for SA:
<div align="center">
<img src="./docs/sa_flowchart.png" alt="SA Flowchart" width="300">
</div>

## Pipeline 
High level pipeline of `field_coverage`:
<div align="center">
<img src="./docs/cpp-pipeline.png" alt="Pipeline" width="300">
</div>

---
