You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This script enables real-time control of a drone's velocity and yaw using keyboard inputs.
6
-
It sends velocity setpoints in the body frame and commands for yaw adjustments, allowing
7
-
for dynamic control through familiar keyboard keys.
8
-
9
-
Key Bindings:
10
-
- 'W': Move forward
11
-
- 'S': Move backward
12
-
- 'A': Move left
13
-
- 'D': Move right
14
-
- Up Arrow: Increase altitude
15
-
- Down Arrow: Decrease altitude
16
-
- Left Arrow: Yaw left
17
-
- Right Arrow: Yaw right
18
-
- 'Q': Quit the application
19
-
20
-
The drone must be configured to receive and process these commands, typically in an offboard control mode.
2
+
MAVSDK Offboard Control - Local Velocity Sender
3
+
=================================================
4
+
5
+
This script is designed to control a drone's velocity and yaw through keyboard inputs, interfacing via MAVSDK over UDP. It offers an interactive GUI built with Pygame for real-time control and feedback.
6
+
7
+
Overview:
8
+
---------
9
+
- Sends control packets to command drone movements in local body coordinates with optional yaw adjustments.
10
+
- Utilizes keyboard inputs for dynamic control (W, A, S, D, Arrow keys).
11
+
- Real-time feedback on current command and connection status via a Pygame-based GUI.
12
+
13
+
Setup Requirements:
14
+
-------------------
15
+
- A MAVSDK-compatible drone or a SITL setup running and accessible on the network.
16
+
- The receiver node (`receiver.py`) must be operational to handle and execute the commands sent from this script.
17
+
- Ensure that the receiver and this sender script are configured to communicate over the specified IP and port.
18
+
19
+
Key Functionalities:
20
+
--------------------
21
+
- **Velocity Control**: Use W, A, S, D for movement along the body frame's axes.
22
+
- **Altitude Adjustment**: Use the Up and Down arrow keys for vertical movement adjustments.
23
+
- **Yaw Control**: Use Left and Right arrow keys to adjust yaw.
24
+
- **Enable/Disable Commands**: Toggle command sending with 'E' to enable and 'C' to cancel.
25
+
- **Emergency Stop**: 'H' to hold (stop all movements) and 'Q' to quit the application safely.
26
+
27
+
28
+
Instructions for Use:
29
+
---------------------
30
+
1. Ensure your MAVSDK setup (either SITL or a real drone) is ready and the `receiver.py` script is running.
31
+
2. Adjust parameters such as IP, port, and control rates directly in the code if necessary.
32
+
3. Run this script in a Python environment where Pygame is installed.
33
+
4. Use the keyboard controls as outlined to command the drone.
34
+
35
+
Safety Notice:
36
+
--------------
37
+
- When using with a real drone, operate in a safe, open environment to avoid accidents.
38
+
- Always be ready to take manual control or stop the drone if necessary.
21
39
22
40
Author:
23
41
- Alireza Ghaderi
24
42
- GitHub: alireza787b
25
43
- Date: April 2024
26
-
w
27
-
Usage:
28
-
Run the script in a compatible Python environment where the drone control system can
29
-
receive UDP packets. Use the keys to control the drone's movement and orientation.
44
+
45
+
Dependencies:
46
+
- Pygame for GUI operations.
47
+
- Python's `socket` library for UDP communication.
48
+
- `control_packet.py` for formatting control commands.
print(f"Sending POSITION_LOCAL_NED setpoint: North {control_packet.position[0]}, East {control_packet.position[1]}, Down {control_packet.position[2]}, Yaw {yaw}")
0 commit comments