Page 1 of 1

Legacy api to zmq api

Posted: 22 Mar 2024, 12:16
by pr2001
Hello guys
I use to have this function to get the joint values in the old api
Right now i am trying to change to the new zmq api but i dont know how to do this part (res ~= obj.vrep.simx_return_ok && res ~= obj.vrep.simx_return_novalue_flag)
I used it to see if everything went well.
Can someone tell me how to do this ?

Complete function:

Code: Select all

function [error,armJoints] = get_joints(obj)
    error = 0;
    for i = 1:obj.number_of_joints
        %Read from joints
        [res,armJoints(i)]=obj.vrep.simxGetJointPosition(obj.clientID, obj.jointHandle{i},obj.vrep.simx_opmode_buffer);
        if (res ~= obj.vrep.simx_return_ok && res ~= obj.vrep.simx_return_novalue_flag)
            disp('ERROR: Failed read Joint value!');
            error = 1;
            return;
        end
    end
end

Re: Legacy api to zmq api

Posted: 26 Mar 2024, 17:12
by coppelia
Hello,

simply this:

Code: Select all

    for i = 1:obj.number_of_joints
        %Read from joints
        armJoints(i) = sim.getJointPosition(obj.jointHandle{i})
    end
Cheers