Repository navigation
Fix camera shell examples - #832
Merged
Merged
Conversation
Contributor
Author
|
Hi @julianoes, Thank you for merging. Cheers! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit messages for the web upload. Upload each file to the same branch as its own commit, in this order, with these subjects. The full messages, with explanations, are in the
.patchfiles.examples/camera.py:examples: camera: address the camera by its component IDexamples/camera_params.py:examples: camera_params: address the camera by its component IDexamples/shell.py:examples: shell: keep running, and pass the shell deviceexamples/gimbal.py:examples: gimbal: return the gimbals found instead of Noneexamples/px4_ev_automation.pyandexamples/px4_ev_automation_keyboard.pytogether:examples: px4_ev_automation: drop close() calls that don't existSeveral examples don't run against the current API. Each was found by checking every example's plugin calls against the generated plugin signatures, then confirmed by running it (see Testing).
camera.py and camera_params.py
set_mode(),take_photo()andset_setting()take the camera'scomponent_id.mode(),current_settings()andpossible_setting_options()yield per-camera update objects, andstatus()is gone. Both examples crash on their first camera command:camera_list(), pass itscomponent_id, and read the update objects.camera.pyprintsstorage()updates in place ofstatus().shell.py
nsh>. Since #6dc989f ("examples: fix RUF006") replacedrun_forever()withasyncio.run(run()),run()returns as soon as the stdin reader is added. It now waits on an event, liketelemetry.pyand the other long-running examples.Shell.send()also requires adevice. Without it, every command raised aTypeErrorinside a fire-and-forget task, so nothing reached the vehicle and no error was shown. It now passesDevice.SHELL, the plugin's documented default.gimbal.py
gimbal_list()never ends, sowait_for()always timed out andget_gimbals()returnedNone, even when gimbals were found.run()then crashed withTypeError: 'NoneType' object is not iterable.timeoutparameter is renamedwait_s. ruff's ASYNC109 flags atimeoutparameter on async functions, and with the current ruff (0.17) that makes the CI style check fail onmain.asyncio.timeout()would need Python 3.11, andsetup.pyallows 3.7.px4_ev_automation.py and px4_ev_automation_keyboard.py
Neither
SystemnorTelemetryhas aclose()method. Inpx4_ev_automation.pythe call is reached when the telemetry streams end, and raisesAttributeError. In the keyboard version it sits after an endless loop. Both calls are removed.Testing
Run on Linux with Python 3.13, mavsdk-grpc 4.0.5 and its bundled mavsdk_server v4.0.5. With no PX4 available, I used two stand-ins, both included in
test-harness/:fake_autopilot.py: PX4 heartbeats from system 1 / component 1. It routes MAVLink between the example and the camera, logsSERIAL_CONTROL, and answers gimbal commands.fake_camera.py: a MAVLink camera built on MAVSDK's ownCameraServerplugin. It answers mode changes, photos and storage requests, and logs each one.camera.pyTypeErrorabovecamera_params.py(inputp,m,1,p)TypeErroratm--> Succeededshell.py(inputls,param show SYS_AUTOSTART)nsh>; with only the exit fixed, 0 commands reach the autopilotSERIAL_CONTROLwithdevice=10(SERIAL_CONTROL_DEV_SHELL)gimbal.py, no gimbal presentTypeError: 'NoneType' object is not iterableget_gimbals()with a stub stream:[], then one gimbal, then never ending (test_get_gimbals.py)Noneafter the full timeout[gimbal]after 0.4 s, and[]after the timeout with no gimbalThe CI style commands pass:
ruff format --check,ruff check --select=ASYNC,RUF006,E,Fandruff check --select=PERF(all with--line-length=100), pluscodespell. ASYNC109 currently fails onmain, and this PR fixes it.Not tested:
camera_params.py'ss(change a setting) path, which needs a camera definition file. It only changes to pass thecomponent_id, the same asset_mode().