# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: btRotationalLimitMotor lockPosted: Mon May 03, 2010 10:56 pm

Joined: Mon May 03, 2010 10:38 pm
Posts: 1
Hello!

I recently started using bullet and I find it very useful, thanks for your hard work!
However, I've been struggling the last days trying to simulate some kind of servo motor. After lots of tests involving different constraints with different parameters, I decided to settle with a locked btGeneric6DofConstraint by changing the locked range every time the motor needs to move. This worked fairly well, but when the motor went over PI or under -PI, it turned along the longest arc path to reach the new locking position.
Luckly the btRotationalLimitMotor code was very easy to understand, and I made the following changes to btRotationalLimitMotor::testLimitValue (added lines preceded with ++):

Code:
if (test_value < m_loLimit)
{
m_currentLimit = 1;//low limit violation
m_currentLimitError =  test_value - m_loLimit;
++       if(m_currentLimitError>SIMD_PI) m_currentLimitError-=SIMD_2_PI;
++       else if(m_currentLimitError<-SIMD_PI) m_currentLimitError+=SIMD_2_PI;
return 1;
}
else if (test_value> m_hiLimit)
{
m_currentLimit = 2;//High limit violation
m_currentLimitError = test_value - m_hiLimit;
++      if(m_currentLimitError>SIMD_PI) m_currentLimitError-=SIMD_2_PI;
++      else if(m_currentLimitError<-SIMD_PI) m_currentLimitError+=SIMD_2_PI;
return 2;
};

It works as I want, however, I'm wondering if I've broken some other expected behavior by manipulating the limit error this way.
Does somebody knows what could go wrong with change?

Top

 Post subject: Re: btRotationalLimitMotor lockPosted: Tue May 04, 2010 2:24 am

Joined: Tue Mar 16, 2010 1:42 am
Posts: 57
I think the 6Dof constraint has problems in general with rotations beyond a hemisphere or so from rest. Its calculateAngleInfo() computes a constraint coordinate system in such a way that effectively wraps around or flips an axis when one basis is rotated more than +-90 degrees from the other.

Mathematically, the vector resulting from the cross product of the Z and X axes of basis A and B respectively flips direction when the angle between them changes from positive to negative, or from less than 180 degrees to more than 180 degrees.

The effect in the simulation can be like the rotation hitting a hard stop and bouncing back.

---JvdL---

Top

 Post subject: Re: btRotationalLimitMotor lockPosted: Fri Feb 17, 2012 4:59 pm

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 456
I know that this thread is nearly two years old, but I just wanted to say that I've found the code modification zlash posted very useful when locking a btRotationalLimitMotor that was free to rotate around one axis.
Please see http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4457 for further info on how to unlock an axis (it seems to work with the X or Z axis free (which is better?), since the Y axis must always be in [-SIMD_HALF_PI,SIMD_HALF_PI] ).

Basically in this context this fix was very useful for me: although a 6DofConstraint with a free rotational axis can rotate seamlessly when a motor with a target velocity is applied without zlash fix, I've found out that problems may arise when we want to "lock" the free rotational axis in one position without this fix. So basically AFAIK this fix makes a "seamless lock" possible on such an axis (and prevents situations in which the locked axis (m_loLimit=m_hiLimit=m_currentPosition, m_motorEnabled=false) instead of being locked starts spinning like crazy).

I don't know if it breaks something (I've not seen any difference so far), but I think that all the people working with a 6DofConstraint with a free rotational axis should try it.

And I wanted to thank zlash for the fix (I've tried to achieve the same without modifying the Bullet source code with no luck).

Top

 Post subject: Re: btRotationalLimitMotor lockPosted: Sat Feb 18, 2012 9:12 am

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 4054
Location: California, USA
Good point. I'll apply the fix in the Bullet source tree.

Thanks!
Erwin

Top

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

 All times are UTC

#### Who is online

Users browsing this forum: Baidu [Spider], 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