Page 1 of 1

Apply torque with JointMotor

Posted: Sun Oct 04, 2015 10:37 am
by benelot
Hello,

I am trying to port some functionality from my btMultiBody implementation to my RigidBody and JointConstraint implementation since not everything is implemented in the btMultiBody yet. In btMultiBody I can apply torque at a certain joint, but in the JointConstraints I can only use the motors and run it with maxTorque and a desired velocity. Can I somehow apply torque at the joints the same as in btMultiBody?

Re: Apply torque with JointMotor

Posted: Sun Oct 04, 2015 2:24 pm
by Basroil
One easy way is to just set the torque to be the torque (impulse) you want, and then have the desired velocity be a large number in the direction of that torque. As long as you never exceed that large velocity, the joint will end up (after costing a few cpu cycles) with the same result as if you put a torque on each body at the joint location.

Just remember that it's not very computationally friendly, but the answer should be the same (though not necessarily identical).

Re: Apply torque with JointMotor

Posted: Tue Oct 06, 2015 4:29 am
by benelot
So there is really no other way to apply the torque (impulse) directly? That is a bit inconsistent in API. Especially for torque driven robots, you do not want that torque ramp-up that bullet is probably doing when increasing towards maxtorque. But ok, then I have to cope with that. Unfortunate, but I will find a way.Thanks for your answer.

Re: Apply torque with JointMotor

Posted: Tue Oct 06, 2015 4:43 am
by Basroil
benelot wrote:So there is really no other way to apply the torque (impulse) directly? That is a bit inconsistent in API. Especially for torque driven robots, you do not want that torque ramp-up that bullet is probably doing when increasing towards maxtorque. But ok, then I have to cope with that. Unfortunate, but I will find a way.Thanks for your answer.
What torque ramp-up?

I've been able to get pretty much accurate motors simulation (~0.004 rad for motors with 12bit feedback that has 0.0015 error by itself and another ~0.001-6 rad error from latency variability) using that (and applying torques to each body directly), haven't seen any ramp-up outside that which I put in myself (since motors always have a "ramp-up")

Re: Apply torque with JointMotor

Posted: Wed Jul 03, 2019 3:21 pm
by usamarafiq93
Hi,
I have been trying to measure the applied torque through getJointTorque (int dof) and its returning zero.

Re: Apply torque with JointMotor

Posted: Thu Jul 04, 2019 4:56 pm
by xissburg
usamarafiq93 wrote: Wed Jul 03, 2019 3:21 pm Hi,
I have been trying to measure the applied torque through getJointTorque (int dof) and its returning zero.
I guess what you want is btMultiBodyConstraint::getAppliedImpulse(int dof). btMultiBody::getJointTorque(int i) is the external torque applied by the user.