In this project, I plan to learn drone technology and improve my autonomous programming skills.
I will work with the Pixhawk framework/libraries, as it is a standard in this field. I bought all my hardware from AliExpress because it was cheaper. They are likely clones, but I didn't research them thoroughly beforehand. My first step is to quickly test all the hardware to ensure everything works properly before moving on to path planning, IMU calibration, STM microcontrollers, and software development.
1. Software Setup
First, download and install Mission Planner from the official site:
2. Wiring & Assembly
All hardware connections should follow the PX4 wiring reference:

- Power Distribution (PDB): Normally, a separate PDB is used, but if your drone frame has an integrated Power Distribution Board, you don't need a separate one. You can solder your main battery leads and ESC power connections directly to the frame.

- Safety Switch: This emergency button is used when the drone is ready for flight. In software, you can configure safety clauses (e.g., holding the button for two seconds to arm/disarm). Connect it to the Safety port on the Pixhawk.
.jpeg)
- RC Receiver / Binding: This small board connects your Remote Controller (RC). During initial binding/pairing, place a jumper on the bind pins. Once paired, connect the signal wire (yellow) to the RC input port on the flight controller so it can receive commands.
- ESC PWM Signal Splitter / Output: Connect your ESC signal lines to the flight controller outputs (ensure the white signal wire is oriented correctly). You can check motor rotation directions in Mission Planner or QGroundControl. If a motor spins in the wrong direction, swap any two of the three bullet connector wires running between the ESC and the motor.
.jpeg)
- Sensor Expansion Board: I also used an I2C/signal splitter board to connect additional sensors, such as the ToF (Time-of-Flight) Laser Ranging Sensor.
.jpeg)
ESC Beep Codes: When powering up your ESCs, pay attention to the startup tones. If configured correctly, you will hear normal initialization beeps. If there is an issue or wrong connection, you will hear error buzzer signals or no sound at all.
For step-by-step visual guidance, you can check out these video tutorials:
3. Gazebo Simulation & MAVSDK Autonomous Script
You can define the drone model in Gazebo (~/PX4-Autopilot/Tools/simulation/gz/models/x500/model.sdf) and then control it using Python and MAVSDK.
Below is an updated Python script using takeoff_test.py that connects via MAVSDK, arms the drone, takes off, flies forward for a short distance using velocity commands (Offboard mode), and then safely lands:
python3 takeoff_test.py
import asyncio
from mavsdk import System
from mavsdk.offboard import VelocityNedYaw, OffboardError
async def run():
drone = System()
# Using the correct connection address for SITL
await drone.connect(system_address="udpin://127.0.0.1:14540")
print("Waiting for drone to connect...")
async for state in drone.core.connection_state():
if state.is_connected:
print("[SUCCESS] Connected to Pixhawk simulator!")
break
# Short pause for the system to settle
await asyncio.sleep(2)
# Arm the motors
print("-- Arming motors...")
try:
await drone.action.arm()
print("[SUCCESS] Motors are spinning!")
except Exception as e:
print(f"[ERROR] Arming failed: {e}")
return
# Autonomous Takeoff
print("-- Taking off...")
await drone.action.takeoff()
# Wait for the drone to reach altitude and stabilize
print("Waiting for drone to hover (8 seconds)...")
await asyncio.sleep(8)
# Mission completed, safe landing
print("-- Landing...")
await drone.action.land()
print("Mission completed.")
if __name__ == "__main__":
asyncio.run(run())

.jpeg)
