Can I interact with a Speedgoat real-time simulation from Python?
조회 수: 27 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2018년 10월 31일
편집: MathWorks Support Team
2024년 2월 2일
I would like to interact from our host computer with our Speedgoat machine to observe signals and update tunable parameters during runtime.
The goal is to be able to do this via a Python script or GUI. What would be the best way to accomplish this?
채택된 답변
MathWorks Support Team
2024년 2월 2일
편집: MathWorks Support Team
2024년 2월 2일
The MATLAB Engine API provides a package for Python to call MATLAB as a computational engine. An overview of this feature can be found at the following link:
To use the MATLAB Engine API for Speedgoat target computer & real-time simulation interaction, a full installation of MATLAB and Simulink Real-Time (including licenses) is required. With that, you will have full access to MATLAB's Simulink Real-Time features from Python.
For details on how to interact with a Speedgoat target machine and real-time simulation from Python, refer to the following example:
Note that the example above was designed to work with release R2020b or later. If you are working with R2020a or older, you will need to modify the code with the functions that are supported with your current release, such as the SimulinkRealTime.target object.
Tip: One thing to suggest while developing the Python interface is using the "-desktop" startup option when creating the engine. This will make the MATLAB instance visible, and will be useful in testing how the MATLAB Engine API interacts with the MATLAB instance for debugging and development purposes:Start MATLAB Engine for Python - MATLAB matlab.engine.start_matlab (mathworks.com)
Alternatives to Python:
The recommended method for interacting with a Speedgoat target machine is through a GUI created with MATLAB's App Designer as shown in the following link:
The App Designer workflow also supports the standalone operation of the GUI (without any MATLAB installation or license).
For a complete overview of available interfaces that don't require the full Simulink Real-Time license suite, refer to the MATLAB Answer posts below:
댓글 수: 0
추가 답변 (1개)
Pablo Romero
2021년 11월 19일
Please find a complete example at Run Real-Time Application by Using Python Script - MATLAB & Simulink (mathworks.com).
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!