Skip to content

Running

Peter Corke edited this page Jul 8, 2020 · 9 revisions

Standalone Python script

#!/usr/bin/env python3

import bdsim
 .
 .
bd.run(10)
bd.done()

The first line runs the simulation for the specified amount of time. Graphics behaviour is controlled by command line switches:

Switch Behaviour
-g disable graphics, simulation runs quickly, returns numerical result only
-a enable animation, simulation runs more slowly

The second line blocks until either the figures are all closed, or a SIGINT is received. Without this the program "falls of the end" and the graphics are not seen.

Python code within your script

Pretty much the same as above. The BlockDiagram constructor does access the command line arguments by defaults. If you use these for your own purposes, in particular use these same flags for your own purpose, then you can set some arguments to the constructor

Argument Behaviour
sysargs process command line arguments (default True)
graphics enable graphics, simulation runs quickly, returns numerical result only (default True)
animation enable animation, simulation runs more slowly (default False)

Jupyter