Embedded scripts

V-REP is a highly customizable simulator: almost every step of a simulation is user-defined. This flexibility is allowed through an integrated script interpreter. The scripting language is Lua, which is an extension programming language designed to support general procedural programming. For more information on Lua, refer to the Lua crash course section and the online documentation. By default, V-REP uses the official and original Lua, but if you wish you can tell V-REP to use another flavor of Lua by setting variable useExternalLuaLibrary in system/usrset.txt to true. In that case, all Lua calls are handled via the v_repLua library, which itself will link against LuaJIT (Lua Just-in-Time compiler). The v_repLua library project files are located in programming/v_repLuaLibrary. See here for acknowledgments and credits related to Lua and LuaJIT.

[Lua logo]

V-REP extends Lua's commands and adds V-REP specific commands that can be recognized by their sim-prefixes (e.g. simHandleCollision). For a list of all V-REP specific Lua-commands, refer to the regular API. New, customized Lua-commands can also be registered from the main client application or from a plugin. Refer to the related API-functions for more information.

Lua's functionality itself can easily be extended by making use of a Lua extension library available online.

An embedded script is a script that is embedded in a scene (or model), i.e. a script that is part of the scene and that will be saved and loaded together with the rest of the scene (or model). There are different types of embedded scripts that are supported. Each type has specific features and application areas:

[Embedded script types]

Two major types of embedded scripts are supported:

  • Simulation scripts: simulation scripts are scripts that are executed only during simulation, and that are used to customize a simulation or a simulation model. The main simulation loop is handled via the main script, models/robots are controlled via child scripts, low-level dynamic motor controllers are written via joint control callback scripts, and dynamic collisions can be handled via a contact callback script. General callback scripts are multi-purpose callback scripts.
  • other embedded scripts: those are scripts that can also be executed while simulation is not running, and that are used to customize a simulation scene or the simulator itself. They include customization scripts and a general callback script.

  • Next to embedded scripts, V-REP supports also add-ons, that allow to customize the simulator itself.

    Among the different script types, it can be useful to remember that some are associated with scene objects (attached to scene objects, i.e. associated scripts) such as child scripts, joint control callback scripts and customization scripts, and others are unassociated (i.e. unassociated scripts). Associated scripts, which form the basis of V-REP's distributed control architecture, share the convenient property to be automatically duplicated if their associated object is duplicated.

    Recommended topics

  • Simulation scripts
  • Add-ons
  • Script dialog
  • Script editor
  • Accessing objects programmatically
  • Application Programming Interface