Page 1 of 1

simSetJointTargetVelocity doesn't work the second time

Posted: 02 Apr 2013, 15:58
by geerten
Hi,

It appears to me that simSetJointTargetVelocity is not working correctly..
The first time I use it in a script it works fine, but when a condition changes, I want to change the velocity again, and then it doesn't work..

Code: Select all

if(active == 1) then
	simSetJointTargetVelocity(simGetObjectAssociatedWithScript(sim_handle_self),-0.4)
else
	simSetJointTargetVelocity(simGetObjectAssociatedWithScript(sim_handle_self),0)
end
Is this a bug, or am I doing something wrong?

Re: simSetJointTargetVelocity doesn't work the second time

Posted: 02 Apr 2013, 16:09
by coppelia
Hello Geerten,

What mode is your joint in? Probably in force/torque mode, with the motor enabled AND the position control disabled.
In that case, the joint will try to reach the specified velocity, given the max. torque it can exert. If the max. torque is too small, the velocity will never be reached. Also, if you specify a velocity of 0, it will simply disable the motor, and slowly slow down (it slows down much faster if the max. torque specified is high). This is specific to the physics engines.

When the joint is in velocity mode, it is not regulated! (unlike the PID position control)

Cheers

Re: simSetJointTargetVelocity doesn't work the second time

Posted: 02 Apr 2013, 16:14
by geerten
It is indeed in force/torque mode, with the motor enabled AND the position control disabled.

So how can I then switch between a velocity of 0 and non-zero (using Bullet)?

Re: simSetJointTargetVelocity doesn't work the second time

Posted: 02 Apr 2013, 16:16
by geerten
I notice now that if I set the target velocity through scripting first to zero, then to -8, it ends up at 0.45 (as I can see in the dynamics dialog that I leave open)..

Re: simSetJointTargetVelocity doesn't work the second time

Posted: 02 Apr 2013, 16:33
by coppelia
The units of the API are always specified in radians, meters, seconds, etc.

The user interface might display the target velocity value as degrees/s, depending on your settings.

We tested, and it works fine. You must have a bug in your code somewhere, or strange settings.

Cheers

Re: simSetJointTargetVelocity doesn't work the second time

Posted: 03 Apr 2013, 07:48
by geerten
Ah, indeed, that was the problem. The radians and degrees conversion threw me off, it works now!