Regular API function

simRegisterJointCtrlCallback

Description Registers or unregisters a joint control callback function for customized joint control handling. Several plugins can register a callback, and the callbacks will be cascaded if not interrupted.
C synopsis simInt simRegisterJointCtrlCallback(simInt(*callBack)(simInt,simInt,simInt,const simInt*,const simFloat*,simFloat*))
C parameters
callback address. Specify the function you wish to register/unregister as callback. When the function is already registered, it will be unregistered. Following describes the callback's arguments:

first argument (int): handle of the joint
second argument (int): the selected physics engine
third argument (int): a version indicator. Zero for now.

The forth, fifth and sixth arguments are allocated by V-REP. Arguments 4 and 5 describe the joint state, argument 6 are the callback return values:

forth argument (const int*)
[0] bit-coded:
1=this callback is called for the first time (if the joint is dynamically reset during the simulation, this might be true more often)
2=the joint is revolute
4=the joint is cyclic (has no limits)
[1] the current dynamics calculation pass. 0-9 by default. See next item for details
[2] the number of dynamics calculation passes for each "regular" simulation pass. 10 by default (i.e. 10*5ms=50ms which is the default simulation time step)
Fifth argument (const float*)
[0] the current position of the joint
[1] the desired position of the joint
[2] error: targetPos-currentPos (with revolute cyclic joints we take the shortest cyclic distance)
[3] the last force or torque that acted on this joint along/around its axis. With Bullet, torques from joint limits are not taken into account
[4] the step size used for the dynamics calculations (by default 5ms)
[5] the joint lower limit
[6] the joint upper limit
[7] the joint target velocity (as set in the user interface)
[8] the joint maximum force/torque (as set in the user interface)
[9] the joint velocity upper limit (as set in the user interface)
Sixth argument (float*). If you want to control the joint from your callback, you need to set those values.
[0] the maximum force/torque that the joint will be able to exert
[1] the velocity to apply to the joint

The callback return value can be:
-1: the callback doesn't handle the joint and hands it to the next callback. If no callback handles it, the default joint controller handling routine is used (or the joint control callback script is called, if enabled)
0: the joint is free (no force/torque is applied)
>0: the values of above's 6th argument will be applied to the joint (the default values (or the joint control callback script) are overridden)
C return value
-1 if operation was not successful. 0 if the callback was unregistered, 1 if the callback was registered
Lua synopsis -
Lua parameters
-
Lua return values
-

All regular API functions on one page