Skip to content

What about Simulink

Peter Corke edited this page Dec 22, 2020 · 3 revisions

The MATLAB version of the Toolbox had some support for Simulink, with the roblocks block library. Python has no Simulink!

However I am working on a simple Python-based block-diagram simulation tool called bdsim.

We first sketch the dynamic system we want to simulate as a block diagram, for example this simple first-order system

block diagram

which we can express concisely with bdsim as (see bdsim/examples/eg1.py

     1	#!/usr/bin/env python3
     2	
     3	import bdsim.simulation as sim
     4	
     5	bd = sim.Simulation()
     6	
     7	# define the blocks
     8	demand = bd.STEP(T=1, pos=(0,0), name='demand')
     9	sum = bd.SUM('+-', pos=(1,0))
    10	gain = bd.GAIN(10, pos=(1.5,0))
    11	plant = bd.LTI_SISO(0.5, [2, 1], name='plant', pos=(3,0))
    12	scope = bd.SCOPE(styles=['k', 'r--'], pos=(4,0))
    13	
    14	# connect the blocks
    15	bd.connect(demand, sum[0], scope[1])
    16	bd.connect(plant, sum[1])
    17	bd.connect(sum, gain)
    18	bd.connect(gain, plant)
    19	bd.connect(plant, scope[0])
    20	
    21	bd.compile()   # check the diagram
    22	bd.report()    # list all blocks and wires
    23	
    24	bd.run(5)  # simulate for 5s
    25	
    26	bd.dotfile('bd1.dot')  # output a graphviz dot file
    27	bd.savefig('pdf')      # save all figures as pdf
    28	
    29	bd.done()

It's showing promise and there are a bunch of examples from the Robotics, Vision & Control book up and running. More details on the bdsim page. There is not yet much in the way of robotics blocks, but there is a quad rotor dynamic model and visualiser.