Simulation scripts

Simulation scripts are embedded scripts that are only executed while a simulation is running. There are four types of simulation scripts:

[Simulation script types]

  • The main script: by default, each scene has a main script that handles all the functionality (that is is charge of calling the other types of simulation scripts). 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 (see hereafter).
  • Child scripts: each scene object can be associated with a child script that will handle a specific part of a simulation. One particularity of them is that they can also run threaded (which is not the case with any other script types). The most common use for child scripts is to have them control a model (e.g. a robot).
  • The contact callback script: each scene can have a contact callback script that will be in charge of handling dynamic contacts (e.g. deciding whether two entities should react to collision or not). The contact callback script is however rarely used and not directly recommended, since it slows down the simulation pace, and renders a simulation scene potentially incompatible with existing simulation models.
  • Joint control callback scripts: each joint object can be associated with a joint control callback script that will be in charge of performing custom low-level joint dynamic control (e.g. by implementing a custom position controller for instance). This task could also be handled via a child script, but not in such a precise manner since the dynamic loop can run several times in each simulation step (and thus joint control callback scripts can be running several times per simulation step, which is not the case with child scripts).
  • Since child scripts and joint control callback scripts are attached to scene objects (i.e. they are associated scripts), they will also be duplicated during a copy-and-paste operation, which is an important feature that allows a simulation scene to be easily scalable. Associated scripts form the basis of V-REP's distributed control architecture.

    Recommended topics

  • The main script
  • Child scripts
  • The contact callback script
  • Joint control callback scripts
  • Accessing objects programmatically