Trouble interfacing Matlab and V-rep successfully

Typically: "How do I... ", "How can I... " questions
Post Reply
Posts: 3
Joined: 20 Oct 2018, 03:09

Trouble interfacing Matlab and V-rep successfully

Post by bjsp33 » 23 Oct 2018, 17:52

For my Term project, I must successfully simulate an application of my choice using both Matlab and V-rep.

I have never used V-rep before so I am still learning by watching youtube tutorials, etc.

For my application, I have chosen to have Baxter "paint" a block by moving the left arm around the block. I have disabled every script except for the non-threaded child script which i added to the scene, and added the command "simRemoteApi.start(19999)" to the script to be able to connect V-rep and Matlab. The connection is successful and have even ran the test provided by V-rep called "simple test" to verify.

I have written some code to try and move one of Baxter's joints and it will not move in V-rep no matter what i change. I have successfully completed other tutorials on youtube such as the "turtlebot" and have referenced that when making my code and i am failing. I am not sure what is wrong with what I'm doing. Any help is appreciated.

% Run just once in a child script of a vrep scene just once
% simRemoteApi.start(19999)

vrep=remApi('remoteApi') ; % creates a remote api object and calls it vrep

vrep.simxFinish(-1); %closes any currently open connections

clientID=vrep.simxStart('',19999,true,true,5000,5); %cretes a connection in a specifc port

% if no connection established -1 if greater than connection succesful

% if connection succesful

if (clientID>-1)

disp('Connected to remote API server');

% Handles

[returnCode,joint1]= vrep.simxGetObjectHandle(clientID,'Baxter_leftArm_joint1',vrep.simx_opmode_blocking) ;
%[returnCode,joint2]= vrep.simxGetObjectHandle(clientID,'Baxter_leftArm_joint2',vrep.simx_opmode_blocking) ;
%[returnCode,joint3]= vrep.simxGetObjectHandle(clientID,'Baxter_leftArm_joint3',vrep.simx_opmode_blocking) ;

% [returnCode,joint4]= vrep.simxGetObjectHandle(clientID,'Baxter_leftArm_joint4',vrep.simx_opmode_blocking) ;
% [returnCode,joint5]= vrep.simxGetObjectHandle(clientID,'Baxter_leftArm_joint5',vrep.simx_opmode_blocking) ;
% [returnCode,joint6]= vrep.simxGetObjectHandle(clientID,'Baxter_leftArm_joint6',vrep.simx_opmode_blocking) ;
% [returnCode,joint7]= vrep.simxGetObjectHandle(clientID,'Baxter_leftArm_joint7',vrep.simx_opmode_blocking) ;

%Other code

[returnCode]= vrep.simxSetJointTargetVelocity(clientID,joint1,5,vrep.simx_opmode_blocking) ;
[returnCode]= vrep.simxSetJointTargetVelocity(clientID,joint1,0,vrep.simx_opmode_blocking) ;

vrep.simxFinish(-1); %closes any currently open connections


%calls the destructor

Posts: 3
Joined: 11 Oct 2018, 17:50

Re: Trouble interfacing Matlab and V-rep successfully

Post by amunishk » 02 Nov 2018, 07:02

Have you enabled the joint you wish to control?

If not, then click joint and click on "scene object properties > show dynamic properties dialog" and click on (1) motor enabled and (2) control loop enabled. Their defaults should work. "scene object properties" is located towards the left side usually.

Post Reply