Skip to content

Commit

Permalink
Refactoring workspace (#29)
Browse files Browse the repository at this point in the history
* Started BOB refactoring [UNTESTED]:
 - moved modules in modules subdirectory
 - added modules readmes
 - removed old Docker stuff
 - cleaned startup scripts
 - added start_single script
 - removed bt and old_gear modules

* add: web UI in BOB repo

* fix: missing package_list file
add: cockpit installation

* add: poetry example with bob-core import and tests

* add: test poetry in accelerometer module

* add: working poetry env for accelerometer and csv

* add: workspace template example for module

* add: ci for tests and build

* rm: lock files

* fix: ci

* add: dynamic service path, ui structure as a module
rm: bob-core (mqtt run with docker and bt as a service)

* fix: remove ui as poetry module

* add: progress on modules refactoring with poetry

* finished poetry refactoring:
 - all modules use bob-core
 - all modules have poetry
 - all modules have a systemd service file that uses poetry python interpreter

* chore: add banner

* chore: fix shield

* add: bobui as a module
fix: create_module script

* fix: install stuff

* add: installation progress

* fix: video install

* add: hotplug for hdmi power on startup

* add(wip): async video module

Co-Authored-By: AlbertoEusebio <[email protected]>

* fix: update font with monospace one

* ci: disable action

* add(wip): better screen management with grid sector

* ci: disable action

* Delete dbus-org.bluez.service

* add(module): accelerometer wip with base functionalities

* Added CLI (#32)

* add: basic cli structure (wip)

* add: module-list & install commands

* add: bob cli commands, separated cli from webapp

* add: docs, setup command & video install

* changed default main

* Camera zoom and multisector (#38)

* add: zoom api

* fix: overlay buffer overflow

* fix: overlay destroy, content guard, zoom guard

* add: `OverlayElement` class

* fix: resolution (?)

* add: better main error recovery

* chore: bump `Pillow` and core

* add: multisector write

* fix: import error

* fix: font path

* chore(rm): `phoenix`, `csv`, `comunication`, `gpio`

* chore(mv): `external_mqtt` to `alice`

* chore(mv): `bt` to `sofia`

* tests(#33): add `video` build test

* test(ci): fix image

* fix(accelerometer): calibration zero

* test(#33): add `accelerometer` CI

* fix(accelerometer): import error

* chore(rm): useless files

* fix(accelerometer): error recovery

* add(video): rotation and framerate parameters

* fix: mosquitto docker

* add: overlay rotation param

* doc(accelerometer): update readme

* add(accelerometer): db write data

* add(video): mqtt sensor read

* chore: add example db with a base configuration

* add(video): config from db

* fix(video): db path

* chore(video): bump core

* add(video): recording mode

* fix(video): db config

* chore: update db for ant

* Refactoring ant module for asyncio (#34)

Co-authored-by: Alberto Eusebio <[email protected]>

* fix: camera overlay ant

* fix: database write

* add(ant): db write

* chore: better config params

* chore: better class methods on `AntReader`

* fix(ant): powermeter sensor

* add(ant): function for bin to int calculation

* add(ant): buffer for power and ctf calculation

* fix(ant): bin to int better semantic

* fix(ant): use a buffer for offset

* chore: update db

* fix: db conf

* fix(acc): handle exception db

* fix(video): color cadence and get param from db

* add(ant): nested dict for config

* add(video): data unit

* docs(ant): add documentations for sensors and db

* chore: rm unused modules

* chore: update readme

* docs: add davideaimar as a contributor for code, maintenance, ideas (#42)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* docs: add gabelluardo as a contributor for design, infra, test, doc (#43)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Gabriele Belluardo <[email protected]>

* Add CTF for srm powermeter (#41)

* chore(wip): calculations inserted

* chore(wip): implemented logic for Messagetype.crank_torque_freq

* fix: get parameters

* chore(wip): added buffer overflow constraints on payload

* add: buffer for power on ctf

* chore: private methods for computations

Co-authored-by: Alberto Eusebio <[email protected]>

* fix(ant): db write

* add: attribute for custom circumference

* ci: update poetry

* chore(ant): update lock file

* chroe: update db

* fix(ci): pip install poetry matching

* chore(ant): update hr sesors id

* fix(video): data unit

* fix(db): hr id taurusx

* fix(ant): db sensor value and ant doc

* docs(ant): add hall phoenix

* docs(ant): update hall sensor id cerberus

Co-authored-by: Davide Aimar <[email protected]>
Co-authored-by: AlbertoEusebio <[email protected]>
Co-authored-by: Marta <[email protected]>
  • Loading branch information
4 people authored Oct 31, 2022
1 parent 343b6c5 commit f37400a
Show file tree
Hide file tree
Showing 379 changed files with 12,219 additions and 5,003 deletions.
25 changes: 24 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,33 @@
"contributions": [
"code"
]
},
{
"login": "davideaimar",
"name": "davide.aimar",
"avatar_url": "https://avatars.githubusercontent.com/u/17318562?v=4",
"profile": "http://www.davideaimar.com",
"contributions": [
"code",
"maintenance",
"ideas"
]
},
{
"login": "gabelluardo",
"name": "Gabriele Belluardo",
"avatar_url": "https://avatars.githubusercontent.com/u/42920247?v=4",
"profile": "http://gabelluardo.github.io",
"contributions": [
"design",
"infra",
"test",
"doc"
]
}
],
"contributorsPerLine": 7,
"projectName": "BOB",
"projectName": "bob",
"projectOwner": "policumbent",
"repoType": "github",
"repoHost": "https://github.com",
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches: [dev-refactoring]
pull_request:
branches: [dev-refactoring]
workflow_dispatch:

jobs:
ci:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8]
poetry-version: [1.1.15]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Test module `ant` on arm
uses: pguyot/arm-runner-action@v2
with:
base_image: https://downloads.raspberrypi.org/raspios_oldstable_armhf/images/raspios_oldstable_armhf-2022-04-07/2022-04-04-raspios-buster-armhf.img.xz
commands: |
cd modules/ant
apt-get update --fix-missing
apt-get install -y --no-install-recommends python3-dev python3-setuptools python3-wheel python3-pip git $(cat package_list.txt)
pip3 install poetry==1.1.15
poetry install
poetry run pytest
# Errore di `RPi.GPIO` da aggiustare prima di abilitare la CI
#
# - name: Test module `video` on arm
# uses: pguyot/arm-runner-action@v2
# with:
# base_image: https://downloads.raspberrypi.org/raspios_oldstable_armhf/images/raspios_oldstable_armhf-2022-04-07/2022-04-04-raspios-buster-armhf.img.xz
# commands: |
# cd modules/video
# apt-get update --fix-missing
# apt-get install -y --no-install-recommends python3-dev python3-setuptools python3-wheel python3-pip git $(cat package_list.txt)
# pip3 install -r requirements.txt
# pip3 install RPi.GPIO
# pip3 install pytest
# pytest

- name: Test module `accelerometer` on arm
uses: pguyot/arm-runner-action@v2
with:
base_image: https://downloads.raspberrypi.org/raspios_oldstable_armhf/images/raspios_oldstable_armhf-2022-04-07/2022-04-04-raspios-buster-armhf.img.xz
commands: |
cd modules/accelerometer
apt-get update --fix-missing
apt-get install -y --no-install-recommends python3-dev python3-setuptools python3-wheel python3-pip git $(cat package_list.txt)
pip3 install poetry==1.1.15
poetry install
poetry run pytest
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
.idea
.idea
.venv
.env
.pytest*
.vscode
**/__pycache__/**
dist
onboard_video
7 changes: 0 additions & 7 deletions LED/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions LED/led.service

This file was deleted.

92 changes: 22 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,27 @@
# BOB
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

## Componenti

*Work in progress*

Per tutti manca la gestione delle impostazioni

- sensori
- [x] ant
- [x] accelerometer
- [ ] weather => sensori umidità e temperatura a bordo della bici
- [x] gps
- [ ] gear => gestione cambio e comunicazione seriale
- consumatori
- [x] csv
- [ ] power/speed profiles
- [x] raspberry manager (cronometro / temperatura cpu)
- [x] video
- comunicazione
- [x] gpio => tasti cambio e combinazioni tasti
- [x] communication => collegamento con il server http
- [x] pyxbee_v2 => comunicazione tramite lora
- [x] bt => collegamento con l'app bt **(manca dockerfile)**
- messaggi
- [x] messaggi a schermo
- [ ] alert su alice

## Protocollo
![BOB](img/banner.png)

### Comuni (Mqtt)
<h3 align="center">
Il factotum della bici

- publish
- `states/{name}` => Il sensore pubblica un json `{"connected": True}`quando si connette
- `settings/{name}` => Un sensore pubblica un json con le sue impostazioni
- `messages/{name}` => Un sensore pubblica un json con il messaggio che vuole mandare `{"text": "Ciao", "priority": 4, "time": 10, "type": 0}`
- `alerts/{name}` => Un sensore pubblica un json con il messaggio che vuole mandare `{"text": "Ciao", "priority": 4}`
- subscribe
- `new_settings/{name}` => Un sensore effettua la subscribe sulle nuove impostazioni e se arriva un messaggio aggiorna le proprie
- `signals` => Un sensore effettua la subscribe sui segnali, se arriva un segnale il sensore compie la relativa azione `{"action": "reset"}`
<br>
<br>

### Sensori (MqttSensor => Estende Mqtt)

- publish
- `sensors/{name}` => Il sensore pubblica i suoi dati

### Consumatori (MqttConsumer => Estende MqttSensor)

- subscribe
- `sensors/{name}` => I consumatori effettuano la subscription ad una lista di sensori

### Comunicazione (MqttRemote => Estende MqttConsumer)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

- publish
- `signals` => Manda dei segnali che saranno letti da tutti i sensori `{"action": "reset"}`
- `new_settings/{name}` => Manda le impostazioni ad ogni sensores
- subscribe
- `settings`
- `alerts`
</h3>

### Messaggi (MqttMessages => Estende Mqtt)
- BOB is not a single program, it is a collection of independent modules and tools to manage them.
- Modules talk to each other through MQTT.
- Up to now, all the modules are written in Python and are managed by systemd.
- Every module has its own systemd service, and it's independent of the others.

- publish
- `messages` => Pubblica un json con i messaggi da mostrare sulle due righe `{"line_1": "Messaggio riga 1", "line_2": "Messaggio riga 2"}`
- subscribe
- `messages` => Riceve gli aggiornamenti dai vari sensori
## CLI

## TODO
In order to ease the management of the modules, BOB has a command line interface.\
Read the [README](bobcli/README.md) to know how to use it.

- [ ] implementare componenti mancanti
- [ ] gestione settings
## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand All @@ -81,10 +31,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/stelosca96"><img src="https://avatars.githubusercontent.com/u/44433696?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefano Loscalzo</b></sub></a><br /><a href="https://github.com/policumbent/BOB/commits?author=stelosca96" title="Code">💻</a> <a href="#ideas-stelosca96" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-stelosca96" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center"><a href="https://github.com/davidegavatorta"><img src="https://avatars.githubusercontent.com/u/45601520?v=4?s=100" width="100px;" alt=""/><br /><sub><b>davidegavatorta</b></sub></a><br /><a href="https://github.com/policumbent/BOB/commits?author=davidegavatorta" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/CornagliaRiccardo"><img src="https://avatars.githubusercontent.com/u/81438517?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CornagliaRiccardo</b></sub></a><br /><a href="https://github.com/policumbent/BOB/commits?author=CornagliaRiccardo" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/AlbertoEusebio"><img src="https://avatars.githubusercontent.com/u/72319445?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alberto Eusebio</b></sub></a><br /><a href="https://github.com/policumbent/BOB/commits?author=AlbertoEusebio" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/stelosca96"><img src="https://avatars.githubusercontent.com/u/44433696?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefano Loscalzo</b></sub></a><br /><a href="https://github.com/policumbent/bob/commits?author=stelosca96" title="Code">💻</a> <a href="#ideas-stelosca96" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-stelosca96" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center"><a href="https://github.com/davidegavatorta"><img src="https://avatars.githubusercontent.com/u/45601520?v=4?s=100" width="100px;" alt=""/><br /><sub><b>davidegavatorta</b></sub></a><br /><a href="https://github.com/policumbent/bob/commits?author=davidegavatorta" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/CornagliaRiccardo"><img src="https://avatars.githubusercontent.com/u/81438517?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CornagliaRiccardo</b></sub></a><br /><a href="https://github.com/policumbent/bob/commits?author=CornagliaRiccardo" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/AlbertoEusebio"><img src="https://avatars.githubusercontent.com/u/72319445?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alberto Eusebio</b></sub></a><br /><a href="https://github.com/policumbent/bob/commits?author=AlbertoEusebio" title="Code">💻</a></td>
<td align="center"><a href="http://www.davideaimar.com"><img src="https://avatars.githubusercontent.com/u/17318562?v=4?s=100" width="100px;" alt=""/><br /><sub><b>davide.aimar</b></sub></a><br /><a href="https://github.com/policumbent/bob/commits?author=davideaimar" title="Code">💻</a> <a href="#maintenance-davideaimar" title="Maintenance">🚧</a> <a href="#ideas-davideaimar" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="http://gabelluardo.github.io"><img src="https://avatars.githubusercontent.com/u/42920247?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gabriele Belluardo</b></sub></a><br /><a href="#design-gabelluardo" title="Design">🎨</a> <a href="#infra-gabelluardo" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/policumbent/bob/commits?author=gabelluardo" title="Tests">⚠️</a> <a href="https://github.com/policumbent/bob/commits?author=gabelluardo" title="Documentation">📖</a></td>
</tr>
</table>

Expand Down
9 changes: 0 additions & 9 deletions accelerometer/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions accelerometer/accelerometer.service

This file was deleted.

3 changes: 0 additions & 3 deletions accelerometer/package_list.txt

This file was deleted.

Loading

0 comments on commit f37400a

Please sign in to comment.