# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: computing work done by a btGeneric6DofConstraint?Posted: Wed Feb 08, 2012 6:47 pm

Joined: Fri Dec 17, 2010 12:26 am
Posts: 5
I'm trying to compute the total work done by a btGeneric6DofConstraint in the last timestep. Has anyone figured out how to do this?

I am using Bullet to evolve neural controllers for simulated robots. The robot legs are powered by btGeneric6DofConstraint joints (I'm only using the btRotationalLimitMotor part). I will make the evolutionary fitness consider the total work done by all the legs. (This will make the running more natural.)

I think I would understand how to do this with btRotationalLimitMotor::solveAngularLimits(). (There you can get the impulse that is actually applied. So if you just get the angle it's applied over, I think you can compute the work.)

However, looks like solveAngularLimits() is now obsolete - it is not called anywhere in the bullet libraries. There is a function btTypedConstraint::getAppliedImpulse(), but this returns a scalar. Work = distance * impulse (both are vectors) / time, so a scalar is not enough.

Has anybody else computed total work done by a rotational motor, or have any tips where I should try to get the work, or the impulse & angle traveled? E.g., a hint like "the best place to get both is after the total impulse is computed in function XYZ".

Thanks!

P.S. Here are some videos of the evolved robots, you may recognize the body model from one of the Bullet demos called MotorDemo. http://youtube.com/geccospider

Top

 Posted: Thu Feb 09, 2012 2:15 am

Joined: Sun Jan 01, 2012 7:37 pm
Posts: 55
Wait, are you doing evolutionary neural networks that are connected to sensors and emitters?

This is really cool

Top

 Posted: Fri Feb 10, 2012 7:41 pm

Joined: Fri Dec 17, 2010 12:26 am
Posts: 5
Sensors and effectors, yeah... thanks! Bullet is very good for evolutionary robotics.

Wonder if anyone else has some tips on computing the total work done by a rotational motor. I set the m_targetVelocity of the rotational motor, and at some point this gets converted to a torque, can anyone explain how/where? (That's the point where I might be able to put a callback or something to accumulate the total work.)

I believe the next place the m_targetVelocity pops up is in btGeneric6DofConstraint::get_limit_motor_info2(). Here an m_constraintError is computed from it... but at that point I lose it. Where does the m_constraintError get converted into an actual torque that is applied? I imagine somewhere the constraint errors are all resolved...?

Thanks for any explanation or help!

Cheers,

Mike

Top

 Posted: Mon Feb 13, 2012 11:37 pm

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3746
Location: California, USA
The constraint solver internally updates the m_accumulatedImpulse for each constraint row.

This is not properly updated in this function:
btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyFinish( ... )
So perhaps there is a better way to provide the constraint feedback.

You might be able to run the 'obsolete' code path (check out m_useSolveConstraintObsolete) and use the applied impulses as part of each limit/motor.

Hope this helps,
Erwin

Top

 Posted: Thu May 03, 2012 8:27 am

Joined: Mon Apr 23, 2012 2:57 pm
Posts: 2
Hi,

I am also interested in this topic. I tried to implement a torque sensor on a hinge constraint and a generic 6 dof constraint. I tried to get the obsolete code path to work on a generic 6 dof constraint as proposed by Erwin. I set the flag D6_USE_OBSOLETE_METHOD in btGeneric6DofConstraint.cpp with is used to initialize m_useSolveConstraintObsolete. But if I run my code now, there is an other problem: The first segment of my robot arm is attached to the world frame

Code:
hingeGen1 = new btGeneric6DofConstraint(*upperArmRB, trans, false);
hingeGen1->setAngularLowerLimit(btVector3(0,0,-3.14));
hingeGen1->setAngularUpperLimit(btVector3(0,0,3.14));
hingeGen1->setLinearLowerLimit(btVector3(0,0,0));
hingeGen1->setLinearUpperLimit(btVector3(0,0,0));
hingeGen1->enableFeedback(true);
mot1 = hingeGen1->getRotationalLimitMotor(2);

The second constraint is set up between this segment and the other segment

Code:
hingeGen2 = new btGeneric6DofConstraint(*upperArmRB, *lowerArmRB, transA, transB, true);
hingeGen2->setAngularLowerLimit(btVector3(0,0,-3.14));
hingeGen2->setAngularUpperLimit(btVector3(0,0,3.14));
hingeGen2->setLinearLowerLimit(btVector3(0,0,0));
hingeGen2->setLinearUpperLimit(btVector3(0,0,0));
hingeGen2->enableFeedback(true);
mot2 = hingeGen2->getRotationalLimitMotor(2);

But unfortunately the the second constraint seems to be ignored by the solver. The second segment starts to move down (due to gravity) immediately. This does only happen if the obsolete code path is used. I checked the enabled-flag and the constraint seems not to be disabled or broken.

Does the obsolete code path still works in Bullet? What can I do to get this to work and obtain correct values for torques / impulse applied by one rotational motor only? Currently I am using Bullet 2.79.

Greetings,
anyway

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 5 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 3 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities