## Integrating joint velocity to get position

Typically: "How do I... ", "How can I... " questions
realjsk
Posts: 19
Joined: 21 Dec 2013, 03:59

### Integrating joint velocity to get position

I know the desired velocity of a revolute joint configured in passive mode. Since I can only set the position value of such a joint, I was wondering if their is a way to integrate the known desired velocity over time to a position value. I don't like to configure the joint in force/torque mode so that I don't have to deal with the control side (among other reasons). Thank you.

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

### Re: Integrating joint velocity to get position

Hello,

try with something like:

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then
jointHandle=simGetObjectHandle('myJoint')
lastTime=0
end

if (sim_call_type==sim_childscriptcall_actuation) then
local t=simGetSimulationTime()
local dt=t-lastTime
lastTime=t
local pos=simGetJointPosition(jointHandle)
pos=pos+dt*jointVelocity
simSetJointPosition(jointHandle,pos)
end 
Cheers

realjsk
Posts: 19
Joined: 21 Dec 2013, 03:59

### Re: Integrating joint velocity to get position

It worked. Thank you very much.