Motors for btGeneric6DofConstraint

peltonen
Posts: 18
Joined: Thu Jan 17, 2008 8:16 pm

Motors for btGeneric6DofConstraint

Post by peltonen »

Does anyone have any advice for attaching rotational motors to a btGeneric6DofConstraint?

btHingeContraint has a motor, which serves as a good example (but I don't quite understand the variable m_kHinge).

I am working on applying a torque impulse to both rigid bodies joined by the constraint, but having problems calibrating the amount of torque needed to achieve a desired velocity.

For all objects, I'm using the equation for the moment of inertia of a sphere (i.e. (2.0f / 5.0f) * mass * (distance * distance), where distance equals the distance from the contact point to the object's center of mass). But I'm not sure if this makes sense for objects of arbitrary shape. It's obviously not completely accurate of course, but I don't know if that sort of simplification is acceptable with these types of things.

If not, would people recommend generating a more accurate moment of inertia by iterating over all vertices of a triangle mesh (with mass evenly distributed across all points)? This wouldn't be entirely accurate either, as vertices aren't evenly distributed spatially, but might work better than a simplification like the sphere equation.

Or, more simply, is there already a member variable somewhere that represents this?

In my simulation, objects without outside forces achieve the desired velocity pretty well. With an outside force applied, they will eventually get back to their target velocities once the outside force is gone, but they don't snap back quickly. Their behavior is much more gradual.

It also gets more difficult if objects are attached in a chain.

I'd love to hear from other people who are facing (or have faced) the same issues!
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Re: Motors for btGeneric6DofConstraint

Post by projectileman »

May you should take a more deep revision to the btGeneric6DofConstraint header file.

6DOF constraints have one Rotational Motor configuration per axis, represented by the btRotationalLimitMotor structure.
You can access to each Rotational motor with the getRotationalLimitMotor(int index) function.

There are some aspects to consider when you're configuring these limit motors:
  • You must set m_enableMotor attribute to true.
  • Rotational motors are based on velocities. You must set their velocity parameter in the m_targetVelocity attribute, and the maximum force of the motor with m_maxMotorForce attribute.
  • Also you should configure the rotational limits carefully. Please read the documentation about the angular limits range for each axis in the btGeneric6DofConstraint.h file, line 192. In the most cases, you should leave one axis free (axis X for example) and keep the other (YZ) limited.
peltonen
Posts: 18
Joined: Thu Jan 17, 2008 8:16 pm

Re: Motors for btGeneric6DofConstraint

Post by peltonen »

Thanks, Projectileman,
For some reason I had dismissed the btGeneric6DofConstraint btRotationalLimitMotors early on. After your posting, I checked them out again. I switched over to using them in my project and things are working great now.
Can you explain, though, the difference between m_maxLimitForce and m_maxMotorForce?
Thanks.
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Re: Motors for btGeneric6DofConstraint

Post by projectileman »

Sure.

m_maxLimitForce determines how much torque the constraint applies when its limits are violated, typically its value is very high.

And maxMotorForce is the maximum torque that the Motor applies for mantain the desired velocity, and its value shouldn't be too high.