Repository navigation
Fix stock Simulink example lifecycle - #227
Merged
Merged
Conversation
Connect to the shared MATLAB session in the background so Ctrl+C cannot leave the example with no engine, and report a missing session with the loader-script hint. Re-read finished MATLAB calls so an interrupt that arrives as a call completes does not hide its error. Name the lifecycle timeouts and print each failure traceback once.
This was referenced Oct 11, 2026
Contributor
|
Thanks for your contribution! keep it up! |
Contributor
Author
Thanks! |
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.
About
This PR fixes startup, interruption, and cleanup in the four stock Python Simulink examples in
client/python/example_user_scripts/:simulink_physics_quadrotor.pysimulink_physics_quadtiltrotor.pysimulink_controller_quadrotor.pysimulink_combined_quadrotor.pyOn current
main, these examples have the following problems:drone.disarm()or the model stop), the remaining steps are skipped, includingclient.disconnect(), and the next run cannot connect.start_future.result()) and stopping it (background=False) have no time limit. If the model never starts or never stops, the script hangs.start, while the scene is loading. Once the scene runs, the simulator's MATLAB physics or controller step retries the model's TCP connection until the model is running, so the simulation waits for compilation, and compilation errors appear only after the scene has loaded.None. The examples treat that as success, so pressing Ctrl+C while the model starts continues to the flight sequence.simulink_controller_quadrotor.pynamesload_quadrotor_simulink_control_model, but the example uses the model loaded byload_quadrotor_simulink_control_model_navigation.This change:
simulink_utils.py, a small helper module shared by the four examples.SimulationCommandupdate) before connecting to the simulator, then starts it in the background while the scene loads.simulink_controller_quadrotor.pyusage text.Behavior that stays the same:
Behavior differences users will notice:
How Has This Been Tested?
Offline tests, run from
client/python/projectairsim/tests/with Python 3.14 on Linux. These tests do not need MATLAB or a simulator:test_datacollection/conftest.pyrequires scikit-image, which was not installed in the test environment.git diff --checkpasses.Earlier live validation of the lifecycle changes, before the latest update, used MATLAB R2026b on Linux with a Project AirSim Runtime build that also contained other changes, not a rendered Unreal session:
simulink_physics_quadrotor.pycompleted takeoff, flight, and landing.simulink_controller_quadrotor.pystarted and stopped.simulink_combined_quadrotor.pystalled during startup and shutdown inside the native MATLAB transport, with both the original and the revised script. The revised script reports the stop timeout and disconnects its client, but a Python example cannot release an S-function that is blocked waiting for a request. The native fix is proposed separately in Fix MATLAB Runtime contact and transport lifecycle #229.After this update, the revised examples were run again together with the native fixes from #229 (headless Runtime on Linux, MATLAB R2026b): the physics example completed takeoff, flight, and landing; the controller-only example started and stopped; and the combined example started and stopped twice in one MATLAB session. Each model ended stopped and each Runtime exited with code 0.
Not tested:
main(only together with Fix MATLAB Runtime contact and transport lifecycle #229).simulink_physics_quadtiltrotor.pyflight.Related pull requests
Suggested merge order: #227 → #228 → #229 → #230. #230 also edits
client/python/projectairsim/tests/README.md, so whichever of the two merges later will be rebased.Screenshots and videos (if appropriate):
Not applicable.