I want to perform low-level control of joints in C++. The input for the controller, which was written in C++, is the subtraction between the joint’s target position and its current position (similar to the inData.error in sysCall_joint). Therefore, I intend to use simIK.findConfig (which I’ve implemented in a function named IKconfig) to obtain the target configuration. Additionally, I plan to use simxCallScriptFunction in C++ to receive the return value from simIK.findConfig. To ensure that simIK.findConfig runs correctly, I initially attempted to invoke it in CoppeliaSim.
Here are the steps I followed:
In sysCall_init(), I created the IK Environment and Group, and added an IK element using simIK.addIkElementFromScene.
In sysCall_actuation(), I invoked the IKconfig function (simIK.findConfig).
However, I encountered the following error: “in sim.genericFunctionHandler: Found invalid joint handle.”
I am certain that the joint handle is valid because, after encountering the error, I attempted to use the same joint handle to execute functions like sim.getJointVelocity, and the results were normal.
Could you please explain why this error occurs and provide guidance on how to resolve it?
The definition of the IKconfig function is as follows:
Code: Select all
function IKconfig()
jointPositions = simIK.findConfig(ikEnv,ikGroup,simJoints,0.1,0.5,{1,1,1,0.1},nil,nil)
return jointPositions
end