This repository contains a protocol bridge for controlling a drone using a joystick. The bridge allows communication between a client, which reads input from a joystick and sends control commands to the drone, and a server, which receives the commands and sends them to the flight controller.
To use this protocol bridge, you need the following:
- Python 3.x
 - Pygame library
 - websockets library
 - pymavlink library
 
- 
Clone this repository:
git clone https://github.com/letsmakecakes/protocol-bridge.git
 - 
Install the required libraries. Run the following command:
pip install pygame websockets pymavlink
 
- 
Open the
client.pyfile in a text editor. - 
Modify the following line to match the address and port of the server:
async with websockets.connect('ws://localhost:8765', ping_interval=None) as websocket:
 - 
Connect your joystick to the computer.
 - 
Run the client script using the following command:
python client.py
 
- 
Open the
server.pyfile in a text editor. - 
Modify the following line to match the connection string of your flight controller:
master = mavutil.mavlink_connection('<your-system-ip-address>:14550')
 - 
Run the server script using the following command:
python server.py
 
The client reads input from the joystick and sends control commands to the server using a WebSocket connection. The server receives the commands and sends them to the flight controller using the MAVLink protocol.
The control commands include the following parameters:
arm: Arm the flight controller (value:1to arm,0to disarm).disarm: Disarm the flight controller (value:1to disarm,0to keep armed).mode: Set the flight mode of the drone (value:1to set mode,0to keep the current mode).yaw: Yaw control value (-1.0 to 1.0).throttle: Throttle control value (-1.0 to 1.0).roll: Roll control value (-1.0 to 1.0).pitch: Pitch control value (-1.0 to 1.0).
The server receives the control commands and processes them accordingly:
- If 
armis set to1, the server arms the flight controller. - If 
disarmis set to1, the server disarms the flight controller. - If 
modeis set to1, the server sets the flight mode of the drone to the specified mode. 
The server then sends the control commands to the flight controller using the MAVLink protocol. The control values for yaw, throttle, roll, and pitch are scaled and sent as manual control commands.
This project is licensed under the MIT License.
Feel free to contribute to this project by submitting issues or pull requests.