Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Arrowhead wrappers #6

Merged
merged 41 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
98989c6
Add exit screen
jara001 Apr 6, 2022
8f4763c
Rename shutdown timeval to avoid conflicts
jara001 Apr 6, 2022
5a43f90
Add exit handler
jara001 Apr 6, 2022
5005930
Run exit handler on pressing second button
jara001 Apr 6, 2022
522e688
Merge branch 'feature/exit-application' into devel/arrowhead-final
jara001 Apr 7, 2022
2b1d840
Add git configure file for cmake
jara001 Apr 7, 2022
aed0463
Add git sequence to CMakeLists
jara001 Apr 7, 2022
0b36093
Display git version on exit screen
jara001 Apr 7, 2022
30564f9
Merge branch 'feature/git-versioning' into devel/arrowhead-final
jara001 Apr 8, 2022
55da123
Kill explicitly websocat on exit
jara001 Apr 8, 2022
91113b4
(.GI) Add git.h
jara001 Apr 8, 2022
e625be4
(F) Marking version dirty
jara001 Apr 8, 2022
418d7df
Reverse the functions order when pressing buttons
jara001 Apr 8, 2022
1133b06
Make start structs global
jara001 Apr 8, 2022
ec7b18e
Move usec_between slightly more to the top
jara001 Apr 8, 2022
399ac9d
Display progress on exit/shutdown
jara001 Apr 8, 2022
b219a70
Merge branch 'feature/exit-progress' into devel/arrowhead-final
jara001 Apr 8, 2022
0393658
Add Arrowhead Tools logo
jara001 Apr 12, 2022
599a772
Add backend overlay
jara001 Apr 12, 2022
b26e250
(.GI) Add scoreapp database
jara001 Apr 12, 2022
091e655
Get and display current branch
jara001 Apr 12, 2022
548543b
Exit the application during exit sequence
jara001 Apr 12, 2022
efdad50
Update metadata example of backend overlay to latest version
jara001 Apr 13, 2022
4dfd275
Add raspberry overlay as submodule
jara001 Apr 13, 2022
4a24b98
Update the raspberry overlay submodule
jara001 Apr 19, 2022
6dec827
Roll poweroff screen and show wireguard address
jara001 Apr 19, 2022
96933c2
Slow down the rolling
jara001 Apr 19, 2022
0c34261
(F) Set default value of wireguard address
jara001 Apr 19, 2022
fa5ca94
Hide wireguard address when not obtained
jara001 Apr 19, 2022
b519356
Set raspberry overlay submodule to track branch
jara001 Apr 20, 2022
7494469
Update the raspberry overlay submodule
jara001 Apr 20, 2022
d9fb602
Update backend-arrowhead readme
jara001 Apr 20, 2022
b93ff12
Add new draft of the readme
jara001 Apr 22, 2022
38df385
Add logo to backend overlay and add status messages
jara001 May 3, 2022
2695f3a
Add license file
jara001 May 12, 2022
d72a851
Merge branch 'devel/arrowhead-final' into main
jara001 May 12, 2022
d338215
Move arrowhead overlays to 'arrowhead' folder
jara001 May 23, 2022
29492ea
Update links in the readme and use term wrapper
jara001 May 23, 2022
4cb998b
(F) Path to the scoreapp in Arrowhead wrapper
jara001 May 23, 2022
39b5ab7
Change the license to TODO until resolved
jara001 May 23, 2022
ee001da
Rename the license file
jara001 May 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "barrier-arrowhead"]
path = arrowhead/barrier
url = https://github.com/jara001/ah-raspi-overlay
branch = master
674 changes: 674 additions & 0 deletions LICENSE.tobeused

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# f1tenth-scoreapp
# F1Tenth Scoreapp

