Apologies if I'm missing something obvious - learning the relevant math along with the library and that leads
to some embarrassing confusion sometimes:
I'm using setMotorTarget() to manipulate some hinge joints and in a desire to better understand what's going
on under the hood I was looking at its source and am confused about something. Ultimately, what it seems to
do is set the angular velocity for the hinge. But what throws me is that it sets the velocity to the total distance
required per time step.
Here is the relevant code from void btHingeConstraint::setMotorTarget(btScalar targetAngle, btScalar dt):
btScalar curAngle = getHingeAngle(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform());
btScalar dAngle = targetAngle - curAngle;
m_motorTargetVelocity = dAngle / dt;
dt = delta Time since last step (at least that's what the examples I have found pass in)
My question is: if the motor's velocity is getting set to the total distance per delta time then why isn't the motor just instantly jumping to the target angle? I tried to follow m_motorTargetVelocity
to see where it was being used but ended up in the weeds and thought I'd try asking before I go back in there.
[SOLVED]Beginner Q re parameters to setMotorTarget()
-
- Posts: 6
- Joined: Sat Nov 30, 2013 9:31 am
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Beginner Q re parameters to setMotorTarget()
AFAIR (from some year ago... ):
Nope, the motor's target velocity is getting set. Bullet does not set it instantly, but sets some force that is based on the MaxMotorForce every timestep to try to get to it.mscottveach wrote:My question is: if the motor's velocity is getting set to the total distance per delta time...
-
- Posts: 6
- Joined: Sat Nov 30, 2013 9:31 am
Re: Beginner Q re parameters to setMotorTarget()
Aha...thank you! So funny, it's obvious now but for some reason I was reading that
variable name as meaning "motor velocity to reach target" not "target velocity for
motor"... thanks!
variable name as meaning "motor velocity to reach target" not "target velocity for
motor"... thanks!