Skip to content

Commit 212e881

Browse files
committed
Added some additional comments. Pylint compliance
1 parent c9ac5ba commit 212e881

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

examples/manual_control.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#! /usr/bin/env python3
22

3-
# This example shows how to use the manual controls plugin. Manual inputs are taken from a test set, but the use of a joystick can be implemented using third party extensions.
3+
"""
4+
This example shows how to use the manual controls plugin.
45
5-
import asyncio, random
6+
Note: Manual inputs are taken from a test set in this example to decrease complexity. Manual inputs
7+
can be received from devices such as a joystick using third-party python extensions
8+
9+
Note: Taking off the drone is not necessary before enabling manual inputs. It is acceptable to send
10+
positive throttle input to leave the ground. Takeoff is used in this example to decrease complexity
11+
"""
12+
13+
import asyncio
14+
import random
615
from mavsdk import System
716

817
# Test set of manual inputs. Format: [roll, pitch, throttle, yaw]
@@ -20,6 +29,7 @@
2029

2130

2231
async def manual_controls():
32+
"""Main function to connect to the drone and input manual controls"""
2333
# Connect to the Simulation
2434
drone = System()
2535
await drone.connect(system_address="udp://:14540")
@@ -45,7 +55,7 @@ async def manual_controls():
4555
print("-- Arming")
4656
await drone.action.arm()
4757

48-
# Takeoff the vehicle (Not a necessary command, but makes it easier to see manual controls working)
58+
# Takeoff the vehicle
4959
print("-- Taking off")
5060
await drone.action.takeoff()
5161
await asyncio.sleep(5)
@@ -60,15 +70,16 @@ async def manual_controls():
6070
await drone.manual_control.start_position_control()
6171

6272
while True:
63-
# grabs a random input from the test list. WARNING - your simulation vehicle may crash if its unlucky enough
73+
# grabs a random input from the test list
74+
# WARNING - your simulation vehicle may crash if its unlucky enough
6475
input_index = random.randint(0, len(manual_inputs) - 1)
6576
input_list = manual_inputs[input_index]
6677

6778
# get current state of roll axis (between -1 and 1)
6879
roll = float(input_list[0])
6980
# get current state of pitch axis (between -1 and 1)
7081
pitch = float(input_list[1])
71-
# get current state of throttle axis (between -1 and 1, but between 0 and 1 is expected right now)
82+
# get current state of throttle axis (between -1 and 1, but between 0 and 1 is expected)
7283
throttle = float(input_list[2])
7384
# get current state of yaw axis (between -1 and 1)
7485
yaw = float(input_list[3])
@@ -81,4 +92,4 @@ async def manual_controls():
8192
if __name__ == "__main__":
8293

8394
loop = asyncio.get_event_loop()
84-
loop.run_until_complete(manual_controls())
95+
loop.run_until_complete(manual_controls())

0 commit comments

Comments
 (0)