simSetJointTargetVelocity doesn't work the second time

Report crashes, strange behaviour, or apparent bugs
Post Reply
geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

simSetJointTargetVelocity doesn't work the second time

Post 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?

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

Re: simSetJointTargetVelocity doesn't work the second time

Post 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

geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

Re: simSetJointTargetVelocity doesn't work the second time

Post 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)?

geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

Re: simSetJointTargetVelocity doesn't work the second time

Post 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)..

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

Re: simSetJointTargetVelocity doesn't work the second time

Post 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

geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

Re: simSetJointTargetVelocity doesn't work the second time

Post by geerten »

Ah, indeed, that was the problem. The radians and degrees conversion threw me off, it works now!

Post Reply