servo implementation tips?

User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

servo implementation tips?

Post by ejtttje »

I want to implement a PID (and/or just proportional) motor controller to simulate the servos on a robot. Looking at how the motor on the hinge constraint is implemented, it seems I should just call applyTorqueImpulse on each of the connected bodies for each simulation step.

However, I feel I am missing a bit of physics understanding, or else some simulation simplifications are at play—doesn't the location of the torque matter? If the hinge is not aligned with the center of mass of each of the bodies, then there's a force component. At infinite distance between the hinge and CoM, a body receives a "pure" central impulse; as the torque axis approaches the center of mass, then it becomes a pure torque instead.

I'm afraid I don't understanding how to implement this, or why bullet there's no "non-central" torque impulse function. Is there a trick in that by applying opposite torque impulses to each of the bodies, the hinge constraint itself transforms the appropriate amount of angular momentum to linear momentum such that the resultant motion is as expected?

thanks...
User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

Re: servo implementation tips?

Post by ejtttje »

*bump* I'm still interested in a response.
I've gotten things basically working by just using applyTorqueImpulse, but is there a better way? Should there be a version of applyTorquImpulse which takes a location as well as axis?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: servo implementation tips?

Post by Erwin Coumans »

There are motors implemented in several constraints (6DOF etc), those are recommended over directly applying impulses.

Have you checked the Bullet/Demos/ConstraintDemo and Bullet/Demos/ForkLiftDemo?
Hope this helps,
Erwin
User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

Re: servo implementation tips?

Post by ejtttje »

Erwin Coumans wrote:There are motors implemented in several constraints (6DOF etc), those are recommended over directly applying impulses.
Yeah, I've played with that as well. I might switch over to it since it takes the object mass/inertia into account so I don't have to tweak my controller parameters for each object.

But on the other hand, I'm trying to simulate a robot, so there is some value in trying to reimplement the servo's controller and then I can use the same controller parameters in the simulation as on the robot and hopefully things will move similarly after a bit of calibration for the servo's torque and such. My robot can dynamically adjust the servo controller parameters, so it would be nice if the servo simulation was doing the same thing.

I also do a bit of manual physics calculation in my robot code to predict joint loads and compensate for dynamics, so if my physics understanding is off I'd appreciate the education :)