This repository contains Python scripts for controlling and interacting with a drone using the MAVSDK library. The scripts demonstrate various functionalities such as connecting to the drone, executing offboard control, reading telemetry data, taking off, and running waypoint missions.
- Python 3.7+
- MAVSDK-Python Library
- Compatible Drone Hardware with MAVLink Support
- Connection Interface (e.g., Serial)
- Clone the repository:
git clone https://github.com/slsecrets357/drone.git
cd drone
- Install dependencies:
pip install mavsdk
- Connect the drone via UART.
To establish communication between the PX4-based flight controller and a Jetson device, follow these steps:
-
PX4 Setup:
- Modify MAVLink instance
MAV_1_CONFIG
in QGroundControl to useTELEM 3
for MAVLink communication. - Set the baud rate and mode settings appropriately (e.g., 57600 baud for telemetry).
- Modify MAVLink instance
-
Hardware Wiring:
- Connect the
TELEM 3
port of the PX4 to the Jetson device. - Wiring Configuration:
- TX on PX4 -> RX on Jetson.
- RX on PX4 -> TX on Jetson.
- GND on PX4 -> GND on Jetson.
- Connect the
-
Verification:
- Ensure the connections are secure and verify communication using a serial terminal before running the scripts.
Purpose:
- Connects to the drone via a specified serial port.
- Verifies and confirms the connection status.
Usage:
python connect_drone.py
Purpose:
- Demonstrates offboard control by setting target positions in a local coordinate frame.
- Moves the drone through a sequence of waypoints.
Usage:
python offboard_example.py
Purpose:
- Fetches and displays telemetry data such as GPS position, battery status, altitude, and attitude.
Usage:
python read_sensors.py
Purpose:
- Arms the drone.
- Executes a takeoff sequence.
- Lands the drone after a delay.
Usage:
python takeoff.py
Purpose:
- Defines a series of waypoints.
- Uploads a mission to the drone.
- Executes the mission and monitors progress.
Usage:
python waypoint_mission.py
Make sure your drone is connected and powered on before running any of the scripts. Replace the serial port or system address in the scripts if needed. Each script provides output logs for real-time feedback during execution.