The main and child scripts

The main script and the child scripts, which are simulation scripts, play the central role in each simulation: while the main script contains the simulation loop code, child scripts contain the typical code to control models (e.g. robots, sensors or actuators).

By default, each scene has a main script that handles all the functionality. Without main script, a simulation cannot run. The main script can be customized, but it is preferable to do all the customization work in a child script.

Each scene object can be associated with a child script that will handle a specific part of a simulation, in an independent and distributed fashion. The most common use for child scripts is to have them control a model.

Following are the main differences between the main script and a child script:

  • there can only be one main script. There can be an unlimited number of child scripts.
  • the main script is independent and should preferably not be customized. Child scripts are associated with scene objects and should be customized.
  • the main script is never duplicated in a copy/paste operation of scene objects. Child scripts will duplicate themselves together with their associated scene object.
  • the main script cannot be threaded. Child scripts can be threaded or non-threaded.
  • child scripts can use special types of system callback functions, such as joint callback functions or a contact callback function.
  • The main script as well as each child script have a list of simulation parameters attached, called script simulation parameters. Those parameters can be used as a quick way of adjusting values of a specific simulation model for example (e.g. the maximum velocity of a mobile robot or the resolution of a sensor).

    Recommended topics

  • The main script
  • Child scripts
  • Script simulation parameters
  • Joint callback functions
  • Contact callback function