An autonomous Nerf turret
This package has two optional extras. You must install at least one for camera-related features to work.
[picamera]
can only be installed on Raspberry Pi hardware[opencv]
is used for object recognition. It can be installed on Pi and non-Pi hardware but is extremely slow to compile on a Pi.
To install on a Raspberry Pi, log in and then:
-
Install the project with
pip install "git+https://github.com/Iain-S/sentry-bot#egg=sentrybot[picamera]"`
Note that we are installing the
[picamera]
extra and that the"
quotes are required if usingzsh
. -
optional Manually compile and install OpenCV by following, for example, these instructions
-
Proceed to Run the Server
You can install this package on non-Pi hardware using pip
.
Some features of this package will be unavailable on non-Pi hardware but the web server will still run.
If your computer has a camera, you can install the [opencv]
extra.
You should not try to install the [picamera]
extra on non-Pi hardware as installation will fail.
-
Install the project with
pip install "git+https://github.com/Iain-S/sentry-bot#egg=sentrybot[opencv]"`
Note that we are installing the
[opencv]
extra and that the"
quotes are required if usingzsh
. -
Proceed to Run the Server
- Clone the repository with something like
git clone path/to/sentry-bot-repo
- Change directory with
cd sentry-bot/
(subsequent instructions assume you are in the repo root directory)
- assets/ contains images, etc. for the README
- frontend/ contains the frontend code and tests, which are written in TypeScript
- sentrybot/ contains the backend code, which is a Python Flask webserver
- stubs/ contains type stubs for Mypy
- tests/ contains the backend tests
- Install Python >= 3.10
- Install Poetry
- Install the
sentrybot
package and[opencv]
extra withpoetry install -E opencv
- Active our new virtual environment with
poetry shell
(subsequent instructions assume this is still active)
- Install Node and npm
- Install our frontend dependencies with
npm --prefix ./frontend install ./frontend
- Install pre-commit
- Install pre-commit hooks with
pre-commit install
The formatters and linters specified in .pre-commit-config.yaml will run whenever you git commit
.
- Check that pre-commit hooks pass when you run
pre-commit run --all-files
- Check that Python pytest tests pass when you run
./test_backend.sh
- Check that TypeScript Jest tests pass when you run
./test_frontend.sh
- Check that you can build the frontend with
./build_frontend.sh
(you can build whenever a .ts file changes by adding a--watch
argument)
-
Make a
config.toml
file in the directory you will run the app from -
optional Add an environment variable to
config.toml
with the path to a.mp4
videoVIDEO_PATH='/path/to/any/video.mp4'
-
optional Build webGL project with Unity and copy the
Build/
,StreamingAssets/
andTemplateData/
directories tosentrybot/static/
. This game can be accessed via the/game
URL. -
If you are running on a Pi:
- Start the pigpio daemon with
sudo pigpiod
- Run the webserver with
flask --app sentrybot --debug run --host 0.0.0.0
but be aware that it will make the webserver accessible to all machines on the network
- Start the pigpio daemon with
-
Else, if you are running on other hardware:
- Run the webserver with
flask --app sentrybot --debug run
- Go to
localhost:5000/
in your web browser
- Run the webserver with