-
Notifications
You must be signed in to change notification settings - Fork 34
.bd files
bdsim
supports models expressed in JSON format text files, which have the extension .bd
.
These contain a full description of the model including all block and wire parameters as well as visual information which is used
by bdedit
.
A .bd
file is ASCII text and can be easily modified using any text editor.
A block diagram instance can be created by
from bdsim import bdload, BDSim
sim = BDSim(animation=True)
bd = sim.blockdiagram()
bd = bdload(bd, "eg1.bd")
Note that the parameters of the blocks in the JSON file can only be simple types such as ints, floats, strings or lists of these simple types. For more complex parameters such as objects (robots, cameras, poses etc.) or functions they are referenced in the file as a string prefixed by an equal sign, which is a reference to a local variable. For example the parameter '=myparam'
is a reference to a local variable myparam
that must exist before the model is loaded.
from bdsim import bdload, BDSim
from spatialmath import SE3
sim = BDSim(animation=True)
bd = sim.blockdiagram()
myparam = SE.Tx(1.2)
bd = bdload(bd, model, globalvars=globals())
The interactive editing tool bdedit
is the easiest way to create such a file.
Copyright (c) Peter Corke 2020-23
- Home
- FAQ
- Changes
- Adding blocks
- Block path
- Connecting blocks
- Subsystems
- Compiling
- Running
- Runtime options
- Discrete-time blocks
- Figures
- Real time control
- PID control
- Coding patterns