Motor doesn't wake up rigid body

Post Reply
dikobraz
Posts: 8
Joined: Thu Feb 19, 2009 3:01 pm

Motor doesn't wake up rigid body

Post by dikobraz »

I was trying to implement some kind of robotic control system and noticed strange behaviour of btRotationalLimitMotor. I use btRotationalLimitMotor in the following way to produce the attached video:

btRotationalLimitMotor* motor = contraint->getRotationalLimitMotor(0); // constraint is btGeneric6DOFConstraint
motor->m_maxMotorForce = 10.0f;
motor->m_targetVelocity = 10.0f;
motor->m_enableMotor = true;

// And to bend cone in the opposite direction:
motor->m_maxMotorForce = 10.0f;
motor->m_targetVelocity = -10.0f;
motor->m_enableMotor = true;

But after some time motor stops affecting cone until the impulse is applied onto it. At first, I decided that the rigid body falls asleep, so I set up the DISABLE_DEACTIVATION flag, but it doesn't help. Now I apply impulse onto rigid body every time I want my motor get working. I assume it is not the best solution. Have I missed something?

Video: http://www.youtube.com/watch?v=lm5lfKz_EKo
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway
Contact:

Re: Motor doesn't wake up rigid body

Post by ola »

I wasn't able to see from your video if the rigid body really goes to sleep. Maybe you can implement the color of the body to change as a function of the activation state, like in the Bullet demos?

In my code I disable deactivation using
body->setActivationState(DISABLE_DEACTIVATION);

Not really solving your issue, but as a tip, you can use body->activate() to wake it up instead of applying an impulse. If activate() doesn't work then the problem might be with the constraint somehow.

Ola
dikobraz
Posts: 8
Joined: Thu Feb 19, 2009 3:01 pm

Re: Motor doesn't wake up rigid body

Post by dikobraz »

ola wrote:I wasn't able to see from your video if the rigid body really goes to sleep. Maybe you can implement the color of the body to change as a function of the activation state, like in the Bullet demos?

In my code I disable deactivation using
body->setActivationState(DISABLE_DEACTIVATION);

Not really solving your issue, but as a tip, you can use body->activate() to wake it up instead of applying an impulse. If activate() doesn't work then the problem might be with the constraint somehow.

Ola
It doesn't goes asleep, because i've set up DISABLE_DEACTIVATION flag for all rigid bodies. I assume the problem is somewhere else.
chucksspencer
Posts: 35
Joined: Wed Jun 25, 2008 2:52 pm

Re: Motor doesn't wake up rigid body

Post by chucksspencer »

I've been experiencing the same issue. I've tried both setting the DISABLE_DEACTIVATION activation state and calling the activate() method on the rigid bodies, to no avail. I think the hinge constraint may not suffer from this problem. Anyone gotten anywhere on this?
mepster
Posts: 5
Joined: Fri Dec 17, 2010 12:26 am

Re: Motor doesn't wake up rigid body

Post by mepster »

I think I am getting this same thing too.

I am using the "TestRig" modified from one of the bullet demos. The one called AppMotorDemo (in Xcode) or "Dynamic Control Demo" (in the glut menu of all the different demos).

The original demo uses a btHingeConstraint on each joint of each leg. I changed it to a btGeneric6DofConstraint, and I think I am having the same problem described here.

One clue: the "test rigs", that look like little spiders, have 6 legs. Only some of the legs suffer from the problem! (I.e., legs 1 and 4, when you start numbering at 0). If you change to 8 legs, ALL eight suffer from the problem. If you change to 4 legs, NONE of them have the problem. With 5 legs, ONE has the problem. With 3 legs, TWO have the problem. Very strange.

The problem manifests as follows: spawn 1 test rig (modified with btGeneric6DofConstraint instead of btHingeConstraint) with bFixed = true. All legs work (lift up and down) for a while. The "problem" legs move jerkily, then stop moving. If you disturb them (in the DemoApplication you can pull them, or shoot blocks at them), they start working for a few moments, but then become jerky, and then stop again.

I also tried DISABLE_DEACTIVATION, doesn't help.

I tried rotating the rigs about Y slightly when spawned - no effect.

Setting m_maxMotorForce very high doesn't help.
mepster
Posts: 5
Joined: Fri Dec 17, 2010 12:26 am

Re: Motor doesn't wake up rigid body

Post by mepster »

I think there is some low threshold, if the m_targetVelocity is too low, no impulse at all is applied.

If I scale up the m_targetVelocity high enough, all legs move properly; if I scale it down enough, all legs go limp as in my previous post. Somewhere in the middle, some legs work & some go limp.

Not sure why this varies for different legs. For some reason, I think some of the legs are above/below the threshold. It is not related to their orientation in space (the 6 legs project out from the center of the body in the X-Z plane like spokes on a wheel, and it you rotate the whole body, the same numbered legs are good/bad). I think it is the order they were created, possibly.

That would also match the observation that if you bounce the legs around (hitting them with something), they do work for a while.

Also, I can confirm that if I switch everything back to a btHingeConstraint, the bug disappears (as another poster mentioned)... unfortunately I need 2 DOF joints! :-(
dikobraz
Posts: 8
Joined: Thu Feb 19, 2009 3:01 pm

Re: Motor doesn't wake up rigid body

Post by dikobraz »

mepster wrote:I think there is some low threshold, if the m_targetVelocity is too low, no impulse at all is applied.

If I scale up the m_targetVelocity high enough, all legs move properly; if I scale it down enough, all legs go limp as in my previous post. Somewhere in the middle, some legs work & some go limp.

Not sure why this varies for different legs. For some reason, I think some of the legs are above/below the threshold. It is not related to their orientation in space (the 6 legs project out from the center of the body in the X-Z plane like spokes on a wheel, and it you rotate the whole body, the same numbered legs are good/bad). I think it is the order they were created, possibly.

That would also match the observation that if you bounce the legs around (hitting them with something), they do work for a while.

Also, I can confirm that if I switch everything back to a btHingeConstraint, the bug disappears (as another poster mentioned)... unfortunately I need 2 DOF joints! :-(
I experienced some other problems using btRotationalLimitMotor. I dropped using it and implemented simple actuator, it suits me enough, may be it will help you: http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=6264
Post Reply