🐍 Python / C++Python / C++

Python for Robotics: The 5 Libraries Every Student Should KnowPython für Robotik: Die 5 Bibliotheken, die jeder Schüler kennen sollte

Python has become the dominant language in robotics and AI — not because it's the fastest, but because its ecosystem of libraries lets you achieve extraordinary things with very little code. At MINT Yantra Labs, students use Python from their very first AI project. Here are the five libraries we use most, and why they matter. Python ist die dominierende Sprache in Robotik und KI — nicht weil sie die schnellste ist, sondern weil ihr Bibliotheks-Ökosystem außergewöhnliche Dinge mit sehr wenig Code ermöglicht. Bei MINT Yantra Labs verwenden Schüler Python vom ersten KI-Projekt an. Hier sind die fünf Bibliotheken, die wir am häufigsten einsetzen.

📋 Setup FirstErst einrichten

All five libraries below can be installed with pip. On a Raspberry Pi running Raspberry Pi OS, use: pip3 install <library-name>. We recommend working in a virtual environment: python3 -m venv yantra-env && source yantra-env/bin/activate Alle fünf Bibliotheken können mit pip installiert werden. Auf einem Raspberry Pi: pip3 install <bibliothek>. Wir empfehlen eine virtuelle Umgebung: python3 -m venv yantra-env && source yantra-env/bin/activate

1. RPi.GPIO — Talking to HardwareMit Hardware kommunizieren

RPi.GPIO is the foundation. It lets Python talk directly to the Raspberry Pi's GPIO (General Purpose Input/Output) pins — the physical connectors that hook up to sensors, motors, LEDs, and servos. Think of it as Python's handshake with the physical world. RPi.GPIO ist die Grundlage. Es lässt Python direkt mit den GPIO-Pins des Raspberry Pi kommunizieren — den physischen Anschlüssen für Sensoren, Motoren, LEDs und Servos. Es ist Pythons Handschlag mit der physischen Welt.

Python · RPi.GPIO
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT) # Pin 18 → servo signal pwm = GPIO.PWM(18, 50) # 50 Hz — standard servo frequency pwm.start(7.5) # 7.5% duty cycle = 90° (centre) time.sleep(1) pwm.ChangeDutyCycle(5) # 5% = ~0° (full left) time.sleep(1) pwm.ChangeDutyCycle(10) # 10% = ~180° (full right)

2. OpenCV — Computer VisionComputer Vision

OpenCV (Open Source Computer Vision Library) is the world's most widely used computer vision library. For our AI Mirror and AI Waste Sorter projects, OpenCV handles camera capture, frame processing, colour detection, and feeding images into ML models. It is extraordinarily powerful. OpenCV (Open Source Computer Vision Library) ist die meistgenutzte Computer-Vision-Bibliothek der Welt. Für unsere KI-Spiegel- und KI-Abfallsortierer-Projekte übernimmt OpenCV Kameraaufnahme, Bildverarbeitung, Farberkennung und die Bildübergabe an ML-Modelle.

Python · OpenCV
import cv2 import numpy as np cap = cv2.VideoCapture(0) # Open camera 0 while True: ret, frame = cap.read() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) # Detect green objects (e.g. recyclable bottles) lower_green = np.array([40, 50, 50]) upper_green = np.array([80, 255, 255]) mask = cv2.inRange(hsv, lower_green, upper_green) cv2.imshow('Waste Detector', mask)

3. TensorFlow Lite — On-Device AIKI auf dem Gerät

TensorFlow Lite is the lightweight version of Google's TensorFlow, designed to run on microcomputers like the Raspberry Pi. We use it to deploy trained machine learning models directly on the robot — no internet connection required, no cloud API call. The AI runs locally, in real time. TensorFlow Lite ist die leichtgewichtige Version von Googles TensorFlow, entwickelt für Mikrocomputer wie den Raspberry Pi. Wir setzen trainierte ML-Modelle direkt auf dem Roboter ein — keine Internetverbindung, kein Cloud-API-Aufruf. Die KI läuft lokal, in Echtzeit.

4. NumPy — The Maths EngineDie Mathe-Engine

NumPy powers almost everything else. Arrays, matrices, trigonometric functions for inverse kinematics calculations, FFT for sensor signal processing — NumPy does it all, fast. When you call cv2.inRange() in OpenCV, it's using NumPy arrays under the hood. NumPy treibt fast alles andere an. Arrays, Matrizen, trigonometrische Funktionen für inverse Kinematik, FFT für Sensorsignalverarbeitung — NumPy erledigt alles, schnell. Wenn Sie cv2.inRange() in OpenCV aufrufen, werden darunter NumPy-Arrays verwendet.

Python · NumPy — Servo angle from inverse kinematicsServowinkel aus inverser Kinematik
import numpy as np # 2-link arm: find elbow angle for target (x, y) def ik_2link(x, y, L1=15, L2=12): cos_theta2 = (x**2 + y**2 - L1**2 - L2**2) / (2*L1*L2) theta2 = np.arccos(np.clip(cos_theta2, -1, 1)) theta1 = np.arctan2(y, x) - np.arctan2(L2*np.sin(theta2), L1 + L2*np.cos(theta2)) return np.degrees(theta1), np.degrees(theta2)

5. Pygame — Controller Input & DisplaySteuerung & Anzeige

Pygame is best known as a game development library, but for robotics it's invaluable for reading joystick/gamepad input and building real-time dashboards. In our RC Car project, a Pygame window on a laptop reads arrow keys and sends commands to the ESP32 over Wi-Fi. Simple, fast, and students can customise it immediately. Pygame ist als Spielentwicklungsbibliothek bekannt, aber für Robotik ist es unschätzbar für Joystick-/Gamepad-Eingaben und Echtzeit-Dashboards. In unserem RC-Auto-Projekt liest ein Pygame-Fenster auf einem Laptop Pfeiltasten und sendet Befehle per WLAN an den ESP32.

🚀 MINT Yantra Learning PathMINT Yantra Lernpfad

Week 1–2: RPi.GPIO — blink an LED, read a button, spin a motor
Week 3–4: NumPy basics — arrays, maths operations, data structures
Week 5–6: OpenCV — read camera, detect colours, track objects
Week 7–8: TF Lite — load a pre-trained model, run inference on camera frames
Week 9–10: Pygame — build a controller UI, integrate everything
Woche 1–2: RPi.GPIO — LED blinken, Button lesen, Motor drehen
Woche 3–4: NumPy-Grundlagen — Arrays, Mathoperationen, Datenstrukturen
Woche 5–6: OpenCV — Kamera lesen, Farben erkennen, Objekte verfolgen
Woche 7–8: TF Lite — vortrainiertes Modell laden, Inferenz auf Kameraframes
Woche 9–10: Pygame — Controller-UI bauen, alles integrieren

Want to build this yourself?Selbst bauen?

Join a MINT Yantra Labs session and turn theory into a working project.Nehmen Sie an einer Session teil und machen Sie Theorie zum Projekt.

🔬 See Programs🔬 Programme✉️ Get in Touch✉️ Kontakt