i am able to connect and use the api to control the movements of joints and get the handles of the joints.
whenever i try to use the simxCallScriptFunction i get an error in coppeliasim saying that the script does not exists.
This is my code to get the handle for the main object
Code: Select all
[app.youBotHandle, rc] = app.getHandle('youBot');
if rc == app.sim.simx_return_ok
disp('youBot handle retrieved successfully.');
else
disp('Failed to retrieve youBot handle.');
end
Code: Select all
function callYouBotScriptFunction(app)
if app.clientID > -1 && app.youBotHandle > -1
[returnCode, outInts, outFloats, outStrings, outBuffer] = app.sim.simxCallScriptFunction(...
app.clientID, app.youBotHandle, app.sim.sim_scripttype_childscript, ...
'printMessage', [], [], [], [], app.sim.simx_opmode_blocking);
if returnCode == app.sim.simx_return_ok
disp('Successfully called printMessage function using object handle.');
else
disp(['Failed to call printMessage function. Return code: ', num2str(returnCode)]);
end
else
disp('Cannot call script function, handle or connection invalid.');
end
end
Code: Select all
function sysCall_init()
sim = require('sim')
-- do some initialization here
end
function printMessage(inInts, inFloats, inStrings, inBuffer)
sim.addLog(sim.verbosity_scriptinfos, 'Hello from the child script!')
-- You can also return values if needed
return {}, {}, {"Message received and processed."}, ''
end
function sysCall_actuation()
-- put your actuation code here
end
function sysCall_sensing()
-- put your sensing code here
end
function sysCall_cleanup()
-- do some clean-up here
end
-- See the user manual or the available code snippets for additional callback functions and details
and this is the error i am getting in the log of coppeliasim:
"External call to simCallScriptFunction failed('printMessage@youbot'):script does not exist
i dont understand what am i doing wrong.
thanks in advance for your help