Skip to content

petercorke/bdsim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

756 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 computer 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.

About

Simulate dynamic systems expressed in block diagram form using Python

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages