Skip to content
robonhub

PYTHON DRONE CODING

Python drone coding: fly a real drone with Python

RobonHub drones are programmed in Python: with commands such as takeoff, move, yaw and land from the robonhubpy library, students code a real drone's take-off, route and landing, and read sensor data with functions like get_altitude and get_battery_voltage. The Python editor runs in the browser at app.robonhub.com; the same code runs first in the demo.robonhub.com simulator, then on the real drone. Students who start in Blockly move to text coding by seeing the Python their blocks generate.

Your first Python drone program

The program below is the square-flight example that ships in the app: the drone climbs to 1 metre, flies two seconds in each of four directions and lands. Commands run in order and each one finishes before the next starts, which keeps programs easy to follow.

Core Python commands

Programs are written against the robonhub object. The most used commands:

  • takeoff(altitude) — take off to a target height in metres
  • move(direction, duration) — fly "front", "back", "left" or "right" for a number of seconds
  • yaw(direction, degrees) — turn "cw" / "ccw" by a number of degrees
  • change_altitude(delta_cm) and set_altitude(altitude) — adjust height
  • hold(duration) — hover in place
  • land() and emergency_land() — landing and emergency landing
  • get_altitude(), get_yaw(), get_battery_voltage(), get_battery_remaining() — sensor and battery data

From Blockly to Python

Each Blockly block maps to one line of Python: the “take off” block generates robonhub.takeoff(), “go forward” generates robonhub.move("front", …) and “wait” generates time.sleep(). Students see the Python behind their blocks in the same project, so they move to text coding by recognising the logic rather than memorising syntax.

What students build with Python

Square, circle and figure-eight routes built with loops; conditional missions that decide from sensor data; programs that print and analyse telemetry every second. With the VISION kit, students move on to camera-based image processing and object tracking.

# 1 m yükseklikte kare uçuş: 4 yöne 2 sn'lik adımlar.
from robonhubpy.robonhub import Robonhub
import time

robonhub = Robonhub(wait_connection=False)

def run_robonhub_program():
    robonhub.wait_until_connected()
    robonhub.arm()
    time.sleep(1)
    robonhub.takeoff(1.0)        # metre
    robonhub.move("front", 2)    # yön, saniye
    robonhub.move("right", 2)
    robonhub.move("back",  2)
    robonhub.move("left",  2)
    robonhub.land()

if __name__ == "__main__":
    run_robonhub_program()
Square flight — the built-in example (square_flight.py). Run it without a drone at demo.robonhub.com.

Frequently asked

Yes. RobonHub CORE and VISION are programmed with the robonhubpy Python library: commands like takeoff, move, yaw and land for flight, and functions like get_altitude for sensor reads.

Yes. Students start with Blockly blocks, which turn into Python code, and write Python directly when they're ready.

Code is written in the browser at app.robonhub.com and runs in the simulator. Connecting to the real drone needs a small companion app on the computer.

Yes. demo.robonhub.com runs in the browser with a Python editor, simulator and sample missions — no hardware needed.

Related pages

THE NEXT PILOTS ARE IN YOUR CLASSROOM

Let's plan a demo flight: get hands-on with the kits, try the platform and talk curriculum together.

Request a demo

info@robonhub.com · +90 531 855 85 56