-
Notifications
You must be signed in to change notification settings - Fork 34
Adding blocks
The first step is to create a Simulation
object instance
import bdsim
bd = bdsim.BDSim()
which loads blocks from a number of modules in the bdsim/blocks
folder.
We create blocks using this object's factory methods. For example
gain = bd.GAIN(4)
is a gain block represented by an instance of the class Gain
>>> type(gain)
<class 'bdsim.blocks.functions.Gain'>
which has the class hierarchy Gain
→ FunctionBlock
→ Block
.
Blocks belong to one of four main subclasses:
Source blocks (subclass of SourceBlock
→ Block
) have an output, but no inputs.
Name | Description |
---|---|
CONSTANT | A constant of any type |
PIECEWISE | a piecewise constant function of time |
RAMP | a linear ramp with a start time |
STEP | a step (Heaviside) function of time |
TIME | time since start of simulation |
WAVEFORM | sine, square or triangle function of time |
Sink blocks (subclass of SinkBlock
→ Block
) have inputs, but no outputs.
Name | Description |
---|---|
NULL | discards all data |
Print value to console | |
STOP | Stop simulation when condition is true |
WATCH | Add input to the watch list |
SCOPE | Plot signals as function of time |
SCOPEXY | Plot one signal against another |
VEHICLE | 2D animation of ground vehicle motion |
MULTIROTORPLOT | 3D animation of multi-rotor motion |
Function blocks (subclass of FunctionBlock
→ Block
) have inputs and outputs and perform some linear or non-linear operation.
Name | Description |
---|---|
CLIP | limit signal values |
FUNCTION | apply Python function to inputs |
GAIN | multiply input by constant, any of input or constant can be numpy arrays |
INTERPOLATE | 1D interpolation of data |
PROD | multiplication and division of signals |
SUM | addition and subtraction of signals |
Linear algebra blocks (subclass of FunctionBlock
→ Block
) have inputs and outputs.
Name | Description |
---|---|
COND | matrix condition number |
DET | matrix determinant |
FLATTEN | flatten matrix to 1D array |
INVERSE | matrix inverse |
NORM | vector norm |
SLICE1 | slice of 1D array |
SLICE2 | slice of 2D array |
TRANSPOSE | matrix transpose |
Transfer blocks (subclass of TransferBlock
→ Block
) have inputs and outputs and state and represent differential equations.
Name | Description |
---|---|
INTEGRATOR | integration of input signals |
LTI_SISO | dynamic system described in transfer-function form |
LTI_SS | dynamic system described in state-space form |
POSEINTEGRATOR | integrate spatial velocity to pose |
Transfer blocks (subclass of TransferBlock
→ Block
) have inputs and outputs and state and represent continuous-time differential equations.
Name | Description |
---|---|
DINTEGRATOR | integration of input signals |
DPOSEINTEGRATOR | integrate spatial velocity to pose |
ZOH | zero-order hold |
Connection blocks (subclass of FunctionBlock
→ Block
) manipulate vector and dict signals.
Name | Description |
---|---|
MUX | concatenate signals into a vector signal |
DEMUX | split a vector signal to individual signals |
DICT | convert input signals to a dict of signals |
ITEM | select specific item from a dict signal |
Subsystem blocks (subclass of SubsystemBlock
→ Block
) connect a block diagram subsystem to a parent block diagram.
Name | Description |
---|---|
INPORT | Inputs to the subsystem, like a SourceBlock
|
OUTPORT | Outputs from the subsystem, like a SinkBlock
|
SUBSYSTEM | Represents the subsystem in the parent block diagram, like a FunctionBlock
|
The inputs to a SUBSYSTEM
block are the outputs of that subsystem's INPORT
, and the inputs to the subsystem's OUTPORT
are the outputs of the SUBSYSTEM
block.
Unlike Simulink, there is only one input or output block per subsystem, but they can have multiple inputs each.
Name | Description |
---|---|
ARMPLOT | Animate robot arm using Matplotlib |
CTRAJ | Cartesian trajectory |
CIRCLEPATH | circular trajectory |
DELTA2TR | spatial displacement to SE(3) |
FDYN | manipulator forward dynamics |
FDYN_X | manipulator forward dynamics in task space |
FKINE | manipulator forward kinematics trajectory |
GRAVLOAD | manipulator forward kinematics trajectory |
BICYCLE | Bicycle kinematics as for a car-like vehicle |
UNICYCLE | Unicycle kinematics |
DIFFSTEER | Differential-steer kinematics with wheel speed inputs |
MULTIROTOR | Dynamics of a multi-rotor drone |
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