How to actuate a joint by using Matlab

Typically: "How do I... ", "How can I... " questions
Nana
Posts: 9
Joined: 22 Nov 2016, 11:16

How to actuate a joint by using Matlab

Postby Nana » 22 Nov 2016, 12:39

Hello,

I'm trying to simulate a humanoid robot model in VREP with Matlab using the remote API. I've succeeded in the communication between VREP and Matlab by using the function vrep.simxStart and I've got the handle of all the joints of the robot by using vrep.simxGetObjectHandle. Right now I'm faced with some problems when I attempted to actuate the revolute joints.

I tried to actuate the joint by using the function simxSetJointPosition but it failed to move. Could you please help me find out the possible causes?

Nana
Posts: 9
Joined: 22 Nov 2016, 11:16

Re: How to actuate a joint by using Matlab

Postby Nana » 22 Nov 2016, 23:48

Besides, when I tried to get the position of the joints, it shows always 43 for all the joints.

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

Re: How to actuate a joint by using Matlab

Postby coppelia » 23 Nov 2016, 10:10

Hello,

what code do you use to set the joint position? What are the function arguments?
Also, if your joints are in force/torque mode, with controller enabled, then you should rather use simxSetJointTargetPosition.

Cheers

Nana
Posts: 9
Joined: 22 Nov 2016, 11:16

Re: How to actuate a joint by using Matlab

Postby Nana » 23 Nov 2016, 15:48

Thank you very much! I have succeeded in setting the target position of the joint but I just couldn't get their real-time positions with the function simxGetJointPosition() . I think I've misunderstood the function, if so, what is the function I can use to get the real-time position of the joint?

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

Re: How to actuate a joint by using Matlab

Postby coppelia » 25 Nov 2016, 09:16

Please again, show us the code you are using and tell you what it returns or what the effect is.

Cheers

Nana
Posts: 9
Joined: 22 Nov 2016, 11:16

Re: How to actuate a joint by using Matlab

Postby Nana » 26 Nov 2016, 22:14

%get the handle of the head and the elbow
[returnCode0,handleH1]=vrep.simxGetObjectHandle(clientID,'H_PAN_H_ROLL_joint',vrep.simx_opmode_blocking);
[returnCode10,handleRA4]=vrep.simxGetObjectHandle(clientID,'R_SHR_R_EB_joint',vrep.simx_opmode_blocking);
%get the instant position of the head and the elbow
[returnCode14,position0]=vrep.simxGetJointPosition(clientID,handleH1,vrep.simx_opmode_streaming);
[returnCode12,position1]=vrep.simxGetJointPosition(clientID,handleRA4,vrep.simx_opmode_buffer);
%set a target position for the head and the elbow
[returnCode11]=vrep.simxSetJointTargetPosition(clientID,handleH1,+15,vrep.simx_opmode_streaming);
[returnCode15]=vrep.simxSetJointTargetPosition(clientID,handleRA4,0,vrep.simx_opmode_streaming);

pause(1);
%get the new angles after change
[returnCode14,position3]=vrep.simxGetJointPosition(clientID,handleH1,vrep.simx_opmode_buffer);
[returnCode16,position4]=vrep.simxGetJointPosition(clientID,handleRA4,vrep.simx_opmode_buffer);

Nana
Posts: 9
Joined: 22 Nov 2016, 11:16

Re: How to actuate a joint by using Matlab

Postby Nana » 26 Nov 2016, 22:57

the result is:
first angle of the head is 43
first angle of the elbow is 43
second angle of the head is 2.618865e-01
second angle of the elbow is 43

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

Re: How to actuate a joint by using Matlab

Postby coppelia » 29 Nov 2016, 09:17

You are not correctly using the streaming mode. You can't just assume that the data has already arrived once you have enabled streaming. The data will take a few ms before it arrives on the client side. Make sure you carefully read and understand the way the remote API and data streaming works.

Cheers

Nana
Posts: 9
Joined: 22 Nov 2016, 11:16

Re: How to actuate a joint by using Matlab

Postby Nana » 29 Nov 2016, 09:55

Thank you very much! I have figured it out.

Roios
Posts: 1
Joined: 06 Oct 2016, 10:05

Re: How to actuate a joint by using Matlab

Postby Roios » 14 Jul 2017, 13:25

Any solution?
I continue to get only the 43 value...


Return to “General questions”

Who is online

Users browsing this forum: ag_raed, atom, Google [Bot] and 7 guests