{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "49a243e8",
   "metadata": {},
   "source": [
    "# Tello Drone Programming - Setup\n",
    "\n",
    "Dieses Notebook hilft dir, die Programmierung des DJI Tello Drohne einzurichten.\n",
    "\n",
    "## Schritt 1: Pakete installieren\n",
    "\n",
    "Führe die folgende Zelle aus, um die benötigten Python-Pakete zu installieren:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4804023e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Installiere djitellopy und Abhängigkeiten\n",
    "!pip install djitellopy opencv-python pillow"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a480f600",
   "metadata": {},
   "source": [
    "## Schritt 2: Import und Verbindungstest\n",
    "\n",
    "Nach der Installation, importiere die Bibliothek:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7bcda678",
   "metadata": {},
   "outputs": [],
   "source": [
    "from djitellopy import Tello\n",
    "import time\n",
    "\n",
    "print(\"✅ djitellopy erfolgreich importiert!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "165d7797",
   "metadata": {},
   "source": [
    "## Schritt 3: Drohne verbinden (nur ausführen wenn Drohne eingeschaltet ist!)\n",
    "\n",
    "**⚠️ WICHTIG:** Stelle sicher, dass:\n",
    "1. Die Tello Drohne eingeschaltet ist\n",
    "2. Dein Computer mit dem WiFi der Drohne verbunden ist (TELLO-XXXXXX)\n",
    "3. Du genug Platz hast (mindestens 2x2 Meter freier Raum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6acedf15",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Drohne initialisieren\n",
    "drone = Tello()\n",
    "\n",
    "# Verbindung aufbauen\n",
    "drone.connect()\n",
    "\n",
    "# Batterie-Status prüfen\n",
    "battery = drone.get_battery()\n",
    "print(f\"🔋 Batterie: {battery}%\")\n",
    "\n",
    "if battery < 20:\n",
    "    print(\"⚠️ Warnung: Batterie niedrig! Bitte aufladen.\")\n",
    "else:\n",
    "    print(\"✅ Drohne bereit!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4c90848",
   "metadata": {},
   "source": [
    "## Schritt 4: Einfacher Testflug\n",
    "\n",
    "**⚠️ SICHERHEIT ZUERST:**\n",
    "- Freier Raum um dich herum\n",
    "- Keine Personen in der Nähe\n",
    "- Drohne auf ebener Fläche\n",
    "- Bereit, die Drohne zu fangen falls nötig"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ce22798",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Starten und einfache Bewegung\n",
    "drone.takeoff()          # Abheben\n",
    "time.sleep(3)            # 3 Sekunden schweben\n",
    "\n",
    "drone.move_up(30)        # 30cm nach oben\n",
    "time.sleep(2)\n",
    "\n",
    "drone.rotate_clockwise(90)  # 90° drehen\n",
    "time.sleep(2)\n",
    "\n",
    "drone.land()             # Landen\n",
    "print(\"✅ Testflug abgeschlossen!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b616df2",
   "metadata": {},
   "source": [
    "## Nützliche Befehle\n",
    "\n",
    "Hier sind einige grundlegende Befehle:\n",
    "\n",
    "```python\n",
    "# Bewegungen\n",
    "drone.takeoff()                    # Abheben\n",
    "drone.land()                       # Landen\n",
    "drone.move_up(x)                   # x cm nach oben\n",
    "drone.move_down(x)                 # x cm nach unten\n",
    "drone.move_forward(x)              # x cm vorwärts\n",
    "drone.move_back(x)                 # x cm rückwärts\n",
    "drone.move_left(x)                 # x cm links\n",
    "drone.move_right(x)                # x cm rechts\n",
    "drone.rotate_clockwise(x)          # x° im Uhrzeigersinn\n",
    "drone.rotate_counter_clockwise(x)  # x° gegen Uhrzeigersinn\n",
    "\n",
    "# Informationen\n",
    "drone.get_battery()                # Batterie-Status\n",
    "drone.get_height()                 # Aktuelle Höhe\n",
    "drone.get_speed()                  # Geschwindigkeit\n",
    "\n",
    "# Notfall\n",
    "drone.emergency()                  # NOTLANDUNG (sofort stoppen!)\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "441ebe1d",
   "metadata": {},
   "source": [
    "## Weiterführende Ressourcen\n",
    "\n",
    "- [DJITelloPy Dokumentation](https://djitellopy.readthedocs.io/)\n",
    "- [Beispiele auf GitHub](https://github.com/damiafuentes/DJITelloPy/tree/master/examples)\n",
    "\n",
    "---\n",
    "\n",
    "**Viel Spaß beim Programmieren! 🚁**"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
