Integrating joint velocity to get position

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

Integrating joint velocity to get position

Post by realjsk » 19 Jan 2017, 04:42

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
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: Integrating joint velocity to get position

Post by coppelia » 20 Jan 2017, 09:16

Hello,

try with something like:

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then 
    jointHandle=simGetObjectHandle('myJoint')
    lastTime=0
    jointVelocity=0.1 -- 0.1 rad/sec
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: 13
Joined: 21 Dec 2013, 03:59

Re: Integrating joint velocity to get position

Post by realjsk » 21 Jan 2017, 02:39

It worked. Thank you very much.

Post Reply