Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Drone Simulation Controller

This project provides a Python-based controller for operating a drone in AirSim simulation environment, typically integrated with Unreal Engine 4 (UE4). The script allows real-time keyboard control of a virtual drone for testing and development purposes.

Features

  • Real-time keyboard control of drone movement
  • Intuitive control scheme:
    • W / S: Move forward/backward
    • A / D: Move left/right
    • / (Arrow keys): Ascend/descend
    • Q / E: Rotate left/right
    • ESC: Land and exit
    • C: Capture and save current camera view
    • Y: Send current camera view to YOLO object detection model
  • Live camera feed display during flight
  • Automatic image saving with sequential numbering
  • YOLO object detection integration (requires separate YOLO server)
  • Smooth drone movement with configurable speed settings
  • Safe takeoff and landing procedures

Prerequisites

Before running this project, ensure you have:

  1. Unreal Engine 4 installed
  2. AirSim plugin installed and configured with UE4
  3. Python 3.10 installed (virtual environment recommended)
  4. Required Python packages:
    • airsim
    • keyboard
    • opencv-python
    • numpy
    • requests

Installation

  1. Clone this repository:

    git clone <repository-url>
    cd drone
  2. Create a virtual environment:

    python -m venv venv
  3. Activate the virtual environment:

    • On Windows:
      venv\Scripts\activate
    • On macOS/Linux:
      source venv/bin/activate
  4. Install required packages:

    pip install airsim keyboard opencv-python numpy requests

Usage

  1. Start your AirSim simulation environment (UE4 project with AirSim plugin)

  2. (Optional) Start your YOLO object detection server on a separate port (local or cloud)

  3. Update the YOLO_SERVER_URL in drone.py to point to your YOLO server if different from default

  4. Run the drone controller:

    python drone.py
  5. The drone will automatically takeoff and await your commands

  6. Use the keyboard controls listed above to maneuver the drone

  7. Press C to capture and save the current camera view at any time

  8. Press Y to send the current camera view to the YOLO model for object detection

  9. Press Q to close the live camera feed window

  10. Press ESC to land the drone and exit the program

Images will be saved in the captured_images directory with sequential numbering.

Configuration

You can adjust the drone's behavior by modifying these parameters in drone.py:

  • DRONE_SPEED: Movement speed in meters per second (default: 5)
  • ROTATION_SPEED: Rotation speed in degrees per second (default: 45)
  • IMAGE_DIR: Directory where captured images are saved (default: "captured_images")
  • YOLO_SERVER_URL: URL of the YOLO object detection server (default: "http://localhost:5000/yolo")

Project Structure

.
├── drone.py          # Main drone control script
├── README.md         # This file
├── .gitignore        # Git ignore rules
├── venv/             # Python virtual environment (ignored by Git)
└── captured_images/  # Directory for saved drone camera images (created automatically)

Safety Notes

  • The drone automatically lands when the program exits
  • The virtual environment is excluded from Git tracking
  • Ensure your AirSim simulation is running before executing the script

Contributing

Feel free to fork this project and submit pull requests with improvements or bug fixes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages