FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Port microgcs to Python 3 and update the GUI from the main thread by Abhayindia · Pull Request #1257 · dronekit/dronekit-python · GitHub

Port microgcs to Python 3 and update the GUI from the main thread - #1257

Open
Abhayindia wants to merge 2 commits into
dronekit:masterfrom
Abhayindia:fix/microgcs-py3
Open

Abhayindia wants to merge 2 commits into
dronekit:masterfrom
Abhayindia:fix/microgcs-py3

Conversation

Copy link
Copy Markdown

Second finding from the SITL examples sweep in #1255. Two separate bugs in examples/gcs/microgcs.py, both of which stop it dead on Python 3.

1. from Tkinter import * is the Python 2 spelling. Python 3 renamed the module to lowercase tkinter, so the example fails at import:

ModuleNotFoundError: No module named 'Tkinter'

2. With that fixed, it segfaults. The GUI callbacks write to Tk widgets from DroneKit's MAVLink thread, and Tkinter widgets may only be touched from the thread running mainloop():

Connecting to vehicle on: tcp:127.0.0.1:5770
Segmentation fault (core dumped)

I isolated this rather than guessing: commenting out the three addObserverAndInit(...) calls and changing nothing else makes it survive indefinitely, which pins the crash on the attribute callbacks specifically. The fix routes each update through root.after(0, ...) so the widget write happens on the main loop's thread.

Verified against dronekit-sitl copter (APM:Copter 3.3): before, it core-dumps within seconds of connecting; after, it runs with all three observers live for 45s until I stop it, with the labels updating.

Branched off master, independent of #1253 and of #1256.

One caveat I would rather state than hide: I exercised this on a real X display and confirmed the window renders and updates, but I did not click the Auto/RTL buttons, because setting a flight mode does not work against the bundled SITL at all. That is a separate problem with its own root cause, which I will write up on #1255 rather than fold in here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL