Skip to content
Snippets Groups Projects
Commit 8df9fb86 authored by Muhamed's avatar Muhamed
Browse files

Merge branch 'Develop'

parents c12911fe b44435f5
Branches
No related tags found
No related merge requests found
Showing
with 7155 additions and 10 deletions
Source diff could not be displayed: it is too large. Options to address this: view the blob.
# 2025-05-15 21:09:50.551054
+y
# 2025-05-15 21:11:00.460268
+/add C:\Users\muham\OneDrive\Desktop\decker 2\Rover2\marsrover\rest.txt
# 2025-05-15 21:11:42.471363
+n
# 2025-05-15 21:11:53.933976
+/add rest.txt
# 2025-05-15 21:12:03.379723
+/read-only rest.txt
# 2025-05-15 21:13:01.201618
+read it
# 2025-05-15 21:13:16.982291
+y
# 2025-05-15 21:13:33.448481
+n
# 2025-05-15 21:14:27.671213
+/drop Pyscript.py
# 2025-05-15 21:14:47.630069
+read the rest.txt
# 2025-05-15 21:17:53.553232
+/ask what is the rest.txt?
# 2025-05-15 21:18:20.532844
+/ask what can you do with the rest.txt
# 2025-05-15 21:19:18.552869
+/model sonnet openrouter/anthropic/claude-3.7-sonnet
# 2025-05-15 21:19:32.674663
+/ask what is tge rest.txt about?
# 2025-05-15 21:19:42.031921
+n
# 2025-05-15 21:19:52.187436
+/ask rest.txt what is this
# 2025-05-15 21:23:27.193219
+/add rest.txt
# 2025-05-15 21:23:48.199538
+/ask what is inside that
# 2025-05-15 22:17:15.971840
+/add C:\Users\muham\OneDrive\Desktop\decker 2\Rover2\marsrover\Bildschirmfoto_15-5-2025_221527_.jpeg
# 2025-05-15 22:17:51.325776
+n
# 2025-05-15 22:17:59.735628
+/add "C:\Users\muham\OneDrive\Desktop\decker 2\Rover2\marsrover\Bildschirmfoto_15-5-2025_221527_.jpeg"
# 2025-05-15 22:20:33.217179
+/add
# 2025-05-15 22:20:55.009062
+/add Aider_implementation
# 2025-05-15 22:26:45.740736
+/ask Please continue updating the Python code in this project based on the provided UML diagram. This is an updated version of the design you were working with previously, now explicitly showing a REST API interaction.
+
+Focus on implementing or refining the following elements according to the diagram:
+
+* **Map** (Class):
+ * Attribute: `map` (confirm it's a list of lists or tuples as specified)
+ * Method: `move(x: int, y: int) -> None`
+* **MissionControl** (Class):
+ * This class needs to orchestrate interactions with `Map`, `Telescope`, `Rover`, and `Mars`. Review and implement the necessary methods for this coordination.
+ * **Crucially, the diagram shows that `MissionControl` interacts with the `Rover`'s `drive` functionality specifically via a REST API endpoint `POST /drive`. Modify the code to reflect this. You may need to simulate the API call if a full web framework is not part of the project scope, but the interaction pattern should represent a REST call.**
+* **Telescope** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `observe() -> grid` (returning the Plateau's grid).
+* **Rover** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `drive(cmd: str) -> str`. Remember its behavior regarding successful commands and ODS stopping.
+ * **The functionality of this `drive` method is accessed externally by `MissionControl` via the `POST /drive` REST API endpoint.**
+* **Plateau** (Class):
+ * Attribute: `grid` (list of lists or tuples)
+ * Constructor: `__init__(size_x: int, size_y: int) -> None` (creates the plateau of given size).
+ * Method: `move(x: int, y: int) -> None` (notes obstacle and rover positions).
+* **Mars** (Class):
+ * Attribute: `grid`
+ * Constructor: `__init__(size_x: int, size_y: int) -> None`
+ * Method: `move(x: int, y: int) -> None`
+ * Method: `drive(cmd: str) -> str`
+ * Continue to refine the relationship between `Mars` and `Plateau` (inheritance or composition) based on the shared members and the diagram's structure.
+* **Relationships:**
+ * Confirm that `MissionControl` interacts with `Map`, `Telescope`, `Rover`, and `Mars`.
+ * `Telescope` and `Rover` interact with `Mars`.
+ * Implement the REST API interaction for `POST /drive` between `MissionControl` and `Rover`.
+
+Please make the necessary code changes to match this updated design, including the specific interaction mechanism for the rover's drive command.
# 2025-05-15 22:27:53.675863
+/ask what is going on in mars
# 2025-05-15 22:28:40.303672
+/model sonnet openrouter/anthropic/claude-3.7-sonnet
# 2025-05-15 22:28:58.839069
+/add "C:\Users\muham\OneDrive\Desktop\decker 2\Rover2\marsrover\Bildschirmfoto_15-5-2025_221527_.jpeg"
# 2025-05-15 22:29:08.338174
+/ask what is going on in mars
# 2025-05-15 22:29:17.533279
+n
# 2025-05-15 22:31:01.647066
+/add Aider_implementation
# 2025-05-15 22:31:12.832286
+/ask what is `Mars`
# 2025-05-15 22:34:01.151354
+/add Aider_implementation
# 2025-05-15 22:34:12.410863
+/ask what is going on on `Mars`
# 2025-05-18 03:22:59.137629
+/ask Please continue updating the Python code in this project based on the provided UML diagram. This is an updated version of the design you were working with previously, now explicitly showing a REST API interaction.
+
+Focus on implementing or refining the following elements according to the diagram:
+
+* **Map** (Class):
+ * Attribute: `map` (confirm it's a list of lists or tuples as specified)
+ * Method: `move(x: int, y: int) -> None`
+* **MissionControl** (Class):
+ * This class needs to orchestrate interactions with `Map`, `Telescope`, `Rover`, and `Mars`. Review and implement the necessary methods for this coordination.
+ * **Crucially, the diagram shows that `MissionControl` interacts with the `Rover`'s `drive` functionality specifically via a REST API endpoint `POST /drive`. Modify the code to reflect this. You may need to simulate the API call if a full web framework is not part of the project scope, but the interaction pattern should represent a REST call.**
+* **Telescope** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `observe() -> grid` (returning the Plateau's grid).
+* **Rover** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `drive(cmd: str) -> str`. Remember its behavior regarding successful commands and ODS stopping.
+ * **The functionality of this `drive` method is accessed externally by `MissionControl` via the `POST /drive` REST API endpoint.**
+* **Plateau** (Class):
+ * Attribute: `grid` (list of lists or tuples)
+ * Constructor: `__init__(size_x: int, size_y: int) -> None` (creates the plateau of given size).
+ * Method: `move(x: int, y: int) -> None` (notes obstacle and rover positions).
+* **Mars** (Class):
+ * Attribute: `grid`
+ * Constructor: `__init__(size_x: int, size_y: int) -> None`
+ * Method: `move(x: int, y: int) -> None`
+ * Method: `drive(cmd: str) -> str`
+ * Continue to refine the relationship between `Mars` and `Plateau` (inheritance or composition) based on the shared members and the diagram's structure.
+* **Relationships:**
+ * Confirm that `MissionControl` interacts with `Map`, `Telescope`, `Rover`, and `Mars`.
+ * `Telescope` and `Rover` interact with `Mars`.
+ * Implement the REST API interaction for `POST /drive` between `MissionControl` and `Rover`.
+
+Please make the necessary code changes to match this updated design, including the specific interaction mechanism for the rover's drive command.
# 2025-05-18 03:28:14.942107
+/ask where do you make use of the rest api?
# 2025-05-18 03:29:47.923771
+/add Aider_implementation
# 2025-05-18 03:30:23.184509
+/ask Please continue updating the Python code in this project based on the provided UML diagram. This is an updated version of the design you were working with previously, now explicitly showing a REST API interaction.
+
+Focus on implementing or refining the following elements according to the diagram:
+
+* **Map** (Class):
+ * Attribute: `map` (confirm it's a list of lists or tuples as specified)
+ * Method: `move(x: int, y: int) -> None`
+* **MissionControl** (Class):
+ * This class needs to orchestrate interactions with `Map`, `Telescope`, `Rover`, and `Mars`. Review and implement the necessary methods for this coordination.
+ * **Crucially, the diagram shows that `MissionControl` interacts with the `Rover`'s `drive` functionality specifically via a REST API endpoint `POST /drive`. Modify the code to reflect this. You may need to simulate the API call if a full web framework is not part of the project scope, but the interaction pattern should represent a REST call.**
+* **Telescope** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `observe() -> grid` (returning the Plateau's grid).
+* **Rover** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `drive(cmd: str) -> str`. Remember its behavior regarding successful commands and ODS stopping.
+ * **The functionality of this `drive` method is accessed externally by `MissionControl` via the `POST /drive` REST API endpoint.**
+* **Plateau** (Class):
+ * Attribute: `grid` (list of lists or tuples)
+ * Constructor: `__init__(size_x: int, size_y: int) -> None` (creates the plateau of given size).
+ * Method: `move(x: int, y: int) -> None` (notes obstacle and rover positions).
+* **Mars** (Class):
+ * Attribute: `grid`
+ * Constructor: `__init__(size_x: int, size_y: int) -> None`
+ * Method: `move(x: int, y: int) -> None`
+ * Method: `drive(cmd: str) -> str`
+ * Continue to refine the relationship between `Mars` and `Plateau` (inheritance or composition) based on the shared members and the diagram's structure.
+* **Relationships:**
+ * Confirm that `MissionControl` interacts with `Map`, `Telescope`, `Rover`, and `Mars`.
+ * `Telescope` and `Rover` interact with `Mars`.
+ * Implement the REST API interaction for `POST /drive` between `MissionControl` and `Rover`.
+
+Please make the necessary code changes to match this updated design, including the specific interaction mechanism for the rover's drive command.
# 2025-05-18 03:31:55.951445
+/drop
# 2025-05-18 03:32:45.034261
+/add map.py
# 2025-05-18 03:33:00.569257
+/add mars.py
# 2025-05-18 03:33:12.214754
+/add mission_control.py
# 2025-05-18 03:33:21.721199
+/add plateu.py
# 2025-05-18 03:33:25.517729
+n
# 2025-05-18 03:33:35.463333
+/add plateau.py
# 2025-05-18 03:33:46.573735
+/add rover.py
# 2025-05-18 03:33:56.349131
+/add telescope.py
# 2025-05-18 03:34:07.316669
+/add test_rover.py
# 2025-05-18 03:34:21.337342
+/ask Please continue updating the Python code in this project based on the provided UML diagram. This is an updated version of the design you were working with previously, now explicitly showing a REST API interaction.
+
+Focus on implementing or refining the following elements according to the diagram:
+
+* **Map** (Class):
+ * Attribute: `map` (confirm it's a list of lists or tuples as specified)
+ * Method: `move(x: int, y: int) -> None`
+* **MissionControl** (Class):
+ * This class needs to orchestrate interactions with `Map`, `Telescope`, `Rover`, and `Mars`. Review and implement the necessary methods for this coordination.
+ * **Crucially, the diagram shows that `MissionControl` interacts with the `Rover`'s `drive` functionality specifically via a REST API endpoint `POST /drive`. Modify the code to reflect this. You may need to simulate the API call if a full web framework is not part of the project scope, but the interaction pattern should represent a REST call.**
+* **Telescope** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `observe() -> grid` (returning the Plateau's grid).
+* **Rover** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `drive(cmd: str) -> str`. Remember its behavior regarding successful commands and ODS stopping.
+ * **The functionality of this `drive` method is accessed externally by `MissionControl` via the `POST /drive` REST API endpoint.**
+* **Plateau** (Class):
+ * Attribute: `grid` (list of lists or tuples)
+ * Constructor: `__init__(size_x: int, size_y: int) -> None` (creates the plateau of given size).
+ * Method: `move(x: int, y: int) -> None` (notes obstacle and rover positions).
+* **Mars** (Class):
+ * Attribute: `grid`
+ * Constructor: `__init__(size_x: int, size_y: int) -> None`
+ * Method: `move(x: int, y: int) -> None`
+ * Method: `drive(cmd: str) -> str`
+ * Continue to refine the relationship between `Mars` and `Plateau` (inheritance or composition) based on the shared members and the diagram's structure.
+* **Relationships:**
+ * Confirm that `MissionControl` interacts with `Map`, `Telescope`, `Rover`, and `Mars`.
+ * `Telescope` and `Rover` interact with `Mars`.
+ * Implement the REST API interaction for `POST /drive` between `MissionControl` and `Rover`.
+
+Please make the necessary code changes to match this updated design, including the specific interaction mechanism for the rover's drive command.
# 2025-05-18 03:34:48.965676
+/help
# 2025-05-18 03:35:08.389909
+/clear
# 2025-05-18 03:35:13.420413
+/exit
# 2025-05-18 03:35:43.662779
+/add map.py
# 2025-05-18 03:35:53.276243
+/add test_rover.py
# 2025-05-18 03:36:02.345416
+/add plateau.py
# 2025-05-18 03:36:09.408657
+/add telescope.py
# 2025-05-18 03:36:22.408932
+/add mars.py
# 2025-05-18 03:36:31.365434
+/add mission_control.py
# 2025-05-18 03:36:56.426121
+/add rover.py
# 2025-05-18 03:37:14.147028
+/ask Please continue updating the Python code in this project based on the provided UML diagram. This is an updated version of the design you were working with previously, now explicitly showing a REST API interaction.
+
+Focus on implementing or refining the following elements according to the diagram:
+
+* **Map** (Class):
+ * Attribute: `map` (confirm it's a list of lists or tuples as specified)
+ * Method: `move(x: int, y: int) -> None`
+* **MissionControl** (Class):
+ * This class needs to orchestrate interactions with `Map`, `Telescope`, `Rover`, and `Mars`. Review and implement the necessary methods for this coordination.
+ * **Crucially, the diagram shows that `MissionControl` interacts with the `Rover`'s `drive` functionality specifically via a REST API endpoint `POST /drive`. Modify the code to reflect this. You may need to simulate the API call if a full web framework is not part of the project scope, but the interaction pattern should represent a REST call.**
+* **Telescope** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `observe() -> grid` (returning the Plateau's grid).
+* **Rover** (Abstract Class):
+ * Ensure this is an abstract base class with the abstract method: `drive(cmd: str) -> str`. Remember its behavior regarding successful commands and ODS stopping.
+ * **The functionality of this `drive` method is accessed externally by `MissionControl` via the `POST /drive` REST API endpoint.**
+* **Plateau** (Class):
+ * Attribute: `grid` (list of lists or tuples)
+ * Constructor: `__init__(size_x: int, size_y: int) -> None` (creates the plateau of given size).
+ * Method: `move(x: int, y: int) -> None` (notes obstacle and rover positions).
+* **Mars** (Class):
+ * Attribute: `grid`
+ * Constructor: `__init__(size_x: int, size_y: int) -> None`
+ * Method: `move(x: int, y: int) -> None`
+ * Method: `drive(cmd: str) -> str`
+ * Continue to refine the relationship between `Mars` and `Plateau` (inheritance or composition) based on the shared members and the diagram's structure.
+* **Relationships:**
+ * Confirm that `MissionControl` interacts with `Map`, `Telescope`, `Rover`, and `Mars`.
+ * `Telescope` and `Rover` interact with `Mars`.
+ * Implement the REST API interaction for `POST /drive` between `MissionControl` and `Rover`.
+
+Please make the necessary code changes to match this updated design, including the specific interaction mechanism for the rover's drive command.
# 2025-05-18 03:41:26.533862
+/add Bildschirmfoto_15-5-2025_221527_.jpeg
# 2025-05-18 03:42:15.882514
+/model anthropic.claude-3-7-sonnet-20250219-v1:0
# 2025-05-18 03:42:19.510752
+/add Bildschirmfoto_15-5-2025_221527_.jpeg
# 2025-05-18 03:48:58.101632
+/ask as you can see in the image that i provided there has to be a rest interface for the rover. mission control sends the rover string commands via rest to the rover. since each request changes the position and the angle of the rover we need to use a post request example: \drive{"Input": "FRF" } the request to the endpoint returns the successfully requestet commands. essentially the endpoint behaves like the rovers drive method. implement this api interface to the existing design of the rover.
# 2025-05-18 03:50:47.130929
+/model openrouter/anthropic/claude-3.7-sonnet
# 2025-05-18 03:50:56.619610
+/ask as you can see in the image that i provided there has to be a rest interface for the rover. mission control sends the rover string commands via rest to the rover. since each request changes the position and the angle of the rover we need to use a post request example: \drive{"Input": "FRF" } the request to the endpoint returns the successfully requestet commands. essentially the endpoint behaves like the rovers drive method. implement this api interface to the existing design of the rover.
# 2025-05-18 03:51:55.382518
+as you can see in the image that i provided there has to be a rest interface for the rover. mission control sends the rover string commands via rest to the rover. since each request changes the position and the angle of the rover we need to use a post request example: \drive{"Input": "FRF" } the request to the endpoint returns the successfully requestet commands. essentially the endpoint behaves like the rovers drive method. implement this api interface to the existing design of the rover.
# 2025-05-18 03:52:46.653757
+y
# 2025-05-18 03:53:12.274518
+/run pip install flask requests
# 2025-05-18 03:53:12.275154
+/run pip install flask requests
# 2025-05-18 03:53:31.462346
+/run python api.py
# 2025-05-18 03:53:31.462346
+/run python api.py
# 2025-05-18 03:54:05.610259
+y
# 2025-05-18 03:54:12.476164
+/run curl -X POST http://localhost:5000/drive -H "Content-Type: application/json" -d "{\"Input\": \"FRF\"}"
# 2025-05-18 03:54:12.476164
+/run curl -X POST http://localhost:5000/drive -H "Content-Type: application/json" -d "{\"Input\": \"FRF\"}"
# 2025-05-18 03:54:14.917248
+y
# 2025-05-18 04:26:56.246304
+/read-only rest.txt
# 2025-05-18 04:27:45.115943
+/add api.py
# 2025-05-18 04:28:45.512549
+create unittest testcases from openapi specification in rest.txt
# 2025-05-18 04:29:04.339546
+n
# 2025-05-18 04:29:39.213922
+y
# 2025-05-18 04:30:46.423541
+/run python test_api.py
# 2025-05-18 04:30:46.425227
+/run python test_api.py
# 2025-05-18 04:37:39.719223
+y
# 2025-05-18 04:37:45.003955
+/run python api.py
# 2025-05-18 04:37:45.004953
+/run python api.py
# 2025-05-18 04:37:49.568562
+y
# 2025-05-18 04:37:51.058032
+/run curl -X POST http://localhost:5000/drive -H "Content-Type: application/json" -d "{\"Input\": \"FRF\"}"
# 2025-05-18 04:37:51.058032
+/run curl -X POST http://localhost:5000/drive -H "Content-Type: application/json" -d "{\"Input\": \"FRF\"}"
# 2025-05-18 04:37:52.531328
+y
# 2025-05-18 04:38:49.297509
+/ask ======================================================================
+FAIL: test_unknown_command_at_start (__main__.TestDriveEndpoint.test_unknown_command_at_start)
+Test für unbekannten Befehl am Anfang (XFB)
+----------------------------------------------------------------------
+Traceback (most recent call last):
+ File "c:\Users\muham\OneDrive\Desktop\decker 2\Rover2\marsrover\test_api.py", line 64, in test_unknown_command_at_start
+ self.assertIn('successful_commands', data)
+AssertionError: 'successful_commands' not found in {'output': 'FB'}
+
+----------------------------------------------------------------------
+Ran 9 tests in 0.015s
+
+FAILED (failures=7)
# 2025-05-18 04:39:38.479381
+übernehme diese veränderung
.aider*
Bildschirmfoto_15-5-2025_221527_.jpeg

171 KiB

...@@ -505,5 +505,15 @@ Please update the `plateau.py` file to implement the methods in the `Plateau` cl ...@@ -505,5 +505,15 @@ Please update the `plateau.py` file to implement the methods in the `Plateau` cl
> Aider hatte wieder das selbe Problem wie im 1. statement, das modell musste wieder gewechselt werden. > Aider hatte wieder das selbe Problem wie im 1. statement, das modell musste wieder gewechselt werden.
# rest api und die tests
> Aider hatte erneut fehler bei der Ausführung wie zuvor
Nach mehreren versuchen Aider auszführen und einigen Anpassungen funktionierte es und der Code wurde erfolgreich angepasst.
Eine Rest schnittstelle wurde implementiert. Meine vorherigen Unittests liefen ohne Probleme allerdings dauerte der durchlauf der tests länger.
Die API tests die von Aider erstellt wurden hatten einen Assertion error da der erwartete Output im Header nicht dem tatsächlichen output entsprochen hat. Ich habe Aider das Problem geschildert und dieser hat die API tests nochmal angepasst. Alle tests laufen ohne fehler.
...@@ -9,7 +9,6 @@ from telescope import Telescope ...@@ -9,7 +9,6 @@ from telescope import Telescope
from map import Map from map import Map
import unittest import unittest
import telescope
# ---US01: Als Mars Mission Control möchte ich den Mars Rover steuern, um die grundlegende Interaktion und Kontrolle über den Rover zu ermöglichen. # ---US01: Als Mars Mission Control möchte ich den Mars Rover steuern, um die grundlegende Interaktion und Kontrolle über den Rover zu ermöglichen.
# TC01.01: Gültiger Vorwärtsbefehl: Überprüft, ob der Rover sich korrekt um ein Feld vorwärts bewegt, wenn der Befehl "F" empfangen wird. # TC01.01: Gültiger Vorwärtsbefehl: Überprüft, ob der Rover sich korrekt um ein Feld vorwärts bewegt, wenn der Befehl "F" empfangen wird.
......
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
api.py 0 → 100644
from flask import Flask, request, jsonify
from rover import Rover
from plateau import Plateau
app = Flask(__name__)
# Initialisierung des Rovers und des Plateaus
plateau = Plateau(10, 10) # Standardgröße, kann angepasst werden
rover = Rover()
rover.set_plateau_size(plateau.size_x, plateau.size_y)
@app.route('/drive', methods=['POST'])
def drive_rover():
"""
Endpunkt zum Steuern des Rovers.
Erwartet ein JSON mit dem Schlüssel "Input", der die Befehlssequenz enthält.
Gibt die erfolgreich ausgeführten Befehle zurück.
Entspricht der OpenAPI-Spezifikation in rest.txt
"""
try:
data = request.get_json()
if not data or 'Input' not in data:
return jsonify({'error': 'Missing or invalid input'}), 400
commands = data['Input']
result = rover.drive(commands)
return jsonify({'output': result})
except Exception as e:
return jsonify({'error': str(e)}), 400
if __name__ == '__main__':
app.run(debug=True)
File moved
File moved
...@@ -28,7 +28,7 @@ class MissionControl: ...@@ -28,7 +28,7 @@ class MissionControl:
def send_commands(self, cmd: str) -> str: def send_commands(self, cmd: str) -> str:
""" """
Sendet einen Befehl an den Rover. Sendet einen Befehl an den Rover über die REST-API.
Args: Args:
cmd: Der zu sendende Befehl cmd: Der zu sendende Befehl
...@@ -36,14 +36,26 @@ class MissionControl: ...@@ -36,14 +36,26 @@ class MissionControl:
Returns: Returns:
Die erfolgreich ausgeführten Befehle Die erfolgreich ausgeführten Befehle
""" """
import requests
import json
try:
# Synchronisiere die Hindernisse zwischen Mars und Rover # Synchronisiere die Hindernisse zwischen Mars und Rover
# Der Rover sollte die Hindernisse nicht direkt kennen
# Stattdessen sollte er selbst stoppen, wenn ein Hindernis vorliegt
# Da wir aber keine direkte Verbindung zwischen Rover und Mars haben,
# müssen wir die Hindernisse hier synchronisieren
if hasattr(self.mars, 'plateau') and hasattr(self.mars.plateau, 'obstacles'): if hasattr(self.mars, 'plateau') and hasattr(self.mars.plateau, 'obstacles'):
self.rover.obstacles = self.mars.plateau.obstacles self.rover.obstacles = self.mars.plateau.obstacles
# Sende Befehl über REST-API
response = requests.post('http://localhost:5000/drive',
json={'Input': cmd},
headers={'Content-Type': 'application/json'})
if response.status_code == 200:
result = response.json()
return result['output']
else:
return f"Fehler: {response.status_code}, {response.text}"
except Exception as e:
# Fallback: Direkter Aufruf, wenn API nicht erreichbar
return self.rover.drive(cmd) return self.rover.drive(cmd)
def observe_plateau(self) -> list: def observe_plateau(self) -> list:
......
File moved
rest.txt 0 → 100644
openapi: 3.0.3
info:
title: Drive Endpoint API
version: 1.0.0
description: >
A simple API endpoint that receives a command string and may return:
- the full command string
- a substring of the command string
- an empty response
paths:
/drive:
post:
summary: Process a string input
description: Accepts a string and returns either the same string, a substring of it, or nothing.
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- input
properties:
input:
type: string
examples:
example1:
summary: Forward backward commands
value:
input: "FFFFBBB"
example2:
summary: Simple command string
value:
input: "FB"
example3:
summary: Alternating directions
value:
input: "RRRRLLLL"
example4:
summary: Mixed commands with invalid at the end
value:
input: "FBRLX"
example5:
summary: Unknown command at start
value:
input: "XFB"
responses:
'200':
description: Response may include the original string, a substring, or an empty string
content:
application/json:
schema:
type: object
properties:
output:
type: string
examples:
fullString:
summary: Full string returned
value:
output: "FFFFBBB"
subString:
summary: Substring returned
value:
output: "FBRL"
empty:
summary: Empty string returned
value:
output: ""
'400':
description: Bad request due to missing or invalid input
content:
application/json:
schema:
type: object
properties:
error:
type: string
example:
error: "Missing or invalid input"
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment