documentation, IP writing service
This commit is contained in:
parent
03daabaa37
commit
afe5e9c766
22 changed files with 502 additions and 12 deletions
3
client_s2/docs/.gitignore
vendored
Normal file
3
client_s2/docs/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
build
|
||||
logs.db
|
||||
!lib
|
20
client_s2/docs/Makefile
Normal file
20
client_s2/docs/Makefile
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
35
client_s2/docs/make.bat
Normal file
35
client_s2/docs/make.bat
Normal file
|
@ -0,0 +1,35 @@
|
|||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
0
client_s2/docs/source/_static/.gitkeep
Normal file
0
client_s2/docs/source/_static/.gitkeep
Normal file
63
client_s2/docs/source/conf.py
Normal file
63
client_s2/docs/source/conf.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
sys.setrecursionlimit(1500)
|
||||
os.environ["EXTENSIVE_LOGGING"] = "False"
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'CompLib'
|
||||
copyright = '2022, Verein zur Förderung von Wissenschaft und Technik an Schulen (F-WuTS)'
|
||||
author = 'robo4you'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.2.3'
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx_rtd_theme'
|
||||
]
|
||||
|
||||
autodoc_mock_imports = ["smbus", "compLib.PCA9685", "RPi",
|
||||
"pigpio", "flask", "apt", "influxdb_client"]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
|
||||
language = "de"
|
189
client_s2/docs/source/images/compair-logo-white.svg
Normal file
189
client_s2/docs/source/images/compair-logo-white.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 188 KiB |
18
client_s2/docs/source/index.rst
Normal file
18
client_s2/docs/source/index.rst
Normal file
|
@ -0,0 +1,18 @@
|
|||
.. image:: images/compair-logo-white.svg
|
||||
|
||||
Dokumentation des Roboters
|
||||
##########################
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
Contents
|
||||
*********
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 5
|
||||
:glob:
|
||||
|
||||
other/usage
|
||||
lib/index.rst
|
47
client_s2/docs/source/lib/classes/Motor.rst
Normal file
47
client_s2/docs/source/lib/classes/Motor.rst
Normal file
|
@ -0,0 +1,47 @@
|
|||
.. _lib_motor:
|
||||
|
||||
Motoren
|
||||
********
|
||||
|
||||
Dokumentation der Klasse
|
||||
========================
|
||||
|
||||
.. autoclass:: compLib.Motor.Motor
|
||||
:members:
|
||||
|
||||
Genauere Informationen
|
||||
======================
|
||||
|
||||
Power vs Speed
|
||||
--------------
|
||||
Zur ansteuerung der Motoren kann entweder ``Motor.power(...)`` oder ``Motor.speed(...)`` verwendet werden.
|
||||
Der Unterschied der 2 Funktionen liegt dabei in der Einheit des 2. Parameters. Bei ``Motor.power()`` wird dabei ein Wert zwischen -100% und 100% der maximalen Geschwindigkeit angegeben.
|
||||
Im Gegensatz dazu erlaubt einem ``Motor.speed()`` eine Geschwindigkeit in Umdrehungen pro Minute.
|
||||
|
||||
Normal vs Multiple
|
||||
------------------
|
||||
Der Aufruf der funktionen kann entweder über ``Motor.power(port, percent)`` oder ``Motor.power((port, percent), (port, percent), ..)`` erfolgen.
|
||||
Der zweite Aufruf ermöglicht dem Entwickler dabei beide Motoren in einem Aufruf anzusteuern und bringt einen kleinen Vorteil in der Leistungsfähigkeit der Software.
|
||||
|
||||
|
||||
Beispiele
|
||||
=========
|
||||
|
||||
Vorwärts fahren
|
||||
-------------
|
||||
|
||||
Mit folgenden Programm drehen sich beide Motoren mit 50% ihrer maximalen Geschwindigkeit.
|
||||
Dabei ist zu beachten, dass ein Motor in die entgegengesetzte Richtung zum aneren Motor gedreht werden muss, da diese spiegelverkehrt montiert sind.
|
||||
|
||||
Zusätzlich ist ein ``time.sleep(5)`` notwendig, welches das Programm für 5 Sekunden pausiert. Diese Pause wird benötigt, da der Roboter automatisch alle Motoren beim Ende des Progammes deaktiviert.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from compLib.Motor import Motor
|
||||
import time
|
||||
|
||||
Motor.power(0, -50)
|
||||
Motor.power(3, 50)
|
||||
|
||||
time.sleep(5)
|
||||
|
BIN
client_s2/docs/source/lib/classes/images/chessboard.jpg
Normal file
BIN
client_s2/docs/source/lib/classes/images/chessboard.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
BIN
client_s2/docs/source/lib/classes/images/chessboard_detected.jpg
Normal file
BIN
client_s2/docs/source/lib/classes/images/chessboard_detected.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
BIN
client_s2/docs/source/lib/classes/images/opencv_http_stream.png
Normal file
BIN
client_s2/docs/source/lib/classes/images/opencv_http_stream.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 391 KiB |
BIN
client_s2/docs/source/lib/classes/images/opencv_processed.png
Normal file
BIN
client_s2/docs/source/lib/classes/images/opencv_processed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 356 KiB |
8
client_s2/docs/source/lib/index.rst
Normal file
8
client_s2/docs/source/lib/index.rst
Normal file
|
@ -0,0 +1,8 @@
|
|||
compLib
|
||||
#######
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 5
|
||||
:glob:
|
||||
|
||||
classes/*
|
32
client_s2/docs/source/other/usage.rst
Normal file
32
client_s2/docs/source/other/usage.rst
Normal file
|
@ -0,0 +1,32 @@
|
|||
.. _other_usage:
|
||||
|
||||
Beispiele
|
||||
#########
|
||||
|
||||
Vorwärts und rückwärts fahren
|
||||
*****************************
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import time
|
||||
from compLib.Motor import *
|
||||
|
||||
def forward():
|
||||
Motor.power(1, -30);
|
||||
Motor.power(2, 30);
|
||||
|
||||
|
||||
def backward():
|
||||
Motor.power(1, 30);
|
||||
Motor.power(2, -30);
|
||||
|
||||
def main():
|
||||
print("hallo ich bin ein roboter beep buup")
|
||||
|
||||
forward()
|
||||
time.sleep(1)
|
||||
backward()
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
23
client_s2/sphinx_to_github.sh
Executable file
23
client_s2/sphinx_to_github.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
export BUILDING_DOCS=true
|
||||
cd docs || exit
|
||||
rm -rf build
|
||||
rm -rf gh-pages
|
||||
|
||||
make html
|
||||
|
||||
git clone git@github.com:F-WuTS/compLIB.git gh-pages
|
||||
|
||||
cd gh-pages || exit
|
||||
git checkout gh-pages
|
||||
|
||||
cp -r ../build/html/* .
|
||||
|
||||
git add .
|
||||
git commit -a -m "Update documentation"
|
||||
git push origin gh-pages
|
||||
|
||||
cd ..
|
||||
rm -rf gh-pages
|
||||
|
||||
cd ..
|
||||
export BUILDING_DOCS=false
|
10
server_v2/.idea/other.xml
generated
10
server_v2/.idea/other.xml
generated
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoUploadManager">
|
||||
<option name="hosts">
|
||||
<list>
|
||||
<option value="9c7ab821-1501-483e-beda-814d54656ca2" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -56,7 +56,9 @@ set(SRC_FILES
|
|||
src/communication/UnixSocketServer.cpp
|
||||
src/communication/TCPSocketServer.cpp
|
||||
src/GoToController.cpp
|
||||
src/HealthChecker.cpp)
|
||||
src/HealthChecker.cpp
|
||||
src/Display.cpp
|
||||
src/IPWritingService.cpp)
|
||||
|
||||
set(HDR_FILES
|
||||
include/spi.hpp
|
||||
|
@ -77,7 +79,9 @@ set(HDR_FILES
|
|||
include/communication/UnixSocketServer.hpp
|
||||
include/communication/TCPSocketServer.hpp
|
||||
include/GoToController.hpp
|
||||
include/HealthChecker.hpp)
|
||||
include/HealthChecker.hpp
|
||||
include/Display.hpp
|
||||
include/IPWritingService.hpp)
|
||||
|
||||
include_directories(third_party/asio)
|
||||
|
||||
|
|
16
server_v2/include/Display.hpp
Normal file
16
server_v2/include/Display.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef COMPLIB_SERVER_DISPLAY_HPP
|
||||
#define COMPLIB_SERVER_DISPLAY_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class Display {
|
||||
public:
|
||||
static void write(uint8_t line, std::string text);
|
||||
|
||||
private:
|
||||
|
||||
Display() = default;
|
||||
};
|
||||
|
||||
#endif //COMPLIB_SERVER_DISPLAY_HPP
|
16
server_v2/include/IPWritingService.hpp
Normal file
16
server_v2/include/IPWritingService.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef COMPLIB_SERVER_IPWRITINGSERVICE_HPP
|
||||
#define COMPLIB_SERVER_IPWRITINGSERVICE_HPP
|
||||
|
||||
#include <thread>
|
||||
|
||||
class IPWritingService {
|
||||
public:
|
||||
IPWritingService();
|
||||
|
||||
private:
|
||||
[[noreturn]] void writing_loop();
|
||||
|
||||
std::thread writing_thread;
|
||||
};
|
||||
|
||||
#endif //COMPLIB_SERVER_IPWRITINGSERVICE_HPP
|
7
server_v2/src/Display.cpp
Normal file
7
server_v2/src/Display.cpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "include/Display.hpp"
|
||||
#include "include/spi.hpp"
|
||||
|
||||
void Display::write(uint8_t line, std::string text) {
|
||||
text.resize(16);
|
||||
Spi::getInstance().write_array(Spi::DISPLAY_LINE_1_C0 + line * 16, 16, reinterpret_cast<const uint8_t *>(text.c_str()));
|
||||
}
|
17
server_v2/src/IPWritingService.cpp
Normal file
17
server_v2/src/IPWritingService.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "include/IPWritingService.hpp"
|
||||
#include "include/networkUtils.hpp"
|
||||
#include "include/Display.hpp"
|
||||
|
||||
IPWritingService::IPWritingService() {
|
||||
writing_thread = std::thread(&IPWritingService::writing_loop, this);
|
||||
writing_thread.detach();
|
||||
}
|
||||
|
||||
void IPWritingService::writing_loop() {
|
||||
while (true) {
|
||||
auto host_and_ip = networkUtils::get_current_host_and_ip();
|
||||
Display::write(2, std::get<0>(host_and_ip));
|
||||
Display::write(3, std::get<1>(host_and_ip));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
#include "include/GoToController.hpp"
|
||||
#include "include/Encoders.hpp"
|
||||
#include "include/networkUtils.hpp"
|
||||
#include "include/IPWritingService.hpp"
|
||||
|
||||
#ifdef IS_RASPI
|
||||
|
||||
|
@ -27,6 +28,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
UnixSocketServer unixSocketServer;
|
||||
TCPSocketServer tcpSocketServer;
|
||||
IPWritingService ipWritingService;
|
||||
HealthChecker::getInstance();
|
||||
|
||||
#ifdef IS_RASPI
|
||||
|
|
Reference in a new issue