Skip to content

Commit

Permalink
ignore velocity limits for servo motor
Browse files Browse the repository at this point in the history
  • Loading branch information
ufrhaidar authored Jun 27, 2024
1 parent 8911246 commit a18343a
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions dart/constraint/JointConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,42 +289,45 @@ void JointConstraint::update()
continue;
}

// Check lower velocity bound
const double vel_lb = std::max(velocityLowerLimits[i], vel_to_pos_lb);
const double vel_lb_error = velocities[i] - vel_lb;
if (vel_lb_error < 0.0) {
mDesiredVelocityChange[i] = -vel_lb_error;
mImpulseLowerBound[i] = 0.0;
mImpulseUpperBound[i] = static_cast<double>(dInfinity);

if (mActive[i]) {
++(mLifeTime[i]);
} else {
mActive[i] = true;
mLifeTime[i] = 0;
// Ignore for Servo motor
if (mJoint->getActuatorType() != dynamics::Joint::SERVO) {
// Check lower velocity bound
const double vel_lb = std::max(velocityLowerLimits[i], vel_to_pos_lb);
const double vel_lb_error = velocities[i] - vel_lb;
if (vel_lb_error < 0.0) {
mDesiredVelocityChange[i] = -vel_lb_error;
mImpulseLowerBound[i] = 0.0;
mImpulseUpperBound[i] = static_cast<double>(dInfinity);

if (mActive[i]) {
++(mLifeTime[i]);
} else {
mActive[i] = true;
mLifeTime[i] = 0;
}

++mDim;
continue;
}

++mDim;
continue;
}

// Check upper velocity bound
const double vel_ub = std::min(velocityUpperLimits[i], vel_to_pos_ub);
const double vel_ub_error = velocities[i] - vel_ub;
if (vel_ub_error > 0.0) {
mDesiredVelocityChange[i] = -vel_ub_error;
mImpulseLowerBound[i] = -static_cast<double>(dInfinity);
mImpulseUpperBound[i] = 0.0;

if (mActive[i]) {
++(mLifeTime[i]);
} else {
mActive[i] = true;
mLifeTime[i] = 0;
// Check upper velocity bound
const double vel_ub = std::min(velocityUpperLimits[i], vel_to_pos_ub);
const double vel_ub_error = velocities[i] - vel_ub;
if (vel_ub_error > 0.0) {
mDesiredVelocityChange[i] = -vel_ub_error;
mImpulseLowerBound[i] = -static_cast<double>(dInfinity);
mImpulseUpperBound[i] = 0.0;

if (mActive[i]) {
++(mLifeTime[i]);
} else {
mActive[i] = true;
mLifeTime[i] = 0;
}

++mDim;
continue;
}

++mDim;
continue;
}
}

Expand Down

0 comments on commit a18343a

Please sign in to comment.