Skip to content

main block

Peter Corke edited this page Apr 13, 2022 · 2 revisions

The JSON file can only define block parameters that are simple types. For more complex applications we may want to define objects to describe poses (eg. SE3 instance), robots (eg. ETS.Panda instance), cameras (eg. CentralCamera instance) etc. To do this we need a Python script to instantiate the objects and the .bd file to describe the blocks and their connectivity. There are two ways to go.

Running from the command line

Write a Python script that will:

  • setup the runtime environment
  • load the model using bdload
  • run the model using run

Running from inside bbedit

bdedit has a run button which will:

  • save the current model as a .bd file. If it is a new model that has not yet been saved, you are prompted for the file name.
  • execute the command bdrun OPTIONS FILENAME.bd where bdrun is a Python script shipped with bdsim that will load the model specified by its argument and run it. Standard bdsim options can be given to control graphics, animation, runtime etc.

If the model requires instantiation of objects before it can be run, it should include a MAIN block which contains the name of a script. In this case, the run button will:

  • save the current model as a .bd file. If it is a new model that has not yet been saved, you are prompted for the file name.

  • execute the command main OPTIONS FILENAME.bd where main is a Python script provided by the user. By convention these files are named model-main.py where model.bd is the name of the block diagram model file. This script will:

    • setup the runtime environment
    • load the model, specified by the script argument, using bdload. and run it. Standard bdsim options can be given to control graphics, animation, runtime etc.
    • run the model using run