# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Freeing a rotational axis with a 6DofConstraintPosted: Tue Dec 15, 2009 6:23 am

Joined: Sat Dec 09, 2006 8:10 am
Posts: 13
I am using a Generic6DofConstraint to implement an upright constraint that keeps my (capsule) actors from falling over while they move. I am interested in locking the X and Z axes, Y is up in my case and I want to have that axis free (see below).

Code:
pConstraint->setLimit(0, -SIMD_INFINITY, SIMD_INFINITY);
pConstraint->setLimit(1, -SIMD_INFINITY, SIMD_INFINITY);
pConstraint->setLimit(2, -SIMD_INFINITY, SIMD_INFINITY);
pConstraint->setLimit(3, 0, 0);
pConstraint->setLimit(4, 1, 0);
pConstraint->setLimit(5, 0, 0);

Here I am attempting to limit the Y axis with the documented convention that high < low means that the axis is free. The result is that after the value for Y rotation goes past -pi/2 or +pi/2 (i.e. over 90 degrees to either side), the simulation explodes. Using -SIMD_INFINITY, SIMD_INFINITY as the limits does not help, as they are just normalized to -pi/2, +pi/2 inside btGeneric6DofConstraint::setLimit.

If I constrain the Y axis with the limits 0,0, everything is fine and the axis is locked. However, I need the capsule to be able to pull around another rigid body on the X-Z-plane, and that requires the capsule to be able to spin around the Y axis. The pulling works just fine with a Generic6DofSpringConstraint, the problem is that using these two together (upright + pull), does not work.

Top

 Post subject: Re: Freeing a rotational axis with a 6DofConstraintPosted: Tue Dec 15, 2009 10:49 pm

Joined: Thu Dec 14, 2006 4:27 pm
Posts: 109
Location: Colombia
Take a look into the commented text in btGeneric6DofConstraint.h file at line 222, there specifies the valid angle ranges for rotational constraints. You could only freeing the X rotational axis, and you must keep Y and Z limited with values between (-PI/2 , PI/2) . That's because the complexity of the formulas for getting the Euler rotational angles: there is some value ranges where a gimbal lock could occur.

So you must change the constraint reference frame and setting X as the only free rotational axis by setting LoRange>HiRange.

Top

 Post subject: Re: Freeing a rotational axis with a 6DofConstraintPosted: Tue Jul 27, 2010 4:00 pm

Joined: Fri Mar 20, 2009 3:26 am
Posts: 7
projectileman is quite correct. Using the X axis as the "upright" axis does indeed work, but you need to change the reference frames so that the X axis becomes the world Y axis. Here is the code in our engine that uses this solution:
Code:
_bt_balancer_body = new btRigidBody(
btRigidBody::btRigidBodyConstructionInfo(
0, 0, 0, bt_vector_zero ) );

// must use X axis as Y axis because 6dof wont spin freely on Y
btTransform frameina( btTransform::getIdentity() );
btTransform frameinb( btTransform::getIdentity() );
frameina.getBasis().setEulerZYX( 0, 0, SIMD_HALF_PI );
_bt_balancer_body->getWorldTransform()
.getBasis().setEulerZYX( 0, 0, SIMD_HALF_PI );

btGeneric6DofConstraint * sixdof = new btGeneric6DofConstraint(
*_bt_rigid_body, *_bt_balancer_body,
frameina, frameinb, true ); // use linear reference frame a
sixdof->setLimit( 0, -SIMD_INFINITY, SIMD_INFINITY );
sixdof->setLimit( 1, -SIMD_INFINITY, SIMD_INFINITY );
sixdof->setLimit( 2, -SIMD_INFINITY, SIMD_INFINITY );
sixdof->setLimit( 3, -SIMD_PI, SIMD_PI ); // only x axis can turn freely
sixdof->setLimit( 4, 0, 0 );
sixdof->setLimit( 5, 0, 0 );
_bt_balancer_constraint = sixdof;

Also, Erwin posted viewtopic.php?f=9&t=3369&p=19436#p19436
a far simpler solution using btRigidBody::setAngularFactor.

Code:
btVector3 angularfactor( 0, 1, 0 );
_bt_rigid_body->setAngularFactor( angularfactor );

Nevertheless, the btGeneric6DofConstraint solution is the best for us because our worlds are spherical planets, so the "upright" axis changes as bodies move rather than being fixed to the universal Y axis.

--Christopher

Top

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

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 14 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