Skip to content

Commit

Permalink
fix joint stuck at limit bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ufrhaidar authored Jun 26, 2024
1 parent 47666d6 commit cbcb4e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dart/constraint/JointConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void JointConstraint::update()
const double B1 = A1 + mErrorAllowance;
const double A2 = positions[i] - positionUpperLimits[i];
const double B2 = A2 - mErrorAllowance;
if (B1 < 0) {
if (B1 <= 0) {
// The current position is lower than the lower bound.
//
// pos LB UB
Expand All @@ -234,7 +234,7 @@ void JointConstraint::update()
assert(bouncing_vel >= 0);
bouncing_vel = std::min(bouncing_vel, mMaxErrorReductionVelocity);

mDesiredVelocityChange[i] = bouncing_vel - velocities[i];
mDesiredVelocityChange[i] = bouncing_vel + velocities[i];

// Set the impulse bounds to not to be negative so that the impulse only
// exerted to push the joint toward the positive direction.
Expand All @@ -250,7 +250,7 @@ void JointConstraint::update()

++mDim;
continue;
} else if (0 < B2) {
} else if (0 <= B2) {
// The current position is greater than the upper bound.
//
// LB UB pos
Expand All @@ -271,7 +271,7 @@ void JointConstraint::update()
assert(bouncing_vel <= 0);
bouncing_vel = std::max(bouncing_vel, -mMaxErrorReductionVelocity);

mDesiredVelocityChange[i] = bouncing_vel - velocities[i];
mDesiredVelocityChange[i] = bouncing_vel + velocities[i];

// Set the impulse bounds to not to be positive so that the impulse only
// exerted to push the joint toward the negative direction.
Expand Down

0 comments on commit cbcb4e5

Please sign in to comment.