
Add-ons
An add-on in V-REP is quite similar to a plugin:
it is automatically loaded at program start-up, and allows V-REP's
functionality to be extended by user-written functionality or
functions. Add-on scripts are written in Lua. Two types of add-ons are supported:
Add-on functions: add-on functions appear
first in the add-on menu. They can be seen as functions that will be
executed once, when selected by the user. Importers and exporters can
conveniently be implemented with them.
Add-on scripts: add-on scripts are executed
constantly while the simulator is running, effectively running in the
background. They should only execute minimalistic code everytime they
are called, since the whole application would otherwise slow down.
Add-on scripts are called differently depending on the simulation state:
When simulation is not running (i.e. stopped or paused): add-on scripts are called just before visualization of the scene
When simulation running: add-on scripts are called just after the main script was called
Add-on functions should be written in a text file located in the
same folder as the main application, with following naming convention:
vrepAddOnFunc_xxxx.lua, where xxxx can be any string representing the name of an add-on function.
vrepAddOnScript_xxxx.lua, where xxxx can be any
string representing the name of the add-on script. The add-on script
will be automatically started. Selecting it in the add-on menu allows
pausing its execution.
vrepAddOnScript-xxxx.lua, where xxxx can be any
string representing the name of the add-on script. The add-on script
will not be automatically started. The user can start it when required
by selecting it in the add-on menu.
Add-ons can call any of the regular API functions, as long as not stated otherwise in the documentation. They can even call custom Lua functions registered by plugins. They however have two restrictions:
Add-ons cannot call API functions that require the caller to run in
a thread. This is because add-ons operate in a non-threaded fashion.
While simulation is not running, add-ons should not call API functions that make sense only when simulation is running.
For more information on add-ons, make sure to inspect the content of the demo add-ons vrepAddOnScript-addOnScriptDemo.lua and vrepAddOnFunc-addOnFunctionDemo.lua, located in the installation folder.
Recommended topics
Lua
Plugins
Regular API functions
|