**F1Tenth Scoreapp** is a complete solution for measuring lap time on a racing track, which was developed for [International F1/10 Autonomous Racing Competition](https://f1tenth.org/).

This project consists of several parts:
1. [frontend](./frontend/) (client-side React.js app)
2. [backend](./backend/) (Go server providing REST and WebSocket APIs)
3. [optical barrier code and design](./barrier/) (KiCAD, C, Czech)
3. [Arrowhead backend wrapper](./arrowhead/backend/) (Arrowhead Compliant wrapper for launching the backend)
4. [optical barrier code and design](./barrier/) (KiCAD, C, Czech)
5. [Arrowhead barrier wrapper](./barrier-arrowhead/) (Arrowhead Compliant wrapper for the optic barrier)

![Optical barrier based on Raspberry Pi Zero](doc/barrier.jpg)


## License

F1tenth Scoreapp is released under the **TODO** license. Reach us for more information.


## About Arrowhead Tools

<img src="https://www.eclipse.org/org/research/images/research/arrowheadtools.png" alt="Arrowhead Tools logo" width="150" />

This project has been developed by [Industrial Informatics Department](https://iid.ciirc.cvut.cz/) that is a part of [Czech Institute of Informatics, Robotics and Cybernetics](https://ciirc.cvut.cz/), Czech Technical University in Prague. It has received funding from the EU ECSEL Joint Undertaking and the Ministry of Education of the Czech Republic under grant agreement n° 826452 and 8A19011 (project Arrowhead Tools).

The [Arrowhead Tools](https://arrowhead.eu/arrowheadtools) project aims for digitalisation and automation solutions for the European industry, which will close the gaps that hinder the IT/OT integration by introducing new technologies in an open source platform for the design and run-time engineering of IoT and System of Systems. The project will provide engineering processes, integration platform, tools and tool chains for the cost-efficient development of digitalisation, connectivity and automation system solutions in various fields of application.
5 changes: 5 additions & 0 deletions arrowhead/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.p12
*.pub
*.ca
ahconf.py
scoreapp.db
57 changes: 57 additions & 0 deletions arrowhead/backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# f1tenth-scoreapp-backend-arrowhead
_An Arrowhead compliant overlay for backend._

This application serves as an Arrowhead overlay for the **F1Tenth Scoreapp** (backend). It registers itself as an Arrowhead Service `scoreapp` and launches the backend scoreapp itself. Provided Service is consumed by the optical barriers.

The Service `scoreapp` provided by this overlay has following metadata:
- `authorization` -- secret keyphrase for authorizing the barrier (it is used by the barrier to authorize itself with the scoreapp)
- `endpoint_X` -- available endpoint for the barrier to connect to

_Note: The amount of endpoints is not limited. Each parameter starting with `endpoint_` should be treated as an endpoint option._


## Requirements
- `aclpy >= 0.2.0`
- GitHub: [https://github.com/CTU-IIG/ah-acl-py](https://github.com/CTU-IIG/ah-acl-py)
- Wheel: [v0.2.0](https://github.com/jara001/ah-acl-py/releases/download/v0.2.0/aclpy-0.2.0-py3-none-any.whl)


## Usage

1. Obtain certificates (`.p12`, `.pub`) for your system from your local Arrowhead Core.
2. Obtain also the certificate authority `.ca` for your cloud.
3. Create a configuration file `ahconf.py`.
4. Run the `overlay.py3`.


## Configuration example

```python
Server = ArrowheadServer(
address = "192.168.1.22",
)

Interface = ArrowheadInterface(
name = "HTTP-INSECURE-JSON",
)

Service = ArrowheadService(
name = "scoreapp",
metadata = {
"authorization": "secret",
"endpoint_1": "barrier/1",
"endpoint_2": "barrier/2",
},
)

Client = ArrowheadClient(
name = "overlay",
address = "192.168.12.22",
port = 4110,
p12file = "overlay.p12",
p12pass = "SomeSecurePassword",
cafile = "authority.ca",
server = Server,
interfaces = [Interface],
)
```
Binary file added arrowhead/backend/arrowhead_logo.bmp
Binary file not shown.
97 changes: 97 additions & 0 deletions arrowhead/backend/overlay.py3
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
# overlay.py3
"""Arrowhead Compliant overlay."""
######################
# Logo
######################

from PIL import Image
# https://stackoverflow.com/questions/68957686/pillow-how-to-binarize-an-image-with-threshold
arrowhead_logo = Image.open("arrowhead_logo.bmp") \
.convert("L") \
.point( lambda p: 255 if p > 20 else 0 ) \
.convert("1") \
.resize((16, 9))

import sys

def show_arrowhead_logo():
for y in range(arrowhead_logo.height):
for x in range(arrowhead_logo.width):
if arrowhead_logo.getpixel((x, y)):
sys.stdout.write("#")
else:
sys.stdout.write(" ")
print("")


######################
# Arrowhead Configuration
######################

from aclpy.client.client_pkcs12 import ArrowheadClient
from aclpy.interface import ArrowheadInterface
from aclpy.server import ArrowheadServer
from aclpy.service import ArrowheadService

exec(open("ahconf.py", "rb").read())
"""Expected contents:
Server = ArrowheadServer(
address = AH_CORE_IP_ADDRESS,
)

Interface = ArrowheadInterface(
name = NAME_OF_THE_INTERFACE,
)

Service = ArrowheadService(
name = NAME_OF_THE_SERVICE,
)

Client = ArrowheadClient(
name = NAME_OF_THE_SYSTEM,
address = SYSTEM_IP_ADDRESS,
port = SYSTEM_PORT,
pubfile = PATH_TO_PUB_FILE,
p12file = PATH_TO_P12_FILE,
p12pass = PASS_TO_P12_FILE,
cafile = PATH_TO_CA_FILE,
server = Server,
interfaces = [Interface],
)
"""

import signal

def exit_sequence(sig, frame):
Client.unregister_service(Service)

exit(0)


signal.signal(signal.SIGTERM, exit_sequence)

######################
# Arrowhead Sequence
######################

import time, os

show_arrowhead_logo()
print ("Arrowhead backend overlay starting up...\n")

print ("Registering '%s' service to Arrowhead Core..." % Service.name)
if not Client.register_service(Service):
Client.unregister_service(Service)

if not Client.register_service(Service):
print (Client.last_error)
exit (1)

print ("> Registration successful.")
print ("> Interface ID: %d\n> Provider ID: %d\n> Service ID: %d\n" % (Interface.id, Client.id, Service.id))

print ("Starting scoreapp...")
os.system("../../backend/scoreapp")

exit_sequence(signal.SIGTERM, None)
1 change: 1 addition & 0 deletions arrowhead/barrier
Submodule barrier added at 4f77c4
1 change: 1 addition & 0 deletions barrier/optic_barrier_sw/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git.h
60 changes: 60 additions & 0 deletions barrier/optic_barrier_sw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,66 @@ cmake_minimum_required(VERSION 3.1.0)

project(optic_barrier_sw)

# Git versioning
set(PRE_CONFIGURE_FILE "git.h.in")
set(POST_CONFIGURE_FILE "git.h")

# Check whether we have git
execute_process(
COMMAND git --version
RESULT_VARIABLE GIT_CHECK
)

if("${GIT_CHECK}" EQUAL 0)
set(GIT_AVAILABLE true)
else()
set(GIT_AVAILABLE false)
endif()

# Preset variables
set(GIT_IS_DIRTY false)

if(GIT_AVAILABLE)
# Git describe
execute_process(
COMMAND git describe --always --tags
jara001 marked this conversation as resolved.
Show resolved Hide resolved
OUTPUT_VARIABLE GIT_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Commit hash
execute_process(
COMMAND git log -1 --format=%h
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Dirty
execute_process(
COMMAND git status --porcelain -uno
OUTPUT_VARIABLE GIT_DIRTY
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if ("${GIT_DIRTY}" STREQUAL "")
set(GIT_IS_DIRTY false)
else()
set(GIT_IS_DIRTY true)
endif()

# Branch name
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()

get_filename_component(PRE_CONFIGURE_FILE "${PRE_CONFIGURE_FILE}" ABSOLUTE)
get_filename_component(POST_CONFIGURE_FILE "${POST_CONFIGURE_FILE}" ABSOLUTE)

configure_file("${PRE_CONFIGURE_FILE}" "${POST_CONFIGURE_FILE}" @ONLY)

# If you want to use different compiler than arm-linux-gnueabihf-gcc, run cmake as:
# cmake -DHARDCODE_C_COMPILER=NO -DCMAKE_C_COMPILER=...
set(HARDCODE_C_COMPILER YES CACHE BOOL "Override user's (or default) value of CMAKE_C_COMPILER with 'arm-linux-gnueabihf-gcc'")
Expand Down
9 changes: 9 additions & 0 deletions barrier/optic_barrier_sw/git.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#define GIT_AVAILABLE @GIT_AVAILABLE@

#define GIT_DESCRIBE "@GIT_DESCRIBE@"

#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"

#define GIT_IS_DIRTY @GIT_IS_DIRTY@

#define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@"
Loading