mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[wpimath] Add constraints support to ProfiledPIDController Sendable implementation (#6354)
This commit is contained in:
@@ -444,6 +444,18 @@ public class ProfiledPIDController implements Sendable {
|
||||
MathSharedStore.reportError("IZone must be a non-negative number!", e.getStackTrace());
|
||||
}
|
||||
});
|
||||
builder.addDoubleProperty(
|
||||
"maxVelocity",
|
||||
() -> getConstraints().maxVelocity,
|
||||
maxVelocity ->
|
||||
setConstraints(
|
||||
new TrapezoidProfile.Constraints(maxVelocity, getConstraints().maxAcceleration)));
|
||||
builder.addDoubleProperty(
|
||||
"maxAcceleration",
|
||||
() -> getConstraints().maxAcceleration,
|
||||
maxAcceleration ->
|
||||
setConstraints(
|
||||
new TrapezoidProfile.Constraints(getConstraints().maxVelocity, maxAcceleration)));
|
||||
builder.addDoubleProperty("goal", () -> getGoal().position, this::setGoal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,19 @@ class ProfiledPIDController
|
||||
builder.AddDoubleProperty(
|
||||
"izone", [this] { return GetIZone(); },
|
||||
[this](double value) { SetIZone(value); });
|
||||
builder.AddDoubleProperty(
|
||||
"maxVelocity", [this] { return GetConstraints().maxVelocity.value(); },
|
||||
[this](double value) {
|
||||
SetConstraints(
|
||||
Constraints{Velocity_t{value}, GetConstraints().maxAcceleration});
|
||||
});
|
||||
builder.AddDoubleProperty(
|
||||
"maxAcceleration",
|
||||
[this] { return GetConstraints().maxAcceleration.value(); },
|
||||
[this](double value) {
|
||||
SetConstraints(
|
||||
Constraints{GetConstraints().maxVelocity, Acceleration_t{value}});
|
||||
});
|
||||
builder.AddDoubleProperty(
|
||||
"goal", [this] { return GetGoal().position.value(); },
|
||||
[this](double value) { SetGoal(Distance_t{value}); });
|
||||
|
||||
Reference in New Issue
Block a user