General callback script

The general callback script, disabled by default, can be enabled via the environment dialog. When enabled, then specific callback calls, that originate from a plugin for instance, can be intercepted: a function call to simHandleGeneralCallbackScript will end-up in the general callback script, where appropriate measures can be taken depending on the sim_callback_id value. The general callback script can also contain functions that can be accessed via simCallScriptFunctionEx, or simxCallScriptFunction.

Following represents a typical general callback script (variables sim_callback_id and sim_callback_tag are handed over by the system):

if sim_callback_id==sim_callbackid_dynstep then
    -- This is called at the beginning or end of
    -- an individual dynamics simulation step (by
    -- default, there are 10 times more dynamics
    -- simulation steps as simulation steps)
    if sim_callback_tag==0 then
        -- at the beginning of a dynamics step

    if sim_callback_tag==1 then
        -- at the end of a dynamics step

    return 0

if sim_callback_id==sim_callbackid_userdefined+42 then
    -- This is a user defined callback. User defined
    -- callbacks start at ID sim_callbackid_userdefined upwards.
    return 1

Recommended topics

  • General callback IDs