Manta object changes position, wheels don't (remote api Matlab)

Typically: "How do I... ", "How can I... " questions
R2D2
Posts: 3
Joined: 08 Jul 2017, 16:22

Manta object changes position, wheels don't (remote api Matlab)

Postby R2D2 » 14 Jul 2017, 19:34

Hello! I try to carry out a simulation with 3 Manta vehicles with data from Matlab. Specifically, for each time instant I specify the position of the vehicles with the command vrep.simxSetObjectPosition, and run the simulation for one time step. Then I pause the simulation and do the same. As it seems the vehicles' bodies do change position as requested, but their wheels don't! They stick to their initial position! Note that when I get the object handle, I do get the whole object ('Manta', 'Manta#0', 'Manta#1'). The script is given below. I need some help, please! Cheers!

Code: Select all

    disp('Program started');
    clc
    close all
    clear all
    load('data.mat');
    vrep=remApi('remoteApi'); % using the prototype file (remoteApiProto.m)
    vrep.simxFinish(-1); % just in case, close all opened connections
    clientID=vrep.simxStart('127.0.0.1',19999,true,true,5000,5);
    vrep.simxPauseSimulation(clientID, vrep.simx_opmode_oneshot);
   
    if (clientID>-1)   
        disp('Connected to remote API server');
 
        [returnCode,agent(1)]=vrep.simxGetObjectHandle(clientID,'Manta', vrep.simx_opmode_oneshot_wait);
        [returnCode,agent(2)]=vrep.simxGetObjectHandle(clientID,'Manta#0', vrep.simx_opmode_blocking);
        [returnCode,agent(3)]=vrep.simxGetObjectHandle(clientID,'Manta#1', vrep.simx_opmode_blocking);
       
        for i=1:tspan(1,2)/0.05
            vrep.simxPauseSimulation(clientID, vrep.simx_opmode_oneshot);
           
            instant=0.05*i;
            [minimum, j]= min(abs(t-instant));
 
            vrep.simxSetObjectPosition(clientID, agent(1), -1, [q(j, 1), q(j, 2), 0.1922]', vrep.simx_opmode_oneshot);
            vrep.simxSetObjectPosition(clientID, agent(2), -1, [q(j, 8), q(j, 9), 0.1922]', vrep.simx_opmode_oneshot);
            vrep.simxSetObjectPosition(clientID, agent(3), -1, [q(j, 15), q(j, 16), 0.1922]', vrep.simx_opmode_oneshot);

            vrep.simxStartSimulation(clientID,vrep.simx_opmode_blocking);
        end
 
        vrep.simxFinish(-1);
    end
    vrep.delete();
    disp('Program Ended');

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

Re: Manta object changes position, wheels don't (remote api Matlab)

Postby coppelia » 16 Jul 2017, 20:16

Hello,

those vehicle models are dynamically enabled. In that case, you should not try to artificially move the vehicle, but rather modify the torque/speed in the wheel joints in order to have the vehicle move. Make sure to read this topic too.

Cheers


Return to “General questions”

Who is online

Users browsing this forum: No registered users and 18 guests