VREP with Matlab simxSetJointTargetPostion

Report crashes, strange behaviour, or apparent bugs
Post Reply
leoaran
Posts: 3
Joined: 08 May 2014, 08:37

VREP with Matlab simxSetJointTargetPostion

Post by leoaran »

I have configured a V-REP simulation with joints configured in Torque/Force mode. If a press the start button at the simulation interface, the simulation works as expected, even if a change the TargetPostion value for a given joint, which makes the robot move to a given target position. Dynamic contens does not rise any error, so I would presume that the configuration is correct.

If I try to remotely control the robot from Matlab (R2013b x64) using Remote API (remoteApi.so for 64-bits) connection is successfully stablished and handles to the joints return a valid number, even I can start and stop the simulation properly in synchronous mode. However, I am having troubles with simxSetJointTargetPostion function, because the simulation ignores it and the joint doesn't change its target position. I have also tried non-synchronous modes, a simulation witout dynamic contens (joints configured in passive mode) and the funcion simxSetJointPosition instead of simxSetJointTargetPosition, but the result is the same, the call is simply ignored. The return error code is 1, which I think is normal if a call the functions with simx_opmode_oneshot.

I post here my code:
-------------------------------------------------

Code: Select all

vrep=remApi('remoteApi');
vrep.simxFinish(-1); % just in case, close all opened connections
clientID=vrep.simxStart('127.0.0.1',19997,true,true,5000,5);

try
    if (clientID>-1)
        vrep.simxSynchronous(clientID,1); %%Enables synchronous mode
        vrep.simxStartSimulation(clientID,vrep.simx_opmode_oneshot);
        disp('Connected to remote API server');  
        qLID=zeros(12,1);
        for i=1:6
            str=sprintf('%s%d','joint',i);
            [~,qLID(i)]=vrep.simxGetObjectHandle(clientID,str,vrep.simx_opmode_oneshot_wait);
        end
        for i=1:6
            str=sprintf('%s%d','joint',13-i);
            [~,qLID(i+6)]=vrep.simxGetObjectHandle(clientID,str,vrep.simx_opmode_oneshot_wait);
        end  
        qL=zeros(12,1);
        for i=1:12
            qL(i)=30*pi/180;
        end
        %Now run the simulation a given number of iterations
        for k=1:30
            vrep.simxPauseCommunication(clientID,1);
            for i=1:length(qL)
                ret=vrep.simxSetJointTargetPosition(clientID,qLID(i),qL(i),vrep.simx_opmode_oneshot);
            end
            vrep.simxPauseCommunication(clientID,0);
            vrep.simxSynchronousTrigger(clientID);
        end
        vrep.simxStopSimulation(clientID,vrep.simx_opmode_oneshot);
        pause(1);
        vrep.simxFinish(clientID);
    else
        disp('Failed connecting to remote API server');
    end
    vrep.delete(); % call the destructor!
catch err
    vrep.simxFinish(clientID); % close the line if still open
    vrep.delete(); % call the destructor!
end;
disp('Program ended');
------------------------------------------
The output I get is:

Running Matlab glnxa64
make sure you use the corresponding remoteApi library
(i.e. 32bit Matlab will not work with 64bit remoteApi, and vice-versa)
Connected to remote API server
Program ended

Variable qLID is:
qLID =

56
57
58
59
60
61
67
66
65
64
63
62

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

Re: VREP with Matlab simxSetJointTargetPostion

Post by coppelia »

Hello,

before going further into this, what V-REP version are you using?
There was indeed a problem with some funtions with Matlab 64bit, prior to V-REP 3.1.1
The very last version of the remote API (that corrects for a few other bugs too) can be found here.

Cheers

leoaran
Posts: 3
Joined: 08 May 2014, 08:37

Re: VREP with Matlab simxSetJointTargetPostion

Post by leoaran »

I was using V-REP_PRO_EDU_V3_1_0_64_Linux, so after your post I have updated to V-REP_PRO_EDU_V3_1_1_64_Linux, but still the same.

Regards,

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

Re: VREP with Matlab simxSetJointTargetPostion

Post by coppelia »

Make sure you also use the updated files indicated here for your remote API client.

Cheers

leoaran
Posts: 3
Joined: 08 May 2014, 08:37

Re: VREP with Matlab simxSetJointTargetPostion

Post by leoaran »

Thanks a lot, now it works, but I think only after I have remove the default Main script and created a new one.

Regards.

Post Reply