Patch to fix limit problem when angles are wrapping
Hi,
This patch is here for review.
If no one complains about problem I will patch the code.
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
Question:
- 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
Shouldn't the universal and hinge2 joints use the "rotational" test limit?
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.
Remi
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).
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;
if(limit_err<-M_PI)
{
limit = 2;
limit_err = (angle-lostop)+2*M_PI;
}
return 1;
}
else if (angle >= histop) {
limit = 2;
limit_err = angle - histop;
if(limit_err>M_PI)
{
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