Skip to content
Snippets Groups Projects
Unverified Commit a3c4fc27 authored by Anton Tetov Johansson's avatar Anton Tetov Johansson
Browse files

Installable structure

parent 7f36d777
No related branches found
No related tags found
No related merge requests found
[flake8]
max-line-length = 88
extend-ignore = E203
......@@ -4,7 +4,7 @@
https://pjreddie.com/darknet/yolo/
## YOLO, implemented by Darknet
## YOLO, implemented using Darknet
Darknet is a deep learning framework created by the author of YOLO. It is
written in C and provides necessary Python APIs for object detection.
......@@ -59,11 +59,10 @@ system does not perfectly align with the planting bed's corner.
The camera coordinate can be transformed to the global one via a transition and
a rotation. From the picture, we can easily write the formula
## Install, Compile
## Setup
1. `git clone git@gitlab.control.lth.se:alexp/farmbot`
1. `git clone git@gitlab.control.lth.se:robotlab/farmbot_yolo`
1. Initialize submodules: `git submodules init && git submodules update`.
1. Change `LIBSO=0` to `LIBSO=1` in `darknet/Makefile`.
1. `make` to compile
1. Install anaconda using [official
installer](https://www.anaconda.com/products/distribution) and
......@@ -75,6 +74,8 @@ a rotation. From the picture, we can easily write the formula
### Compile Darknet
**Already done in the above steps**
Check the
[instruction](https://github.com/AlexeyAB/darknet#how-to-compile-on-linux-using-make)
for how to use `Make` to compile on Linux.
......@@ -95,32 +96,32 @@ for how to use the web app to set zeros.
The software has three main modules:
1. `move.py`: drive FarmBot to move, take photos, and open/close the gripper
2. `detection.py`: run darknet as a dynamic library for detecting, output
1. `move`: drive FarmBot to move, take photos, and open/close the gripper
2. `detection`: run darknet as a dynamic library for detecting, output
bounding boxes
3. `location.py`: input bounding boxes, transfer to real-world coordinate
3. `location`: input bounding boxes, transfer to real-world coordinate
We also provide `main.py` as a warpper for all the modules above. By running it,
We also provide `main.py` as a wrapper for all the modules above. By running it,
you can make Farmbot automatically conduct the whole process. The three modules
can also be run separately, mostly for debugging purpose.
First go to `farmbot_yolo` and `conda activate <env>` to run the following scripts.
`<env>` is the same as the one you created in _Install, Compile_
### Move Famrbot, take photos, and open/close the gripper
### Move Farmbot, take photos, and open/close the gripper
### YOLO detection
All the arguments for file path are set to default.
```
python ./detect.py --dont_show --ext_output --save_labels --input ../img --weights ../weights/yolov3-vattenhallen_best.weights --config_file ../cfg/yolov3-vattenhallen-test.cfg --data_file ../data/vattenhallen.data
python farmbot_yolo.detect --dont_show --ext_output --save_labels --input ../img --weights ../weights/yolov3-vattenhallen_best.weights --config_file ../cfg/yolov3-vattenhallen-test.cfg --data_file ../data/vattenhallen.data
```
### Calculate location
```
python location.py -v -cam ../static/camera_no_distortion.mat -loc ../img/locations/ -a ../img/annotations -o ../static/distance.txt -l ../log/location.log
python farmbot_yolo.location -v -cam ../static/camera_no_distortion.mat -loc ../img/locations/ -a ../img/annotations -o ../static/distance.txt -l ../log/location.log
```
All the arguments has default values, which means they can be all omitted if you
......
name: false
name: farm-dev
channels:
- conda-forge
dependencies:
- python==3.8
- black
- isort
- mypy
- flake8
- opencv
......@@ -12,4 +13,3 @@ dependencies:
- scipy
- pandas
- requests
prefix: /local/home/tetov/miniforge3/envs/farm-dev
......@@ -26,3 +26,6 @@ dependencies = [
[project.optional-dependencies]
dev = ["black", "mypy", "flake8", "isort"]
[tool.isort]
profile = "black"
File moved
File moved
File moved
......@@ -6,7 +6,7 @@ from typing import List
import requests
import utils.creds as creds
from farmbot_yolo import creds
# note: download only returns 100 at a time!
......
......@@ -2,14 +2,15 @@
TODO: Integrate with FarmbotClient or FarmbotYoloClient
"""
from utils.client import FarmbotClient
from utils.creds import device_id
from utils.creds import token
from farmbot_yolo.client import FarmbotClient
from farmbot_yolo.creds import device_id
from farmbot_yolo.creds import token
GRIPPER_PIN = 12
GRIPPER_OPEN_STATE = 0
GRIPPER_CLOSED_STATE = 1
def gripper_open():
"""Manipulate gripper by setting pin to 1."""
client = FarmbotClient(device_id, token)
......@@ -22,3 +23,6 @@ def gripper_close():
client = FarmbotClient(device_id, token)
client.write_pin(GRIPPER_PIN, GRIPPER_CLOSED_STATE, pin_mode="digital")
client.shutdown()
# TODO: Add argumentparser and ifnamemain function
File moved
File moved
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment