added german documentation to seeding and double elimination api/ gamestate
This commit is contained in:
parent
de9b671f29
commit
369692b619
8 changed files with 107 additions and 24 deletions
|
@ -23,14 +23,14 @@ API_URL_GET_ROBOT_STATE = API_URL + "getRobotState"
|
|||
|
||||
|
||||
class Seeding:
|
||||
"""Class used for communicating with seeding api
|
||||
"""Klasse welche mit der Seeding API Kommuniziert.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_heuballen() -> int:
|
||||
"""Makes the /api/getHeuballen call to the api.
|
||||
"""Macht den /api/getHeuballen request zur Seeding API.
|
||||
|
||||
:return: hueballencode as int.
|
||||
:return: hueballencode als int.
|
||||
:rtype: int
|
||||
"""
|
||||
res = requests.get(API_URL_GET_HEU)
|
||||
|
@ -40,9 +40,9 @@ class Seeding:
|
|||
|
||||
@staticmethod
|
||||
def get_logistic_plan() -> List:
|
||||
"""Makes the /api/getLogisticPlan call to the api.
|
||||
"""Macht den /api/getLogisticPlan zur Seeding API.
|
||||
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:return: Liste an logistic-centern, welche vom roboter in genau der Reihenfolge beliefert werden sollten.
|
||||
:rtype: List
|
||||
"""
|
||||
res = requests.get(API_URL_GET_LOGISTIC_PLAN)
|
||||
|
@ -52,7 +52,7 @@ class Seeding:
|
|||
|
||||
@staticmethod
|
||||
def get_material_deliveries() -> List:
|
||||
"""Makes the /api/getMaterialDeliveries call to the api.
|
||||
"""Macht den /api/getMaterialDeliveries zur Seeding API.
|
||||
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: List
|
||||
|
|
|
@ -29,7 +29,12 @@ API_URL_GET_SCORES = API_URL + "getScores"
|
|||
|
||||
|
||||
class Position:
|
||||
"""Datastructure for holding a position
|
||||
"""
|
||||
Datenstruktur, welche eine Position representiert.
|
||||
|
||||
:ivar x: X Position in Centimeter
|
||||
:ivar y: Y Position in Centimeter
|
||||
:ivar degrees: Rotation in Grad von -180 bis 180
|
||||
"""
|
||||
|
||||
def __init__(self, x, y, degrees):
|
||||
|
@ -57,13 +62,14 @@ class Position:
|
|||
|
||||
|
||||
class DoubleElim:
|
||||
"""Class used for communicating with double elimination api
|
||||
"""Klasse für die Kommunikation mit Double Elimination Api
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_pos() -> Tuple[Position, int]:
|
||||
"""Makes the /api/getPos call to the api.
|
||||
:return: A Position object with robot position
|
||||
"""Führt den /api/getPos Aufruf an die API aus.
|
||||
|
||||
:return: Ein Objekt der Klasse :class:`.Position` mit der Position des Roboters und der Status Code
|
||||
:rtype: Tuple[Position, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_POS)
|
||||
|
@ -80,8 +86,9 @@ class DoubleElim:
|
|||
|
||||
@staticmethod
|
||||
def get_opponent() -> Tuple[Position, int]:
|
||||
"""Makes the /api/getOp call to the api.
|
||||
:return: A Position object with opponents robot position
|
||||
"""Führt den /api/getOp Aufruf an die API aus.
|
||||
|
||||
:return: Ein Objekt der Klasse :class:`.Position` mit der Position des gegnerischen Roboters relativ zum eigenen Roboter und der Status Code
|
||||
:rtype: Tuple[Position, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_OP)
|
||||
|
@ -98,8 +105,9 @@ class DoubleElim:
|
|||
|
||||
@staticmethod
|
||||
def get_goal() -> Tuple[Position, int]:
|
||||
"""Makes the /api/getGoal call to the api.
|
||||
:return: A Position object with x and y coordinates of the goal, rotation is always -1
|
||||
"""Führt den /api/getGoal Aufruf an die API aus.
|
||||
|
||||
:return: Ein Objekt der Klasse :class:`.Position` mit der Position des Ziels relativ zum eigenen Roboter und der Status Code
|
||||
:rtype: Tuple[Position, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_GOAL)
|
||||
|
@ -116,8 +124,9 @@ class DoubleElim:
|
|||
|
||||
@staticmethod
|
||||
def get_items() -> Tuple[List[Dict], int]:
|
||||
"""Makes the /api/getItems call to the api.
|
||||
:return: A list will all items currently on the game field. Items are dictionaries that look like: {"id": 0, "x": 0, "y": 0}
|
||||
"""Führt den /api/getItems Aufruf an die API aus.
|
||||
|
||||
:return: Eine Liste aller Items, die sich derzeit auf dem Spielfeld befinden. Items sind "dictionaries", die wie folgt aussehen: {"id": 0, "x": 0, "y": 0}
|
||||
:rtype: Tuple[List[Dict], int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_ITEMS)
|
||||
|
@ -134,8 +143,9 @@ class DoubleElim:
|
|||
|
||||
@staticmethod
|
||||
def get_scores() -> Tuple[Dict, int]:
|
||||
"""Makes the /api/getScores call to the api.
|
||||
:return: A dictionary with all scores included like: {"self":2,"opponent":0}
|
||||
"""Führt den /api/getScores Aufruf an die API aus.
|
||||
|
||||
:return: Ein "dictionary" mit dem eignen Score und dem des Gegners: {"self":2,"opponent":0}
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
res = requests.get(API_URL_GET_SCORES)
|
||||
|
|
|
@ -12,7 +12,7 @@ class Motor(object):
|
|||
def power(port: int, percent: float):
|
||||
"""Motor auf eine prozentuale Leistung der Höchstgeschwindigkeit einstellen
|
||||
|
||||
:param port: Port, an welchen der Motor angestecht wird. 0-3
|
||||
:param port: Port, an welchen der Motor angesteckt ist. 0-3
|
||||
:param percent: Prozentsatz der Höchstgeschwindigkeit. zwischen -100 und 100
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
@ -61,7 +61,7 @@ class Motor(object):
|
|||
def speed(port: int, speed: float):
|
||||
"""Geschwindigkeit des Motors einstellen
|
||||
|
||||
:param port: Port, an welchen der Motor angestecht wird. 0-3
|
||||
:param port: Port, an welchen der Motor angesteckt ist. 0-3
|
||||
:param speed: Drehzahl, mit der sich ein Motor dreht, in Radianten pro Sekunde (rad/s)
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
@ -103,7 +103,7 @@ class Motor(object):
|
|||
def pulse_width(port: int, percent: float):
|
||||
"""Setzen den Pulsbreite eines Motors in Prozent der Periode
|
||||
|
||||
:param port: Port, an welchen der Motor angestecht wird. 0-3
|
||||
:param port: Port, an welchen der Motor angesteckt ist. 0-3
|
||||
:param percent: Prozent der Periode zwischen -100 und 100
|
||||
:raises: IndexError
|
||||
"""
|
||||
|
@ -120,7 +120,7 @@ class Motor(object):
|
|||
|
||||
@staticmethod
|
||||
def multiple_pulse_width(*arguments: tuple[int, float]):
|
||||
"""Setzen den Pulsbreite mehreer Motoren in Prozent der Periode
|
||||
"""Setzen den Pulsbreite mehrerer Motoren in Prozent der Periode
|
||||
|
||||
:param arguments: tuple von port, prozent
|
||||
:raises: IndexError
|
||||
|
|
|
@ -21,6 +21,11 @@ Logistic Plan: {self.logistic_plan}
|
|||
Logistic Centers: {self.logistic_center}"""
|
||||
|
||||
def __init__(self, seed: int):
|
||||
"""
|
||||
Erstellt den Seeding "Gamestate" für den angegebenen Seed.
|
||||
|
||||
:param seed: Seed welcher zum Erstellen des Gamestates benutzt werden soll.
|
||||
"""
|
||||
self.seed = seed
|
||||
set_random_seed(seed)
|
||||
|
||||
|
@ -80,10 +85,25 @@ Logistic Centers: {self.logistic_center}"""
|
|||
self.logistic_plan = [x + 10 for x in self.logistic_plan]
|
||||
|
||||
def get_heuballen(self) -> int:
|
||||
"""
|
||||
Die Funktion gibt entweder die Zahl "1" oder "2" zurück. Wenn die Funktion "1" zurückgibt, dann liegen die Heuballen auf den gelben Linien. Wenn die Funktion "2" zurückgibt, dann liegen sie auf den blauen Flächen.
|
||||
|
||||
:return: Gibt entweder die Zahl 1 oder 2 zurück.
|
||||
"""
|
||||
return self.heu_color
|
||||
|
||||
def get_logistic_plan(self) -> []:
|
||||
"""
|
||||
Die Funktion gibt den "Logistik Plan" zurück. Also die Reihenfolge, in welcher der Roboter die Logistik Zonen Abfahren muss, um die Pakete welche dort liegen zu sortieren.
|
||||
|
||||
:return: Eine Liste an Zahlen zwischen 10 und 13.
|
||||
"""
|
||||
return self.logistic_plan
|
||||
|
||||
def get_material_deliveries(self) -> [[]]:
|
||||
"""
|
||||
Die Funktion gibt die einzelnen "Material Lieferungen" zurück. Da der Roboter immer zwei Paare an Materialien anliefern muss, gibt die Funktion eine Liste an Material Paaren zurück. Die Materialien werden dabei durch ihre Zonen-ID representiert. Also Holz ist z.B. "0" und die Ziegelsteine sind "3".
|
||||
|
||||
:return: Eine Liste and Material Paaren.
|
||||
"""
|
||||
return self.material_pairs
|
||||
|
|
|
@ -22,6 +22,7 @@ os.environ["EXTENSIVE_LOGGING"] = "False"
|
|||
project = 'CompLib'
|
||||
copyright = '2022, Verein zur Förderung von Wissenschaft und Technik an Schulen (F-WuTS)'
|
||||
author = 'robo4you'
|
||||
autoclass_content = 'both'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.2.3'
|
||||
|
|
13
client/docs/source/lib/classes/DoubleElimination.rst
Normal file
13
client/docs/source/lib/classes/DoubleElimination.rst
Normal file
|
@ -0,0 +1,13 @@
|
|||
.. _lib_doubleElim:
|
||||
|
||||
Double Elimination
|
||||
*******************
|
||||
|
||||
Dokumentation des Double Elimination Moduls
|
||||
============================================
|
||||
|
||||
.. autoclass:: compLib.DoubleElimination.Position
|
||||
:members:
|
||||
|
||||
.. autoclass:: compLib.DoubleElimination.DoubleElim
|
||||
:members:
|
36
client/docs/source/lib/classes/Seeding.rst
Normal file
36
client/docs/source/lib/classes/Seeding.rst
Normal file
|
@ -0,0 +1,36 @@
|
|||
.. _lib_seeding:
|
||||
|
||||
Seeding
|
||||
*******
|
||||
|
||||
Dokumentation des Seeding Moduls
|
||||
================================
|
||||
|
||||
.. autoclass:: compLib.Seeding.Gamestate
|
||||
:members:
|
||||
|
||||
Beispiele
|
||||
----------
|
||||
|
||||
| In ``Zeile 1`` wird das Seeding Modul importiert.
|
||||
| In ``Zeile 2`` definieren wir dann eine Variable, in der wir den "Seed" des Gamestates den wir erstellen wollten speichern.
|
||||
| In ``Zeile 3`` erstellen wir dann einen neuen Gamestate mit dem Seed und speichern ihn in die Variable ``gamestate``.
|
||||
| In ``Zeile 4`` geben wir dann den Gamestate aus, damit wir ihn auf der Konsole ansehen können.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import compLib.Seeding as Seeding
|
||||
seed = 42
|
||||
gamestate = Seeding.Gamestate(seed)
|
||||
print(gamestate)
|
||||
|
||||
In der Ausgabe des Print Statements sehen wir den generierten Gamestate.
|
||||
|
||||
.. code-block::
|
||||
|
||||
Seed: 42
|
||||
Heu Color: 1
|
||||
Material Pairs: [[3, 0], [2, 3], [0, 2], [1, 2]]
|
||||
Material Zones: [2, 1, 3, 2]
|
||||
Logistic Plan: [12, 13, 12, 13, 10, 11, 13, 10, 13, 12, 11, 10, 11, 13, 10, 11, 12, 11, 12, 10, 12]
|
||||
Logistic Centers: [[0, 3, 1, 1], [1, 0, 2, 2], [1, 2, 0, 2], [3, 0, 2, 0]]
|
|
@ -3,6 +3,9 @@ compLib
|
|||
|
||||
.. toctree::
|
||||
:maxdepth: 5
|
||||
:glob:
|
||||
|
||||
classes/*
|
||||
classes/Motor
|
||||
classes/Encoder
|
||||
classes/IRSensor
|
||||
classes/Seeding
|
||||
classes/DoubleElimination
|
||||
|
|
Reference in a new issue