This project provides a web-based interface to control a Tello drone, view its video stream, and manage recordings.
- Real-time Video Streaming: View the drone's camera feed directly in the browser using JSMpeg.
- Drone Control: Send commands to the drone (takeoff, land, movement, etc.) via a backend server.
- State Display: Monitor key drone metrics like battery level, flight time, and connection status using Server-Sent Events (SSE).
- Video Recording: Record the video stream (functionality might be partially implemented based on the provided code snippets).
- Redux State Management: Centralized state management for drone status and UI interactions.
- Frontend:
- React
- Redux Toolkit (for state management)
- Tailwind CSS (for styling)
- Vite (build tool)
- JSMpeg Player (for video streaming)
- Backend (Node.js -
server.js):- Express.js (web framework)
ws(WebSocket library for video stream proxying)- Node.js
dgram(for UDP communication with the drone) - Server-Sent Events (SSE) for real-time state updates
.
├── public/
│ └── vite.svg
├── server.js # Backend server (Node.js)
├── src/
│ ├── App.jsx # Main application component
│ ├── assets/ # Static assets (e.g., images)
│ ├── components/ # React components
│ │ ├── control/ # Drone control components (if any)
│ │ ├── DroneStateDisplay.jsx # Displays drone status
│ │ ├── JSMpegVideoPlayer.jsx # Handles video stream display
│ │ └── VideoContainer.jsx # Layout for video player
│ ├── hooks/ # Custom React hooks
│ │ └── useDroneStateEventSource.js # Hook for SSE connection
│ ├── store/ # Redux store configuration
│ │ ├── slices/
│ │ │ └── droneSlice.js # Redux slice for drone state
│ │ └── store.js # Redux store setup
│ ├── index.css # Main CSS file (imports Tailwind)
│ ├── jsmpeg-player.d.ts # TypeScript definitions for JSMpeg
│ └── main.jsx # Application entry point
├── .gitignore
├── eslint.config.js # ESLint configuration
├── index.html # Main HTML file
├── jsconfig.json # JS configuration for IntelliSense
├── package.json # Project dependencies and scripts
├── README.md # This file
└── vite.config.js # Vite configuration
-
Clone the repository:
git clone <repository-url> cd drone_web
-
Install dependencies:
npm install
-
Start the backend server: This server handles communication with the drone and streams video/state.
npm run server # or node server.js -
Start the frontend development server: In a separate terminal:
npm run dev
This will open the web interface, usually at
http://localhost:5173(check the terminal output for the exact URL). -
Connect to the Tello Drone's Wi-Fi network.
-
Interact with the drone using the web interface.
- Backend (
server.js):- Connects to the Tello drone via UDP for sending commands and receiving state.
- Receives the video stream from the drone.
- Uses
ws(WebSocket) to proxy the video stream to the frontend via JSMpeg format. - Uses Server-Sent Events (SSE) on
/drone-state-streamto push real-time drone state (battery, time, etc.) to the frontend.
- Frontend (
src/):- Uses React for the UI components.
- Uses Redux Toolkit (
droneSlice.js) to manage the application state (connection status, stream status, drone metrics). - The
useDroneStateEventSourcehook connects to the backend's SSE endpoint to receive and update the drone state in the Redux store. JSMpegVideoPlayercomponent connects to the WebSocket video stream provided by the backend and renders it.DroneStateDisplaycomponent subscribes to the Redux store and displays the latest drone state.- Control components (likely intended for
src/components/control/) would send HTTP requests to the backend API endpoints (defined inserver.js) to issue commands to the drone.
- Ensure the Tello drone is powered on and you are connected to its Wi-Fi network before starting the servers.
- The backend server listens on port 3000 by default for API requests and SSE, and port 9999 for the WebSocket video stream.
- The frontend development server typically runs on port 5173 (Vite default).