## Problems reading revolute joints from MATLAB

Typically: "How do I... ", "How can I... " questions
altella
Posts: 11
Joined: 04 Jun 2019, 14:01

### Problems reading revolute joints from MATLAB

Hello all,

I am completely new to VREP, and my first project is the control of an Inverted pendulum from Matlab, implementing a PID controller.
I have borrowed the scenario from :
https://github.com/RyoheiGoto/inverted_pendulum

As you can see, there is a Joint called "Potentiometer" which is accesed from the code to get its value and control the pendulum.
With the simulation paused from the beginning if you select that joint, you can see:

Code: Select all

Joint (revolute, p=+000.00)
Orientation: a:+090.00 b:+000.00 g:-000.00
However, when I try to access its value from MATLAB with the instructions:

Code: Select all

[res, Potentiometer] = vrep.simxGetObjectHandle(clientID, 'Potentiometer', vrep.simx_opmode_blocking);
[res, theta] = vrep.simxGetJointPosition(clientID, Potentiometer, vrep.simx_opmode_oneshot)
I obtain res = 1, theta = 43.

Which is a nonsense value for me. I later use this theta for the PID, but I cannot control the system given this value. I expected to get a value near 0....

Could anyone give a clue about what is wrong here? I am a newbie, and cannot see where the fault is.

Thank you very much in advance,
Alberto

coppelia
Posts: 7396
Joined: 14 Dec 2012, 00:25

### Re: Problems reading revolute joints from MATLAB

Hello,

why are you using the operation mode simx_opmode_oneshot? You want to retrieve a value. Not send a value. You need to use simx_opmode_blocking. Or you can stream that value, which will be faster once activated.

Cheers

altella
Posts: 11
Joined: 04 Jun 2019, 14:01

### Re: Problems reading revolute joints from MATLAB

Ok, thanks a lot !
That was the trick...yesterday I didn´t realize it for several hours...