Skip to main content

Generate Python wheel package from Simulink model!

Project description

Simbind CLI

Generate Python Wheel package from Simulink model to enhance your Software-in-Loop tests development workflow! Please refer to Wiki and Examples to explore the project's capabilities and limitations.
You also might be interested into pytest-simbind plugin that allows to test Simbind models with pytest!

Single Loop Feedback

Requirements

We highly recommend to use Dockerized version of Simbind, since collecting the correct versions of the necessary requirements can be challenging. If you opt for local installation, the following is required:

  • Linux x86-64 machine with installed Matlab R2023b.
  • Python 3.10 or 3.11: Simbind Architect requires Python 3.10+ and Simulink Exporter needs Python 3.9, 3.10 or 3.11.
  • From Matlab side you need Simulink suite with Embedded Coder.
  • You also need pip, gcc, cmake, make and swig. Under Debian-based distros you can install it with
    sudo apt-get install python3-pip build-essential cmake swig
    

To run output model you need Python 3.8+; Mock model can be used under any OS, SiL model requires Linux x86-64 machine. To learn more about Mock and SiL packages structure and usage, refer to Wiki.

Installation

To install from PyPi run

$ pip install simbind 

Please, notice that you will need to satisfy requirements before running pip!

To clone project you will also need to pull submodules with:

$ git clone --recurse-submodules https://github.com/swag-engineering/simbind-cli.git

Usage

Simbind CLI is a wrapper around Simulink Exporter and Simbind Architect projects and intended to be used as a standalone tool, not as an importable module. If you want to use its functionality programmatically, please refer to subprojects.

$ simbind --help
usage: simbind [-h] --slx-path SLX_PATH [--pkg-name PKG_NAME] [--wheel-out-dir WHEEL_OUT_DIR]
               [--solver {ode1,ode2,ode3,ode4,ode5,ode8,ode14x,ode1be}] [--step STEP_SIZE]
               [--license-text LICENSE_TEXT] [--matlab-include SIMULINK_PATHS] [--use-ansi-c]
               [--preprocessor-def PREPROCESSOR_DEFS] [-v]

Tool to generate Python wheel package from Simulink model.

options:
  -h, --help            show this help message and exit
  --slx-path SLX_PATH   Path to Simulink .slx file.
  --pkg-name PKG_NAME   Name of the output Python package. (default: 'model')
  --wheel-out-dir WHEEL_OUT_DIR
                        Path to folder where wheel package will be stored. (default: '.')
  --solver {ode1,ode2,ode3,ode4,ode5,ode8,ode14x,ode1be}
                        Fixed-step solver. (default: 'ode5')
  --step STEP_SIZE      Fixed step size in seconds. (default: '0.001')
  --license-text LICENSE_TEXT
                        License text that will be included in output Python wheel package. (default: '')
  --matlab-include MATLAB_PATH
                        Path to the folder that will be included into Matlab path. Can be used multiple
                        times.Example: --matlab-include /some/path --matlab-include /another/path
  --use-ansi-c          During build Matlab/Simulink will use C89/90 (ANSI) instead of C99
  --preprocessor-def PREPROCESSOR_DEF
                        Predefine name as a macro that will be passed to preprocessor. Can be used multiple
                        times.Example: --preprocessor-def "__attribute__(x)=" --preprocessor-def "DEBUG=1"
  -v                    Specifies the level of verbosity. Example: -vvv

For detailed instructions on the structure of the output Python package, please refer to our Wiki.

Docker Usage

Disclaimer
Before utilizing Docker containers to run MathWorks products, it is crucial to verify that your licensing agreement with MathWorks explicitly permits such usage. Licensing terms can vary, and it is the responsibility of the user to ensure compliance with these terms to avoid potential violations.

The primary challenge in using MathWorks products within Docker containers lies in the licencing the application. MathWorks offers various license types, detailed further here. If you have access to a network license or your organization utilizes a License Manager through their organization, you can uncomment the corresponding option in the Dockerfile. This section demonstrates how to apply your Individual License for using Simbind in a Docker container.
Since R2023b MathWorks does not generate dedicated Individual license file that could be utilized inside Docker container. Instead, it uses online license that requires you to login on a first use of newly installed Matlab:

  • Log in into docker container and provide your credentials:
    $ docker run -it --ulimit nofile=65535:65535 ghcr.io/swag-engineering/simbind-cli/simbind-cli:latest matlab
    MATLAB is selecting SOFTWARE OPENGL rendering.
    Please enter your MathWorks Account email address and press Enter: your@email.com
    Please enter your MathWorks Account password and press Enter:
    
  • Without terminating Docker session, in new terminal commit changes:
    $ docker ps
    CONTAINER ID   IMAGE                                                     COMMAND    CREATED         STATUS         PORTS     NAMES
    aef878e19c3f   ghcr.io/swag-engineering/simbind-cli/simbind-cli:latest   "matlab"   2 minutes ago   Up 2 minutes             focused_satoshi
    $ docker commit aef878e19c3f simbind-cli:licensed
    
  • Terminate docker session in the first terminal with:
    >> exit()
    

Now that you have configured your license, you're all set to utilize the simbind-cli:licensed image to use Simbind:

$ docker run --rm --ulimit nofile=65535:65535 \
  -v /path/to/model.slx:/tmp/model.slx \
  -v /path/to/output/dir:/tmp/output \
  simbind-cli:licensed \
  simbind \
  --slx-path /tmp/model.slx \
  --wheel-out-dir /tmp/output \
  --pkg-name fancypackage \
  --solver ode8 \
  --step 0.005

Issues

If you run into any issues or believe additional functionality is needed, please don't hesitate to open an issue or email us at contact@swag-engineering.io. We're always ready to assist!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simbind-0.2.0.tar.gz (56.1 kB view details)

Uploaded Source

Built Distribution

simbind-0.2.0-py3-none-manylinux2010_x86_64.whl (52.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.12+ x86-64

File details

Details for the file simbind-0.2.0.tar.gz.

File metadata

  • Download URL: simbind-0.2.0.tar.gz
  • Upload date:
  • Size: 56.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for simbind-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dd7767226867f57e990aaa090b2dd93703c3ae696cb9b5bce05d23aa54736857
MD5 e1e4650d286ef3df857b1ef26d710924
BLAKE2b-256 2c2becd3877c731fc7caa98748412e0c2ac2ec878d9a5c233866615022719f9d

See more details on using hashes here.

File details

Details for the file simbind-0.2.0-py3-none-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for simbind-0.2.0-py3-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5629105234d55a2ce8b3f86a078440cd296385f149132e885d7dd616732eeb5c
MD5 34fc741683f9e37bd77712c85d872b3c
BLAKE2b-256 8d32ffd521177a2da1c80625b2ce9ba702560a839d88e762781122cc06f7c4e1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page