## Using script function of LUA on MATLAB

Typically: "How do I... ", "How can I... " questions
Jinhyeok
Posts: 4
Joined: 29 May 2019, 16:53

### Using script function of LUA on MATLAB

Hello, I'm Jinhyeok. For now, I'm trying to make a time delay control for a manipulator with Matlab external API.
To do this, I felt that I need to know about joint velocity and acceleration.

According to previous FAQs, I could find some references.
> http://forum.coppeliarobotics.com/v ... php?t=5031
According to this link, I need to use vrep.simxCallScriptFunction but Matlab returns that string cannot be changed to int8 type.
matlab code

Code: Select all

[ret, retInts, retFloats, retStrings, retBuff]=vrep.simxCallScriptFunction(clientID,"Cuboid",vrep.sim_scripttype_childscript,'getJointVelocity',[],[],[actuator_3],[],vrep.simx_opmode_blocking);

LUA code for the non-threaded code of Cuboid

Code: Select all

function getJointVelocity(inInts,inFloats,inStrings,inBuffer)
local jointHandle=inFloats[1]
local
res,v=simGetObjectFloatParameter(jointHandle,sim_jointfloatparam_velocity)
return {},{v},{},''
end

I corrected my code as above.
After some corrections of my Matlab codes, it seemed that the type of
"Cuboid" is what matters.

Since I'm new to V-REP and the syntax of LUA, my question would sound strange.

And there's one more question. Is it effective to use LUA script to implement some control code on 5R manipulator rather using MATLAB external API?
Thanks in advance and sorry for unarranged question. :)
> PS) My version of MATLAB is R2018a and the version of V-REP is 3.6.1.

coppelia
Posts: 7909
Joined: 14 Dec 2012, 00:25

### Re: Using script function of LUA on MATLAB

Hello,

did you try with 'Cuboid' instead of "Cuboid"?

About your second question: with Lua code (or with C code inside of a V-REP plugin) you can run commands synchronously, without any communication overhead. With the remote API however, there is communication overhead, which tends to drastically slow down things if you have frequent function calls that need to travel to V-REP, execute something there, and return a reply.

Cheers

Jinhyeok
Posts: 4
Joined: 29 May 2019, 16:53