Apply joint torques

jalfonsossm
Posts: 3
Joined: Wed Feb 17, 2010 12:22 pm

Apply joint torques

Post by jalfonsossm »

I am starting study robotics. I worked with ODE, but I want to port my code into Bullet. My question is if I can apply a specific torque at a joint like in ODE ( a need a method like ODE's addTorque(torque) ).

Can I get the same result using bullet constraints motors? I worked with PhysX motors and, since physX motors are pd controllers based on spring-damper system, I don't want to tweak several constants neither work with desired postion nor velocities. I only want to apply the desired torque

Thanks and sorry for my english
User avatar
rponomarev
Posts: 56
Joined: Sat Mar 08, 2008 12:37 am

Re: Apply joint torques

Post by rponomarev »

Hello,

Actually only ODE hinge joint have the addTorque(dReal torque) method.
This method gets hinge axis ant applied torque to both bodies that are connected by hinge.
Some other joints have addTorques(...) methods, specific for each joint

Bullet has no specific function for each joint type, but it has
btRigidBody::applyTorque(btVector3 torque)
method that could be used in a similar way.

For example, if you have a hinge btHingeConstraint* pHinge you may get its axis in world space
and apply a torque T to both bodies:

Code: Select all

btVector3 hingeAxisLocal = pHinge->getAFrame().getBasis().getColumn(2); // z-axis of constraint frame
btVector3 hingeAxisWorld = pHinge->getRigidBodyA().getWorldTransform().getBasis() * hingeAxisLocal;
btVector3 hingeTorque = T * hingeAxisWorld;
pHinge->getRigidBodyA().applyTorque(hingeTorque);
pHinge->getRigidBodyB().applyTorque(-hingeTorque);
Hope this will help,
Roman