Linear Motor in Slider unaffacted by MaxLinMotorForce

roy-t
Posts: 3
Joined: Mon May 20, 2013 3:18 pm

Linear Motor in Slider unaffacted by MaxLinMotorForce

Post by roy-t »

Dear Bullet Physics users,

I have the following simulation. The gray leg has an upper leg (dark-gray) and lower leg (light gray) connected by a hinge joint (like a knee, brown). I've connected a body (muscle part as so to speak, in red), using a hinge joint to both of them. Now I've connected the two muscle parts (red) together using a slider joint. The idea is to use the linear motor in the slider joint (blue) to contract and expand the muscle in order to actuate the knee joint.

Image

When the motor is disabled the simulation seems to work fine, the muscles behave as expected and move closer when the knee bends. So I tried enabling the linear motor on the slider joint:

Code: Select all

slider->setPoweredLinMotor(true);
slider->setMaxLinMotorForce(50);
slider->setTargetLinMotorVelocity(-1.0f);	 // negative value to contract


In my dummy simulation (without gravity) this works fine. The knee is slowly actuated and the leg bends. Now when I enable gravity the leg obviously falls over, but it should still be able to contract, given enough force. This is where the weird thing happens. No matter what I set MaxLinMotorForce to the leg will not contract when on the ground. There seems to never be enough force to lift to 'pull the upper leg up'. When the leg is on its side there is enough force to overcome friction and pull very slowly together but the speed of this does not depend on the TargetLinMotorVelocity and the MaxLinMotorForce. (note that I call TargetLinMotorVelocity every frame)

Also setting a TargetLinMotorVelocity of 0.0 doesn't seem to work at all, no matter what the force is the knee still bends quite easily. So, am I missing something here? I tried diving into the source code but there seems to be nothing special concerning the linear motor.

TLDR: how do I make the slider joint LinearMotor more powerful, MaxLinMotorForce doesn't seem to work.


EDIT: the limits seem to affected similarly, when I impose strict limits (to almost freeze the knee) the forces aren't enough to counter outside forces, but in rest it will return to the limits.
roy-t
Posts: 3
Joined: Mon May 20, 2013 3:18 pm

Re: Linear Motor in Slider unaffacted by MaxLinMotorForce

Post by roy-t »

(Reply since I found the bug)

Ok, the problem seems to be 2 fold.

1. My muscle parts had a very low mass (0.001f) which somehow made them behave very differently (for example I couldn't pick the entire creature up by grabbing one of the muscle parts, it would just elastically snap back into place when I released it).

2. The slider joint was connected at the closest tips of the two muscle parts (so with a relative origin of {0, -1, 0} and {0, 1, 0}) using an origin of {0, 0, 0} for both solved the problem.

Anyway these where 2 parts where I didn't expect the bug to be or to look, and I'm still not sure why these 2 combined problems made the motor force inadequate!