#146 Patch to fix problem with limit and angle wrapping

Bug Fix (53)
Remi Ricard


This patch is here for review.
If no one complains about problem I will patch the code.

  • Patch to fix the wrapping and limit problem for the
  • Other joint with rotoide motor will be fixed lated.

  • Rename testRotationalLimit to testLimit

  • Create new function testRotationalLimit which handle
    angle wrapping correctly.

  • dxJointSlider::getInfo1 use testLimit

- Where should the assignment of prevAngle occur to be
only done when necessary
- Now it is always done in getInfo1 even if not needed.
- Should be done in:
- dJointSetParam when param is the loStop or
hiStop and in getInfo2 if limit exits.



  • Remi Ricard

    Remi Ricard - 2008-11-21

    Patch to fix limit problem when angles are wrapping

  • Daniel K. O.

    Daniel K. O. - 2008-12-21

    Shouldn't the universal and hinge2 joints use the "rotational" test limit?

  • Nobody/Anonymous

    Hi Danilel,

    Yes every joint with a rotoide part should test their rotational limit.

    I did only some joint to get some feedback about the way it is done.

    Since I did not have any feedback I'm assuming this is a good way to go so I will update the patch to include the other joints when I will have time.


  • Daniel K. O.

    Daniel K. O. - 2008-12-22

    It's not clear to me what the comparisons between "diff" and "(rate*stepsize)" are doing. It seems they should at least include some epsilon tolerance.

    It might not be robust enough to trust the current angle rate to estimate how it moved from "prevAngle" to the current angle. This rate could have changed by the user, or by damping. The "rate" should be the one that produced the actual rotation (that is, the actual angular displacement), obtainned inside dxStepBody (right after the angular velocity cap).

  • vlat

    vlat - 2010-03-20

    changes in joint.cpp in below function for corection lostop and histop limits and do not create new function, only fix small bug

    int dxJointLimitMotor::testRotationalLimit (dReal angle)
    if (angle <= lostop) {
    limit = 1;
    limit_err = angle - lostop;
    limit = 2;
    limit_err = (angle-lostop)+2*M_PI;

    return 1;
    else if (angle >= histop) {
    limit = 2;
    limit_err = angle - histop;
    limit = 1;
    limit_err = (angle - histop)-2*M_PI;
    return 1;
    else {
    limit = 0;
    return 0;
    lostop and histop must be -pi to pi
    It is necessary for correct change lostop and histop limits in significances near -pi and pi


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks