Open ghost opened 10 years ago
This would be a welcome addition, I have been trying to give it a shot, but don't quite understand the communication happening between the two currently.
@jaredmoore do you have a working example of getting the angle out of Ammo?
No I do not have an example getting the Hinge angle yet. There is a call in Bullet, that I'm pretty sure is also in Ammo though I have yet to test it. Should know more later this week.
Chandler, I was recently at the ALIFE 2014 conference and spoke with a few other researchers in the evolutionary robotics community. We would really like to use Physijs for our online work, but not having the ability to define the angle to move a hinge towards limits the usefulness of the simulation.
I'm currently trying to track down what code would be needed. The relevant call in Bullet would be the following lines:
btScalar btHingeConstraint::getHingeAngle() { return getHingeAngle(m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform()); }
btScalar btHingeConstraint::getHingeAngle(const btTransform& transA,const btTransform& transB) { const btVector3 refAxis0 = transA.getBasis() * m_rbAFrame.getBasis().getColumn(0); const btVector3 refAxis1 = transA.getBasis() * m_rbAFrame.getBasis().getColumn(1); const btVector3 swingAxis = transB.getBasis() * m_rbBFrame.getBasis().getColumn(1); // btScalar angle = btAtan2Fast(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1)); btScalar angle = btAtan2(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1)); return m_referenceSign * angle; }
in the ammo.js/blob/master/bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp file. This is from the ammo.js distribution.
To make the call in ammo.js is simply the following:
hinge_constraint.getHingeAngle()
I attempted to solve this myself a few months ago, but got sidetracked and cannot locate the code. Do you have any idea on how best to implement this? If I remember correctly, I was getting hung up on the worker communication aspect.
For displacement command of robotic joints, I think the call would best look something like:
hinge_constraint.get_angle() which would return the angle between the two bodies. It's really a simple call, but I'm not sure on the implementation in this system.
If you have any other questions, feel free to ask me.
Sorry about the delay in replying. Most of my github notifications started going to gmail's promotions tab for some reason so I wasn't seeing them. I'll try to find some time to look at making the constraint info accessible. If you have or can put together an example of all you need/want from Ammo itself I can quickly transfer it from the worker.
Chandler, no problem. Really the only thing that needs to be called is something like the following:
hinge_constraint.getHingeAngle()
getHingeAngle() is already in Ammo and returns the angle for a given hinge_constraint. The only thing I haven't been able to figure out is how to pass that back from the worker to the main program. I have an example that's a little convoluted, it's a full hillclimbing evolutionary environment, but all you really need is that one call. I can make it available if you want through email.
Thanks again!
A function to obtain the "current" angle of a hinge constraint would be nice. This is already in Bullet, so it should already be exposed by ammo.js.