From 5a05cc352ef453cf700d1110ee599232c8bae6d7 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 10 Sep 2025 10:50:33 +1200 Subject: [PATCH 01/15] examples: async fixes --- .../offboard_from_csv/offboard_from_csv.py | 35 +++++++++---------- examples/rtk_base_ublox.py | 5 +-- examples/telemetry.py | 5 +-- examples/telemetry_is_armed_is_in_air.py | 5 +-- examples/upload_params.py | 7 ++-- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/examples/offboard_from_csv/offboard_from_csv.py b/examples/offboard_from_csv/offboard_from_csv.py index 6510f3d1..7cf28cc7 100644 --- a/examples/offboard_from_csv/offboard_from_csv.py +++ b/examples/offboard_from_csv/offboard_from_csv.py @@ -78,6 +78,8 @@ import asyncio import csv +import io +import anyio from mavsdk import System from mavsdk.offboard import PositionNedYaw, VelocityNedYaw from mavsdk.offboard import AccelerationNed, OffboardError @@ -146,24 +148,21 @@ async def run(): waypoints = [] # Read data from the CSV file - with open("active.csv", newline="") as csvfile: - reader = csv.DictReader(csvfile) - for row in reader: - waypoints.append( - ( - float(row["t"]), - float(row["px"]), - float(row["py"]), - float(row["pz"]), - float(row["vx"]), - float(row["vy"]), - float(row["vz"]), - float(row["ax"]), - float(row["ay"]), - float(row["az"]), - int(row["mode"]), - ) - ) + async with await anyio.open_file("active.csv", "r", newline="") as csvfile: + content = await csvfile.read() + reader = csv.DictReader(io.StringIO(content)) + for row in reader: + waypoints.append((float(row["t"]), + float(row["px"]), + float(row["py"]), + float(row["pz"]), + float(row["vx"]), + float(row["vy"]), + float(row["vz"]), + float(row["ax"]), + float(row["ay"]), + float(row["az"]), + int(row["mode"]))) print("-- Performing trajectory") total_duration = waypoints[-1][0] diff --git a/examples/rtk_base_ublox.py b/examples/rtk_base_ublox.py index a2069238..d5f9629b 100755 --- a/examples/rtk_base_ublox.py +++ b/examples/rtk_base_ublox.py @@ -100,8 +100,9 @@ async def run(): asyncio.ensure_future(print_gps_info(drone)) asyncio.ensure_future(send_rtcm(drone)) - while True: - await asyncio.sleep(1) + # Keep the program running indefinitely + exit_event = asyncio.Event() + await exit_event.wait() async def print_gps_info(drone): diff --git a/examples/telemetry.py b/examples/telemetry.py index 0e271e08..a0008143 100755 --- a/examples/telemetry.py +++ b/examples/telemetry.py @@ -20,8 +20,9 @@ async def run(): asyncio.ensure_future(print_in_air(drone)) asyncio.ensure_future(print_position(drone)) - while True: - await asyncio.sleep(1) + # Keep the program running indefinitely + exit_event = asyncio.Event() + await exit_event.wait() async def print_battery(drone): diff --git a/examples/telemetry_is_armed_is_in_air.py b/examples/telemetry_is_armed_is_in_air.py index deccf67c..8a4efa2e 100755 --- a/examples/telemetry_is_armed_is_in_air.py +++ b/examples/telemetry_is_armed_is_in_air.py @@ -11,8 +11,9 @@ async def run(): asyncio.ensure_future(print_is_armed(drone)) asyncio.ensure_future(print_is_in_air(drone)) - while True: - await asyncio.sleep(1) + # Keep the program running indefinitely + exit_event = asyncio.Event() + await exit_event.wait() async def print_is_armed(drone): diff --git a/examples/upload_params.py b/examples/upload_params.py index eab79708..0c496c3a 100755 --- a/examples/upload_params.py +++ b/examples/upload_params.py @@ -2,6 +2,7 @@ import asyncio import argparse +import anyio from mavsdk import System from tqdm import tqdm @@ -39,9 +40,11 @@ async def set_params(args): else: break - with open(args.param_file, "r") as param_file: + async with await anyio.open_file(args.param_file, "r") as param_file: print("Uploading Parameters... Please do not arm the vehicle!") - for line in tqdm(param_file, unit="lines"): + contents = await param_file.read() + lines = contents.splitlines() + for line in tqdm(lines, unit='lines'): if line.startswith("#"): continue From 6dc989f6811e58167ec7aac0b7c9aa9ac3cfbae7 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 4 Sep 2025 10:47:16 +1200 Subject: [PATCH 02/15] examples: fix RUF006 --- examples/camera_params.py | 7 ++++--- examples/offboard_position_velocity_ned.py | 2 +- examples/rtk_base_ublox.py | 5 +++-- examples/shell.py | 10 +++++----- examples/telemetry.py | 9 +++++---- examples/telemetry_is_armed_is_in_air.py | 5 +++-- examples/transponder.py | 2 +- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/examples/camera_params.py b/examples/camera_params.py index 50b6ed88..bcf2cc1f 100755 --- a/examples/camera_params.py +++ b/examples/camera_params.py @@ -24,9 +24,10 @@ async def run(): drone = System() await drone.connect(system_address="udpin://0.0.0.0:14540") - asyncio.ensure_future(observe_current_settings(drone)) - asyncio.ensure_future(observe_camera_mode(drone)) - asyncio.ensure_future(observe_possible_setting_options(drone)) + tasks = [] + tasks.append(asyncio.create_task(observe_current_settings(drone))) + tasks.append(asyncio.create_task(observe_camera_mode(drone))) + tasks.append(asyncio.create_task(observe_possible_setting_options(drone))) while True: entered_input = await ainput(usage_str) diff --git a/examples/offboard_position_velocity_ned.py b/examples/offboard_position_velocity_ned.py index f9a7ce8b..9e1899dd 100755 --- a/examples/offboard_position_velocity_ned.py +++ b/examples/offboard_position_velocity_ned.py @@ -44,7 +44,7 @@ async def print_z_velocity(drone): async for odom in drone.telemetry.position_velocity_ned(): print(f"{odom.velocity.north_m_s} {odom.velocity.down_m_s}") - asyncio.ensure_future(print_z_velocity(drone)) + tasks = {asyncio.create_task(print_z_velocity(drone))} print("-- Go 0m North, 0m East, -10m Down within local coordinate system") await drone.offboard.set_position_velocity_ned( diff --git a/examples/rtk_base_ublox.py b/examples/rtk_base_ublox.py index d5f9629b..35efe720 100755 --- a/examples/rtk_base_ublox.py +++ b/examples/rtk_base_ublox.py @@ -97,8 +97,9 @@ async def run(): await drone.connect() # Start the tasks - asyncio.ensure_future(print_gps_info(drone)) - asyncio.ensure_future(send_rtcm(drone)) + tasks = [] + tasks.append(asyncio.create_task(print_gps_info(drone))) + tasks.append(asyncio.create_task(send_rtcm(drone))) # Keep the program running indefinitely exit_event = asyncio.Event() diff --git a/examples/shell.py b/examples/shell.py index 15673bb0..52d450e5 100755 --- a/examples/shell.py +++ b/examples/shell.py @@ -5,12 +5,14 @@ from mavsdk import System +send_tasks = set() + async def run(): drone = System() await drone.connect(system_address="udpin://0.0.0.0:14540") - asyncio.ensure_future(observe_shell(drone)) + tasks = {asyncio.create_task(observe_shell(drone))} print("Waiting for drone to connect...") async for state in drone.core.connection_state(): @@ -28,7 +30,7 @@ async def observe_shell(drone): def got_stdin_data(drone): - asyncio.ensure_future(send(drone, sys.stdin.readline())) + send_tasks.add(asyncio.create_task(send(drone, sys.stdin.readline()))) async def send(drone, command): @@ -36,9 +38,7 @@ async def send(drone, command): if __name__ == "__main__": - asyncio.ensure_future(run()) - try: - asyncio.get_event_loop().run_forever() + asyncio.run(run()) except KeyboardInterrupt: pass diff --git a/examples/telemetry.py b/examples/telemetry.py index a0008143..763bd5ee 100755 --- a/examples/telemetry.py +++ b/examples/telemetry.py @@ -15,10 +15,11 @@ async def run(): await drone.connect(system_address="udpin://0.0.0.0:14540") # Start the tasks - asyncio.ensure_future(print_battery(drone)) - asyncio.ensure_future(print_gps_info(drone)) - asyncio.ensure_future(print_in_air(drone)) - asyncio.ensure_future(print_position(drone)) + tasks = [] + tasks.append(asyncio.create_task(print_battery(drone))) + tasks.append(asyncio.create_task(print_gps_info(drone))) + tasks.append(asyncio.create_task(print_in_air(drone))) + tasks.append(asyncio.create_task(print_position(drone))) # Keep the program running indefinitely exit_event = asyncio.Event() diff --git a/examples/telemetry_is_armed_is_in_air.py b/examples/telemetry_is_armed_is_in_air.py index 8a4efa2e..ce313877 100755 --- a/examples/telemetry_is_armed_is_in_air.py +++ b/examples/telemetry_is_armed_is_in_air.py @@ -8,8 +8,9 @@ async def run(): drone = System() await drone.connect(system_address="udpin://0.0.0.0:14540") - asyncio.ensure_future(print_is_armed(drone)) - asyncio.ensure_future(print_is_in_air(drone)) + tasks = [] + tasks.append(asyncio.create_task(print_is_armed(drone))) + tasks.append(asyncio.create_task(print_is_in_air(drone))) # Keep the program running indefinitely exit_event = asyncio.Event() diff --git a/examples/transponder.py b/examples/transponder.py index a1d454f7..1e4d4895 100755 --- a/examples/transponder.py +++ b/examples/transponder.py @@ -10,7 +10,7 @@ async def run(): await drone.connect() # Start the tasks - asyncio.ensure_future(print_transponders(drone)) + tasks = {asyncio.create_task(print_transponders(drone))} # Runs the event loop until the program is canceled with e.g. CTRL-C while True: From f1be08413cc554e837a53fc0a4cda2febac048e4 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 4 Sep 2025 10:44:10 +1200 Subject: [PATCH 03/15] CI: add ruff checks --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fbfdb883..9bdf86ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,9 +26,10 @@ jobs: - name: Check style run: | - python3 -m pip install pycodestyle + python3 -m pip install pycodestyle ruff export PATH=$PATH:$HOME/.local/bin pycodestyle --max-line-length=100 examples/* + ruff --select=ASYNC,RUF006 - name: Install prerequisites run: | From 5874239dcbea17d09249e5dda9dfb50d1214bd4e Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 4 Sep 2025 21:20:23 +1200 Subject: [PATCH 04/15] Update .github/workflows/main.yml Co-authored-by: Christian Clauss --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9bdf86ba..eb5a8caf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: python3 -m pip install pycodestyle ruff export PATH=$PATH:$HOME/.local/bin pycodestyle --max-line-length=100 examples/* - ruff --select=ASYNC,RUF006 + ruff check --select=ASYNC,RUF006 - name: Install prerequisites run: | From bcbc92c439ed52d07a8b03a691296823150bd1e9 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 5 Sep 2025 08:11:35 +1200 Subject: [PATCH 05/15] Use pipx Co-authored-by: Christian Clauss --- .github/workflows/main.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb5a8caf..ba18971b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,14 +22,12 @@ jobs: fetch-depth: 0 - name: Install pip - run: sudo apt-get install -y python3-pip + run: sudo apt-get install -y python3-pip pipx - name: Check style run: | - python3 -m pip install pycodestyle ruff - export PATH=$PATH:$HOME/.local/bin - pycodestyle --max-line-length=100 examples/* - ruff check --select=ASYNC,RUF006 + pipx run pycodestyle --max-line-length=100 examples/* + pipx run ruff check --select=ASYNC,RUF006 - name: Install prerequisites run: | From 7c7ac3686f0734470d58cd0b9b34b28618d9dec7 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 5 Sep 2025 08:11:59 +1200 Subject: [PATCH 06/15] Various improvements Co-authored-by: Christian Clauss --- examples/camera_params.py | 9 +++--- .../offboard_from_csv/offboard_from_csv.py | 31 ++++++++++--------- examples/rtk_base_ublox.py | 7 +++-- examples/telemetry.py | 11 ++++--- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/examples/camera_params.py b/examples/camera_params.py index bcf2cc1f..2c298b76 100755 --- a/examples/camera_params.py +++ b/examples/camera_params.py @@ -24,10 +24,11 @@ async def run(): drone = System() await drone.connect(system_address="udpin://0.0.0.0:14540") - tasks = [] - tasks.append(asyncio.create_task(observe_current_settings(drone))) - tasks.append(asyncio.create_task(observe_camera_mode(drone))) - tasks.append(asyncio.create_task(observe_possible_setting_options(drone))) + tasks = [ + asyncio.create_task(observe_current_settings(drone)), + asyncio.create_task(observe_camera_mode(drone)), + asyncio.create_task(observe_possible_setting_options(drone)), + ] while True: entered_input = await ainput(usage_str) diff --git a/examples/offboard_from_csv/offboard_from_csv.py b/examples/offboard_from_csv/offboard_from_csv.py index 7cf28cc7..6f8854f3 100644 --- a/examples/offboard_from_csv/offboard_from_csv.py +++ b/examples/offboard_from_csv/offboard_from_csv.py @@ -145,24 +145,25 @@ async def run(): await drone.action.disarm() return - waypoints = [] - # Read data from the CSV file async with await anyio.open_file("active.csv", "r", newline="") as csvfile: content = await csvfile.read() - reader = csv.DictReader(io.StringIO(content)) - for row in reader: - waypoints.append((float(row["t"]), - float(row["px"]), - float(row["py"]), - float(row["pz"]), - float(row["vx"]), - float(row["vy"]), - float(row["vz"]), - float(row["ax"]), - float(row["ay"]), - float(row["az"]), - int(row["mode"]))) + waypoints = [ + ( + float(row["t"]), + float(row["px"]), + float(row["py"]), + float(row["pz"]), + float(row["vx"]), + float(row["vy"]), + float(row["vz"]), + float(row["ax"]), + float(row["ay"]), + float(row["az"]), + int(row["mode"]), + ) + for row in csv.DictReader(io.StringIO(content)) + ] print("-- Performing trajectory") total_duration = waypoints[-1][0] diff --git a/examples/rtk_base_ublox.py b/examples/rtk_base_ublox.py index 35efe720..2fcbb8fd 100755 --- a/examples/rtk_base_ublox.py +++ b/examples/rtk_base_ublox.py @@ -97,9 +97,10 @@ async def run(): await drone.connect() # Start the tasks - tasks = [] - tasks.append(asyncio.create_task(print_gps_info(drone))) - tasks.append(asyncio.create_task(send_rtcm(drone))) + tasks = [ + asyncio.create_task(print_gps_info(drone)), + asyncio.create_task(send_rtcm(drone)), + ] # Keep the program running indefinitely exit_event = asyncio.Event() diff --git a/examples/telemetry.py b/examples/telemetry.py index 763bd5ee..b8d6a488 100755 --- a/examples/telemetry.py +++ b/examples/telemetry.py @@ -15,11 +15,12 @@ async def run(): await drone.connect(system_address="udpin://0.0.0.0:14540") # Start the tasks - tasks = [] - tasks.append(asyncio.create_task(print_battery(drone))) - tasks.append(asyncio.create_task(print_gps_info(drone))) - tasks.append(asyncio.create_task(print_in_air(drone))) - tasks.append(asyncio.create_task(print_position(drone))) + tasks = [ + asyncio.create_task(print_battery(drone)), + asyncio.create_task(print_gps_info(drone)), + asyncio.create_task(print_in_air(drone)), + asyncio.create_task(print_position(drone)), + ] # Keep the program running indefinitely exit_event = asyncio.Event() From b6f80ff0e6652be4fbb19495d640fdc4d3035ada Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 5 Sep 2025 08:18:23 +1200 Subject: [PATCH 07/15] examples: fix unnecessary f-strings --- examples/camera.py | 2 +- examples/camera_params.py | 20 ++++++++++---------- examples/failure_injection.py | 2 +- examples/firmware_version.py | 2 +- examples/follow_me_example.py | 2 +- examples/ftp_download_file.py | 2 +- examples/ftp_list_dir.py | 2 +- examples/geofence.py | 2 +- examples/goto.py | 2 +- examples/gripper.py | 6 +++--- examples/highres_imu.py | 2 +- examples/logfile_download.py | 2 +- examples/manual_control.py | 2 +- examples/mission.py | 2 +- examples/mission_import.py | 2 +- examples/offboard_attitude.py | 2 +- examples/offboard_position_ned.py | 2 +- examples/offboard_position_velocity_ned.py | 2 +- examples/offboard_velocity_body.py | 2 +- examples/offboard_velocity_ned.py | 2 +- examples/send_status_message.py | 2 +- examples/shell.py | 2 +- examples/takeoff_and_land.py | 2 +- examples/telemetry_flight_mode.py | 2 +- examples/telemetry_status_text.py | 2 +- examples/telemetry_takeoff_and_land.py | 2 +- examples/tune.py | 2 +- examples/winch.py | 4 ++-- 28 files changed, 40 insertions(+), 40 deletions(-) diff --git a/examples/camera.py b/examples/camera.py index a6b224b3..e5e3dae4 100755 --- a/examples/camera.py +++ b/examples/camera.py @@ -17,7 +17,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print_mode_task = asyncio.ensure_future(print_mode(drone)) diff --git a/examples/camera_params.py b/examples/camera_params.py index 2c298b76..6f2c6cea 100755 --- a/examples/camera_params.py +++ b/examples/camera_params.py @@ -34,12 +34,12 @@ async def run(): entered_input = await ainput(usage_str) if entered_input == "p": - print(f"\n=== Current settings ===\n") + print("\n=== Current settings ===\n") print_current_settings() elif entered_input == "m": - print(f"\n=== Possible modes ===\n") - print(f"1. PHOTO") - print(f"2. VIDEO") + print("\n=== Possible modes ===\n") + print("1. PHOTO") + print("2. VIDEO") try: index_mode = await make_user_choose_camera_mode() @@ -56,11 +56,11 @@ async def run(): try: await drone.camera.set_mode(chosen_mode) - print(f" --> Succeeded") + print(" --> Succeeded") except CameraError as error: print(f" --> Failed with code: {error._result.result_str}") elif entered_input == "s": - print(f"\n=== Possible settings ===\n") + print("\n=== Possible settings ===\n") print_possible_settings(possible_setting_options) try: @@ -72,10 +72,10 @@ async def run(): selected_setting = possible_setting_options[index_setting - 1] possible_options = selected_setting.options - print(f"\n=== Available options ===") + print("\n=== Available options ===") print(f"Setting: {selected_setting.setting_id}") if not selected_setting.is_range: - print(f"Options:") + print("Options:") try: print_possible_options(possible_options) index_option = await make_user_choose_option(possible_options) @@ -113,7 +113,7 @@ async def run(): try: await drone.camera.set_setting(setting) - print(f" --> Succeeded") + print(" --> Succeeded") except CameraError as error: print(f" --> Failed with code: {error._result.result_str}") else: @@ -150,7 +150,7 @@ def print_current_settings(): async def make_user_choose_camera_mode(): - index_mode_str = await ainput(f"\nWhich mode do you want? [1..2] >>> ") + index_mode_str = await ainput("\nWhich mode do you want? [1..2] >>> ") index_mode = int(index_mode_str) if index_mode < 1 or index_mode > 2: raise ValueError() diff --git a/examples/failure_injection.py b/examples/failure_injection.py index 8284e7c9..2346157d 100755 --- a/examples/failure_injection.py +++ b/examples/failure_injection.py @@ -13,7 +13,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/firmware_version.py b/examples/firmware_version.py index 08dd022b..30c5fa11 100755 --- a/examples/firmware_version.py +++ b/examples/firmware_version.py @@ -15,7 +15,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break info = await drone.info.get_version() diff --git a/examples/follow_me_example.py b/examples/follow_me_example.py index 048573a8..51c2ab62 100755 --- a/examples/follow_me_example.py +++ b/examples/follow_me_example.py @@ -32,7 +32,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/ftp_download_file.py b/examples/ftp_download_file.py index 312af188..2bb78da0 100755 --- a/examples/ftp_download_file.py +++ b/examples/ftp_download_file.py @@ -11,7 +11,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break async for update in drone.ftp.download( diff --git a/examples/ftp_list_dir.py b/examples/ftp_list_dir.py index 21fa1473..23fac385 100755 --- a/examples/ftp_list_dir.py +++ b/examples/ftp_list_dir.py @@ -11,7 +11,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("directory list", await drone.ftp.list_directory("/")) diff --git a/examples/geofence.py b/examples/geofence.py index 557a4c77..6e10fc39 100755 --- a/examples/geofence.py +++ b/examples/geofence.py @@ -26,7 +26,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break # Fetch the home location coordinates, in order to set a boundary around diff --git a/examples/goto.py b/examples/goto.py index e2088a30..c5e0a340 100755 --- a/examples/goto.py +++ b/examples/goto.py @@ -15,7 +15,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/gripper.py b/examples/gripper.py index ae78e682..a2dddcb9 100644 --- a/examples/gripper.py +++ b/examples/gripper.py @@ -11,15 +11,15 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break - print(f"-- Gripper Grab") + print("-- Gripper Grab") await drone.gripper.grab(instance=1) await asyncio.sleep(1) - print(f"-- Gripper Release") + print("-- Gripper Release") await drone.gripper.release(instance=1) while True: diff --git a/examples/highres_imu.py b/examples/highres_imu.py index dd129f6b..3cc343eb 100644 --- a/examples/highres_imu.py +++ b/examples/highres_imu.py @@ -23,7 +23,7 @@ async def get_imu_data(): print("Fetching IMU data...") async for imu in telemetry.imu(): # Print data in HIGHRES_IMU format - print(f"HIGHRES_IMU (105)") + print("HIGHRES_IMU (105)") print(f"Time (us): {imu.timestamp_us}") print(f"X Acceleration (m/s^2): {imu.acceleration_frd.forward_m_s2}") print(f"Y Acceleration (m/s^2): {imu.acceleration_frd.right_m_s2}") diff --git a/examples/logfile_download.py b/examples/logfile_download.py index da67c013..d6020b66 100755 --- a/examples/logfile_download.py +++ b/examples/logfile_download.py @@ -12,7 +12,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break entries = await get_entries(drone) diff --git a/examples/manual_control.py b/examples/manual_control.py index 4a1447c8..327c4503 100755 --- a/examples/manual_control.py +++ b/examples/manual_control.py @@ -40,7 +40,7 @@ async def manual_controls(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break # Checking if Global Position Estimate is ok diff --git a/examples/mission.py b/examples/mission.py index 68016340..8b42298e 100755 --- a/examples/mission.py +++ b/examples/mission.py @@ -17,7 +17,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print_mission_progress_task = asyncio.ensure_future(print_mission_progress(drone)) diff --git a/examples/mission_import.py b/examples/mission_import.py index b693ca1d..97d09f81 100755 --- a/examples/mission_import.py +++ b/examples/mission_import.py @@ -13,7 +13,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break out = await drone.mission_raw.import_qgroundcontrol_mission("example-mission.plan") diff --git a/examples/offboard_attitude.py b/examples/offboard_attitude.py index 9155a108..b1ca6258 100755 --- a/examples/offboard_attitude.py +++ b/examples/offboard_attitude.py @@ -20,7 +20,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/offboard_position_ned.py b/examples/offboard_position_ned.py index 8997dd8a..e7b470a9 100755 --- a/examples/offboard_position_ned.py +++ b/examples/offboard_position_ned.py @@ -27,7 +27,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/offboard_position_velocity_ned.py b/examples/offboard_position_velocity_ned.py index 9e1899dd..8fd0db3b 100755 --- a/examples/offboard_position_velocity_ned.py +++ b/examples/offboard_position_velocity_ned.py @@ -13,7 +13,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/offboard_velocity_body.py b/examples/offboard_velocity_body.py index c3ef1ce9..b2519714 100755 --- a/examples/offboard_velocity_body.py +++ b/examples/offboard_velocity_body.py @@ -16,7 +16,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/offboard_velocity_ned.py b/examples/offboard_velocity_ned.py index 2196f976..be7d88ef 100755 --- a/examples/offboard_velocity_ned.py +++ b/examples/offboard_velocity_ned.py @@ -16,7 +16,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/send_status_message.py b/examples/send_status_message.py index 50e4e9ed..6b6bbb11 100755 --- a/examples/send_status_message.py +++ b/examples/send_status_message.py @@ -23,7 +23,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") await drone.server_utility.send_status_text( StatusTextType.INFO, "Hello world!" ) diff --git a/examples/shell.py b/examples/shell.py index 52d450e5..a60a27d5 100755 --- a/examples/shell.py +++ b/examples/shell.py @@ -17,7 +17,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break asyncio.get_event_loop().add_reader(sys.stdin, got_stdin_data, drone) diff --git a/examples/takeoff_and_land.py b/examples/takeoff_and_land.py index 712a9179..19a19eb4 100755 --- a/examples/takeoff_and_land.py +++ b/examples/takeoff_and_land.py @@ -18,7 +18,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break print("Waiting for drone to have a global position estimate...") diff --git a/examples/telemetry_flight_mode.py b/examples/telemetry_flight_mode.py index 4fff2249..42ba1f3e 100755 --- a/examples/telemetry_flight_mode.py +++ b/examples/telemetry_flight_mode.py @@ -11,7 +11,7 @@ async def print_flight_mode(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break async for flight_mode in drone.telemetry.flight_mode(): diff --git a/examples/telemetry_status_text.py b/examples/telemetry_status_text.py index ecdf15d5..b888dc28 100755 --- a/examples/telemetry_status_text.py +++ b/examples/telemetry_status_text.py @@ -11,7 +11,7 @@ async def print_status_text(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break async for status_text in drone.telemetry.status_text(): diff --git a/examples/telemetry_takeoff_and_land.py b/examples/telemetry_takeoff_and_land.py index e68daeaf..6a2290f6 100755 --- a/examples/telemetry_takeoff_and_land.py +++ b/examples/telemetry_takeoff_and_land.py @@ -31,7 +31,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break # Start parallel tasks diff --git a/examples/tune.py b/examples/tune.py index 093dd886..6308a7ec 100755 --- a/examples/tune.py +++ b/examples/tune.py @@ -12,7 +12,7 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break song_elements = [] diff --git a/examples/winch.py b/examples/winch.py index b655b949..5e40ec9d 100644 --- a/examples/winch.py +++ b/examples/winch.py @@ -11,10 +11,10 @@ async def run(): print("Waiting for drone to connect...") async for state in drone.core.connection_state(): if state.is_connected: - print(f"-- Connected to drone!") + print("-- Connected to drone!") break - print(f"-- Winch action: load payload") + print("-- Winch action: load payload") await drone.winch.load_payload(instance=1) while True: From 8bb56d8eacc3dfa179091ad32193d4a377659cb9 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 5 Sep 2025 08:29:56 +1200 Subject: [PATCH 08/15] examples: more ruff fixes --- examples/camera_params.py | 2 +- examples/follow_me_example.py | 2 +- examples/mission_import.py | 1 - examples/offboard_from_csv/offboard_from_csv.py | 4 ++-- examples/offboard_position_velocity_ned.py | 2 +- examples/rtk_base_ublox.py | 4 ++-- examples/shell.py | 2 +- examples/telemetry.py | 2 +- examples/transponder.py | 2 +- examples/tune.py | 2 +- examples/upload_params.py | 6 +++--- 11 files changed, 14 insertions(+), 15 deletions(-) diff --git a/examples/camera_params.py b/examples/camera_params.py index 6f2c6cea..240acf54 100755 --- a/examples/camera_params.py +++ b/examples/camera_params.py @@ -24,7 +24,7 @@ async def run(): drone = System() await drone.connect(system_address="udpin://0.0.0.0:14540") - tasks = [ + _tasks = [ asyncio.create_task(observe_current_settings(drone)), asyncio.create_task(observe_camera_mode(drone)), asyncio.create_task(observe_possible_setting_options(drone)), diff --git a/examples/follow_me_example.py b/examples/follow_me_example.py index 51c2ab62..3ec69408 100755 --- a/examples/follow_me_example.py +++ b/examples/follow_me_example.py @@ -4,7 +4,7 @@ import asyncio from mavsdk import System -from mavsdk.follow_me import Config, FollowMeError, TargetLocation +from mavsdk.follow_me import Config, TargetLocation follow_height = 8.0 # in meters diff --git a/examples/mission_import.py b/examples/mission_import.py index 97d09f81..dc797a18 100755 --- a/examples/mission_import.py +++ b/examples/mission_import.py @@ -3,7 +3,6 @@ import asyncio from mavsdk import System -import mavsdk.mission_raw async def run(): diff --git a/examples/offboard_from_csv/offboard_from_csv.py b/examples/offboard_from_csv/offboard_from_csv.py index 6f8854f3..c8381a27 100644 --- a/examples/offboard_from_csv/offboard_from_csv.py +++ b/examples/offboard_from_csv/offboard_from_csv.py @@ -82,7 +82,7 @@ import anyio from mavsdk import System from mavsdk.offboard import PositionNedYaw, VelocityNedYaw -from mavsdk.offboard import AccelerationNed, OffboardError +from mavsdk.offboard import OffboardError from mavsdk.telemetry import LandedState @@ -178,7 +178,7 @@ async def run(): position = current_waypoint[1:4] velocity = current_waypoint[4:7] - acceleration = current_waypoint[7:10] + _acceleration = current_waypoint[7:10] # unused mode_code = current_waypoint[-1] if last_mode != mode_code: # Print the mode number and its description diff --git a/examples/offboard_position_velocity_ned.py b/examples/offboard_position_velocity_ned.py index 8fd0db3b..a209d00b 100755 --- a/examples/offboard_position_velocity_ned.py +++ b/examples/offboard_position_velocity_ned.py @@ -44,7 +44,7 @@ async def print_z_velocity(drone): async for odom in drone.telemetry.position_velocity_ned(): print(f"{odom.velocity.north_m_s} {odom.velocity.down_m_s}") - tasks = {asyncio.create_task(print_z_velocity(drone))} + _tasks = {asyncio.create_task(print_z_velocity(drone))} print("-- Go 0m North, 0m East, -10m Down within local coordinate system") await drone.offboard.set_position_velocity_ned( diff --git a/examples/rtk_base_ublox.py b/examples/rtk_base_ublox.py index 2fcbb8fd..bf08dd38 100755 --- a/examples/rtk_base_ublox.py +++ b/examples/rtk_base_ublox.py @@ -97,7 +97,7 @@ async def run(): await drone.connect() # Start the tasks - tasks = [ + _tasks = [ asyncio.create_task(print_gps_info(drone)), asyncio.create_task(send_rtcm(drone)), ] @@ -170,7 +170,7 @@ async def send_rtcm(drone): # It's recommended to disable NMEA messages, so this script # does not have to differentiate between 3 kinds of messages - nmea = ublox.readline() + # nmea = ublox.readline() # print(nmea) pass diff --git a/examples/shell.py b/examples/shell.py index a60a27d5..5d7e0a26 100755 --- a/examples/shell.py +++ b/examples/shell.py @@ -12,7 +12,7 @@ async def run(): drone = System() await drone.connect(system_address="udpin://0.0.0.0:14540") - tasks = {asyncio.create_task(observe_shell(drone))} + _tasks = {asyncio.create_task(observe_shell(drone))} print("Waiting for drone to connect...") async for state in drone.core.connection_state(): diff --git a/examples/telemetry.py b/examples/telemetry.py index b8d6a488..dd973b21 100755 --- a/examples/telemetry.py +++ b/examples/telemetry.py @@ -15,7 +15,7 @@ async def run(): await drone.connect(system_address="udpin://0.0.0.0:14540") # Start the tasks - tasks = [ + _tasks = [ asyncio.create_task(print_battery(drone)), asyncio.create_task(print_gps_info(drone)), asyncio.create_task(print_in_air(drone)), diff --git a/examples/transponder.py b/examples/transponder.py index 1e4d4895..d7e5fbc3 100755 --- a/examples/transponder.py +++ b/examples/transponder.py @@ -10,7 +10,7 @@ async def run(): await drone.connect() # Start the tasks - tasks = {asyncio.create_task(print_transponders(drone))} + _tasks = {asyncio.create_task(print_transponders(drone))} # Runs the event loop until the program is canceled with e.g. CTRL-C while True: diff --git a/examples/tune.py b/examples/tune.py index 6308a7ec..89cacdf5 100755 --- a/examples/tune.py +++ b/examples/tune.py @@ -2,7 +2,7 @@ import asyncio from mavsdk import System -from mavsdk.tune import SongElement, TuneDescription, TuneError +from mavsdk.tune import SongElement, TuneDescription async def run(): diff --git a/examples/upload_params.py b/examples/upload_params.py index 0c496c3a..4c1f86a5 100755 --- a/examples/upload_params.py +++ b/examples/upload_params.py @@ -49,11 +49,11 @@ async def set_params(args): continue columns = line.strip().split("\t") - vehicle_id = columns[0] - component_id = columns[1] + _vehicle_id = columns[0] + _component_id = columns[1] name = columns[2] value = columns[3] - type = columns[4] + _type = columns[4] if name in int_param_names: await drone.param.set_param_int(name, int(value)) elif name in float_param_names: From fce9984b593ea74f125011d86ca6e187f36a1521 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 5 Sep 2025 08:30:20 +1200 Subject: [PATCH 09/15] CI: enable all ruff checks --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba18971b..00878fbf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: - name: Check style run: | pipx run pycodestyle --max-line-length=100 examples/* - pipx run ruff check --select=ASYNC,RUF006 + pipx run ruff check - name: Install prerequisites run: | From e84d87f0b2ba9c9e9d24962758949dd1a8a097fe Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 6 Sep 2025 09:36:15 +1200 Subject: [PATCH 10/15] CI: add standard set for ruff, examples only --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 00878fbf..5d658bb3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: - name: Check style run: | pipx run pycodestyle --max-line-length=100 examples/* - pipx run ruff check + pipx run ruff check --select=ASYNC,RUF006,E,F examples/* - name: Install prerequisites run: | From 0259a1164c99047829901382c20a040649f5e259 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 6 Sep 2025 09:43:48 +1200 Subject: [PATCH 11/15] CI: add codespell check --- .github/workflows/main.yml | 1 + examples/rtk_base_ublox.py | 2 +- mavsdk/__init__.py | 2 +- other/docker/testing/Dockerfile | 2 +- setup.cfg | 3 +++ 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d658bb3..8580ffe6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: run: | pipx run pycodestyle --max-line-length=100 examples/* pipx run ruff check --select=ASYNC,RUF006,E,F examples/* + pipx run codespell . - name: Install prerequisites run: | diff --git a/examples/rtk_base_ublox.py b/examples/rtk_base_ublox.py index bf08dd38..85a55db1 100755 --- a/examples/rtk_base_ublox.py +++ b/examples/rtk_base_ublox.py @@ -86,7 +86,7 @@ def read_packet(self, dev, preamble): async def run(): # Init the drone. # Note that connecting directly to a drone is not very useful here. - # You probably want to set-up some MAVLink message routing inbetween + # You probably want to set-up some MAVLink message routing in-between # this script and the drone. # Good candidates for this are # 1. mavlink-router (https://github.com/mavlink-router/mavlink-router) diff --git a/mavsdk/__init__.py b/mavsdk/__init__.py index 726b17f4..d8b9bb86 100644 --- a/mavsdk/__init__.py +++ b/mavsdk/__init__.py @@ -15,7 +15,7 @@ # Do asyncio specific initialization try: # Try to import uvloop, provides _MUCH_ better performance compared to the - # standart unix selector event loop + # standard unix selector event loop import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) diff --git a/other/docker/testing/Dockerfile b/other/docker/testing/Dockerfile index 6b1a79c1..a7b2aba5 100644 --- a/other/docker/testing/Dockerfile +++ b/other/docker/testing/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -# Prefere local python binaries over the distributed ones +# Prefer local python binaries over the distributed ones ENV PATH /usr/local/bin:$PATH # Needed for Python 3 diff --git a/setup.cfg b/setup.cfg index 49b8f1df..890ce7ac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,6 @@ license_file = LICENSE.txt [bdist_wheel] universal=0 + +[codespell] +ignore-words-list = NED,PositionNed From f71029cb718d5587604c472a7db0a571f6f00956 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 6 Sep 2025 09:46:36 +1200 Subject: [PATCH 12/15] CI: check directory, not all files --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8580ffe6..3673b503 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,8 +26,8 @@ jobs: - name: Check style run: | - pipx run pycodestyle --max-line-length=100 examples/* - pipx run ruff check --select=ASYNC,RUF006,E,F examples/* + pipx run pycodestyle --max-line-length=100 examples + pipx run ruff check --select=ASYNC,RUF006,E,F examples pipx run codespell . - name: Install prerequisites From faa08d24c4d0afbf841694a43a399df751033643 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 10 Sep 2025 10:59:48 +1200 Subject: [PATCH 13/15] CI: switch from pycodestyle to ruff format --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3673b503..35aeddf2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: - name: Check style run: | - pipx run pycodestyle --max-line-length=100 examples + pipx run ruff format --check --line-length=100 examples pipx run ruff check --select=ASYNC,RUF006,E,F examples pipx run codespell . From c428076b30ffa897115840a9fd417bb49c55d25a Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 10 Sep 2025 11:00:41 +1200 Subject: [PATCH 14/15] examples: ran ruff format --- examples/camera_params.py | 8 ++------ examples/gimbal.py | 4 +--- examples/manual_control.py | 8 ++------ examples/mission_import.py | 5 +---- examples/offboard_from_csv/offboard_from_csv.py | 5 +---- examples/rtk_base_ublox.py | 8 ++------ examples/send_status_message.py | 4 +--- examples/upload_params.py | 10 +++------- 8 files changed, 13 insertions(+), 39 deletions(-) diff --git a/examples/camera_params.py b/examples/camera_params.py index 240acf54..0c4ef0e3 100755 --- a/examples/camera_params.py +++ b/examples/camera_params.py @@ -96,9 +96,7 @@ async def run(): continue else: try: - selected_value = await make_user_choose_option_range( - possible_options - ) + selected_value = await make_user_choose_option_range(possible_options) print(f"Setting {selected_setting.setting_id} to {selected_value}!") setting = Setting( @@ -187,9 +185,7 @@ def print_possible_options(possible_options): async def make_user_choose_option(possible_options): n_options = len(possible_options) - index_option_str = await ainput( - f"\nWhich option do you want? [1..{n_options}] >>> " - ) + index_option_str = await ainput(f"\nWhich option do you want? [1..{n_options}] >>> ") index_option = int(index_option_str) if index_option < 1 or index_option > n_options: diff --git a/examples/gimbal.py b/examples/gimbal.py index 5680e4c3..ab2ddff8 100755 --- a/examples/gimbal.py +++ b/examples/gimbal.py @@ -107,9 +107,7 @@ async def run(): # Set the gimbal to track a region of interest (lat, lon, altitude) # Units are degrees and meters MSL respectively print("Look at a ROI (region of interest) with gimbal ID", gimbal.gimbal_id) - await drone.gimbal.set_roi_location( - gimbal.gimbal_id, 47.39743832, 8.5463316, 488 - ) + await drone.gimbal.set_roi_location(gimbal.gimbal_id, 47.39743832, 8.5463316, 488) await asyncio.sleep(4) print("Back to forward again with gimbal ID", gimbal.gimbal_id) diff --git a/examples/manual_control.py b/examples/manual_control.py index 327c4503..0cf7fa34 100755 --- a/examples/manual_control.py +++ b/examples/manual_control.py @@ -50,9 +50,7 @@ async def manual_controls(): break # set the manual control input after arming - await drone.manual_control.set_manual_control_input( - float(0), float(0), float(0.5), float(0) - ) + await drone.manual_control.set_manual_control_input(float(0), float(0), float(0.5), float(0)) # Arming the drone print("-- Arming") @@ -64,9 +62,7 @@ async def manual_controls(): await asyncio.sleep(5) # set the manual control input after arming - await drone.manual_control.set_manual_control_input( - float(0), float(0), float(0.5), float(0) - ) + await drone.manual_control.set_manual_control_input(float(0), float(0), float(0.5), float(0)) # start manual control print("-- Starting manual control") diff --git a/examples/mission_import.py b/examples/mission_import.py index dc797a18..26d01863 100755 --- a/examples/mission_import.py +++ b/examples/mission_import.py @@ -17,10 +17,7 @@ async def run(): out = await drone.mission_raw.import_qgroundcontrol_mission("example-mission.plan") - print( - f"{len(out.mission_items)} mission items and" - f"{len(out.rally_items)} rally items imported." - ) + print(f"{len(out.mission_items)} mission items and{len(out.rally_items)} rally items imported.") await drone.mission_raw.upload_mission(out.mission_items) await drone.mission_raw.upload_rally_points(out.rally_items) diff --git a/examples/offboard_from_csv/offboard_from_csv.py b/examples/offboard_from_csv/offboard_from_csv.py index c8381a27..92877e9b 100644 --- a/examples/offboard_from_csv/offboard_from_csv.py +++ b/examples/offboard_from_csv/offboard_from_csv.py @@ -182,10 +182,7 @@ async def run(): mode_code = current_waypoint[-1] if last_mode != mode_code: # Print the mode number and its description - print( - " Mode number: " + f"{mode_code}, " - f"Description: {mode_descriptions[mode_code]}" - ) + print(" Mode number: " + f"{mode_code}, Description: {mode_descriptions[mode_code]}") last_mode = mode_code # set_position_velocity_acceleration_ned is not yet available # in the default build for MAVSDK-Python Installation with pip3 diff --git a/examples/rtk_base_ublox.py b/examples/rtk_base_ublox.py index 85a55db1..abb21c4f 100755 --- a/examples/rtk_base_ublox.py +++ b/examples/rtk_base_ublox.py @@ -33,9 +33,7 @@ def read_packet(self, dev, preamble): if self.debug: print( - "UBX class id {} and message id {}".format( - ord(ubx_class_id), ord(ubx_message_id) - ) + "UBX class id {} and message id {}".format(ord(ubx_class_id), ord(ubx_message_id)) ) # The ubx message in full_data could be parsed with pyubx2.UBXReader @@ -142,9 +140,7 @@ async def send_rtcm(drone): # Convert the rtcm data to a base64, # In MAVSDK v3 the rtcm data is expected # to be base64 encoded string . - base64_rtcm_data = base64.b64encode(rtcm_correction_data).decode( - "utf-8" - ) + base64_rtcm_data = base64.b64encode(rtcm_correction_data).decode("utf-8") # Send RTCM await drone.rtk.send_rtcm_data(rtk.RtcmData(base64_rtcm_data)) diff --git a/examples/send_status_message.py b/examples/send_status_message.py index 6b6bbb11..dd4086f1 100755 --- a/examples/send_status_message.py +++ b/examples/send_status_message.py @@ -24,9 +24,7 @@ async def run(): async for state in drone.core.connection_state(): if state.is_connected: print("-- Connected to drone!") - await drone.server_utility.send_status_text( - StatusTextType.INFO, "Hello world!" - ) + await drone.server_utility.send_status_text(StatusTextType.INFO, "Hello world!") break diff --git a/examples/upload_params.py b/examples/upload_params.py index 4c1f86a5..ba33d103 100755 --- a/examples/upload_params.py +++ b/examples/upload_params.py @@ -9,12 +9,8 @@ def main(): parser = argparse.ArgumentParser() - parser.add_argument( - "connection", help="Connection string (e.g. udpin://0.0.0.0:14540)" - ) - parser.add_argument( - "param_file", help="Param file to be uploaded with .params format" - ) + parser.add_argument("connection", help="Connection string (e.g. udpin://0.0.0.0:14540)") + parser.add_argument("param_file", help="Param file to be uploaded with .params format") args = parser.parse_args() @@ -44,7 +40,7 @@ async def set_params(args): print("Uploading Parameters... Please do not arm the vehicle!") contents = await param_file.read() lines = contents.splitlines() - for line in tqdm(lines, unit='lines'): + for line in tqdm(lines, unit="lines"): if line.startswith("#"): continue From 96e1c384f70593987c183d9493b579435b2cc3ea Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 10 Sep 2025 11:05:07 +1200 Subject: [PATCH 15/15] CI: fixup line length --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 35aeddf2..72d14b04 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: - name: Check style run: | pipx run ruff format --check --line-length=100 examples - pipx run ruff check --select=ASYNC,RUF006,E,F examples + pipx run ruff check --select=ASYNC,RUF006,E,F --line-length=100 examples pipx run codespell . - name: Install prerequisites