Motor control with remote API

Typically: "How do I... ", "How can I... " questions
Post Reply
Kabuska
Posts: 1
Joined: 08 May 2018, 22:13

Motor control with remote API

Post by Kabuska » 14 May 2018, 19:46

Hello, I am new at V-REP. I have a problem about controling pioneer p3dx with matlab.
I'm working with pioneer p3dx. I want to control it with remote API ( matlab ). I designed a map with some obstacles in V-REP. I'm taking a picture when simulation start and sending it to Matlab. Matlab is creating path using Breadth First Algoritm. Everything is working well until this point. When I use 'simxSetJointPosition' code it just doesn't work. wheels are not turning. I couldn't understand my fault. It could be very simple but as I said I'm new at V-REP.
P.S. Motors are working Force/Torque Mode. In matlab I see returnCode 0.
Here is my simulation link: https://www.dropbox.com/s/i0npo07olb2l3 ... p.ttt?dl=0
And here is my Matlab code for movement:

Code: Select all

vrep=remApi('remoteApi');
vrep.simxFinish(-1);
 
clientID=vrep.simxStart('127.0.0.1',19999,true,true,5000,5);
 
   if (clientID>-1)
       disp('Connected')
       
            [returnCode,sol_teker]=vrep.simxGetObjectHandle(clientID,'Pioneer_p3dx_leftMotor',vrep.simx_opmode_oneshot_wait); 
            [returnCode,sag_teker]=vrep.simxGetObjectHandle(clientID,'Pioneer_p3dx_rightMotor',vrep.simx_opmode_oneshot_wait);
       
      for i=1:500
            
            i
            [returnCode]=vrep.simxSetJointPosition(clientID,sol_teker,i*pi,vrep.simx_opmode_oneshot)
            i
            
            pause
            
      end
           
    end
   
    vrep.delete();
Best regards.

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

Re: Motor control with remote API

Post by coppelia » 15 May 2018, 08:36

Hello,

if your joints are dynamically enabled, then you can't use sim.setJointPosition. You can only use sim.setJointTargetVelocity (if your joint has the motor enabled but the controller disabled), or sim.setJointTargetPosition (if your joint has the motor enabled and the controller enabled too).

Cheers

Post Reply