Skip to main content

Simulate dynamic systems expressed in block diagram form using Python

Project description

bdsim: Block Diagram Simulation for Python

bdsim logo
A Pythonic block-diagram environment for the simulation and analysis of dynamic systems.

JupyterLite PyPI version Documentation

GitHubWikiChangelogInstallation


Status & Ecosystem

A Python Robotics Package QUT Centre for Robotics Open Source Build Status Coverage Python Version License: MIT PyPI - Downloads

Powered by

Powered by NumPy Powered by Spatial Maths

Synopsis

bdsim bridges the gap between mathematical block diagrams and executable Python code. Unlike traditional graphical-only tools, it treats modelling as code, allowing you to define, simulate, and analyze continuous-time, discrete-time, or hybrid systems within a modern software engineering workflow. Wires in bdsim aren't limited to scalars; they pass NumPy arrays, dictionaries, or even SpatialMath objects seamlessly through your system, integrating directly with the Robotics and Machine Vision toolboxes.

🚀 Key Features

  • Python-First Workflow: Define your systems in pure Python code. Use your preferred IDE (like VS Code), manage versions with Git, and integrate with standard unit-testing frameworks.
  • Rich Data Types: Wires in bdsim aren't limited to scalars. Seamlessly pass NumPy arrays, dictionaries, or complex objects like SE3 and SO3 from the spatialmath-python library.
  • Modular & Extensible: Adding new functionality is straightforward. Create custom blocks by simply subclassing the Block class.
  • Hybrid Ecosystem: Native integration with the Robotics Toolbox and Machine Vision Toolbox for Python.
  • Powerful Editor: Includes bdedit, a PySide-based graphical editor for visual system design and discovery.
  • Publication Ready: Export diagrams or simulation data to to high-quality formats such as PDF or SVG for use in publications.

💻 Quick start

You can install bdsim directly from PyPI:

pip install bdsim
To include the graphical editor (bdedit) and its dependencies:

Bash
pip install bdsim[editor]

Install locally with help from the detailed installation guide.

Or skip setup and run the browser-based JupyterLite examples.

Example

The power of bdsim lies in its conciseness. The step response of a simple first-order system can be defined and simulated in just a few lines of code:

Python
import bdsim

sim = bdsim.BDSim()
bd = sim.blockdiagram()

# Define blocks
step = bd.STEP(T=1, pos=1)
plant = bd.LTI_SISO(1, [1, 1]) # 1/(s+1)
scope = bd.SCOPE()

# Connect blocks
bd.connect(step, plant)
bd.connect(plant, scope)

bd.compile()
out = sim.run(bd, T=5)

🔍 Why bdsim?

In contrast to traditional graphical simulation tools, bdsim treats modelling as code. This ensures:

  • Better Version Control: No more opaque binary blobs. Your models are searchable, diffable text.

  • Seamless Integration: Incorporate SciPy solvers, PyTorch models, or custom robotic vision pipelines directly into your simulation loops.

  • Scalability: Programmatically generate massive block diagrams or run large-scale batch simulations on headless servers.

📚 Documentation

Full Documentation: https://petercorke.github.io/bdsim/

Wiki: Access the community wiki for deep dives into specific block behaviours and tutorials.

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

bdsim-1.2.2.tar.gz (15.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bdsim-1.2.2-py3-none-any.whl (15.5 MB view details)

Uploaded Python 3

File details

Details for the file bdsim-1.2.2.tar.gz.

File metadata

  • Download URL: bdsim-1.2.2.tar.gz
  • Upload date:
  • Size: 15.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for bdsim-1.2.2.tar.gz
Algorithm Hash digest
SHA256 65a4c6a38b4a17cd2103bff808480844e55c756c3e33acd07971fc4b96b57aeb
MD5 f23ba7ba69ec58f81da63d58aeae96bd
BLAKE2b-256 3f9aed28f4122830a098ac77caa24ddbdfcc3d8863d1167988079b7d75c8d201

See more details on using hashes here.

File details

Details for the file bdsim-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: bdsim-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for bdsim-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a7427a9cd6432c931ff3d338955c9ee1db2748a3b26ce685159f7aa3af9fbff
MD5 2d5c85609c05ba9a4542b43fde93be5b
BLAKE2b-256 b5ce4c3030aa58ba5c4a4b3521e883290d436032fe6f1b5b375e286106b13a75

See more details on using hashes here.

Supported by

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