Apply torque with JointMotor

Post Reply
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Apply torque with JointMotor

Post by benelot » Sun Oct 04, 2015 10:37 am

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?

Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Apply torque with JointMotor

Post by Basroil » Sun Oct 04, 2015 2:24 pm

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).

benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Apply torque with JointMotor

Post by benelot » Tue Oct 06, 2015 4:29 am

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.

Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Apply torque with JointMotor

Post by Basroil » Tue Oct 06, 2015 4:43 am

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")

usamarafiq93
Posts: 4
Joined: Mon Jun 10, 2019 3:46 pm

Re: Apply torque with JointMotor

Post by usamarafiq93 » 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.

User avatar
xissburg
Posts: 46
Joined: Sat May 19, 2007 9:28 pm

Re: Apply torque with JointMotor

Post by xissburg » Thu Jul 04, 2019 4:56 pm

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.

Post Reply