This repo allows you to control a Tello drone using your keyboard and perform object detection using a pre-trained model. The drone movements are controlled using the arrow keys and specific keys for takeoff, landing, and flips. The object detection is performed on the live video feed from the drone's camera.
- Python 3.x
getter
moduledjitellopy
librarypygame
librarycv2
(OpenCV) librarycvzone
library
-
Clone the repository to your local machine:
git clone https://github.com/your-username/TelloDrone-with-KeyBoard-and-Objectdetection.git
-
Install the required dependencies:
pip install getter djitellopy pygame opencv-python cvzone
-
Import the necessary modules and initialize the required components:
import getter as kg from djitellopy import tello from time import sleep kg.init() drone = tello.Tello() drone.connect()
-
Define the function to get keyboard input for drone control:
def getKeyboardInput(isFlying): # ... implementation ... return [lr, fb, ud, yw, isFlying]
-
Implement the drone control loop:
while True: inputs = getKeyboardInput(isFlying) isFlying = inputs[4] drone.send_rc_control(inputs[0], inputs[1], inputs[2], inputs[3]) sleep(0.01)
-
Implement object detection using the Tello drone's camera:
# ... import necessary modules ... thres = 0.50 nmsThres = 0.2 # ... load class names and pre-trained model ... while True: # ... get frame from drone's camera ... # ... perform object detection ... # ... display the detected objects ... # ... get keyboard input and control the drone ... # ... display the frame ...
Contributions are welcome! If you find any issues or have suggestions for improvements, please create a GitHub issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more information.
- The Tello SDK provided by DJI Ryze Robotics: https://github.com/damiafuentes/DJITelloPy
- Pre-trained object detection model: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_detection_zoo.md