Velocity on MATLAB

Typically: "How do I... ", "How can I... " questions
Post Reply
STata
Posts: 12
Joined: 19 Feb 2016, 23:02

Velocity on MATLAB

Post by STata » 22 Feb 2016, 14:32

Dear all,

Is it possible to directly get joint velocity from VREP using MATLAB Api??.

Thanks,

Shravan

coppelia
Site Admin
Posts: 7445
Joined: 14 Dec 2012, 00:25

Re: Velocity on MATLAB

Post by coppelia » 22 Feb 2016, 17:25

Hello,

you cannot directly do that. But what you can do is something like:

Code: Select all

[ret, retInts, retFloats, retStrings, retBuff]=vrep.simxCallScriptFunction(clientId,"objectName",vrep.sim_scripttype_childscript,"getJointVelocity",[],[],['jointName'],[],operationMode);
velocity=retFloats(1);
Then, in your scene, create a non-threaded child script that you attach to object objectName and put following function at the top of the script:

Code: Select all

getJointVelocity=function(inInts,inFloats,inStrings,inBuffer)
    local jointHandle=inFloats[1]
    local res,v=simGetObjectFloatParameter(jointHandle,sim_jointfloatparam_velocity)
    return {},{v},{},''
end
What will basically happen: the remote API client will remotely call script function getJointVelocity, which will execute the command and return the desired value. This approach can basically be used for all commands that are not directly supported on the client side.

Make sure you have the last V-REP release (V3.3.0), otherwise you won't have that functionality.

Cheers

Post Reply