mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[glass] Add Profiled PID controller support & IZone Support (#5959)
This commit is contained in:
@@ -29,6 +29,16 @@ void glass::DisplayPIDController(PIDControllerModel* m) {
|
||||
callback(*v);
|
||||
}
|
||||
};
|
||||
// Workaround to allow for the input of inf, -inf, and nan
|
||||
auto createTuningParameterNoFilter =
|
||||
[flag](const char* name, double* v,
|
||||
std::function<void(double)> callback) {
|
||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
|
||||
if (ImGui::InputScalar(name, ImGuiDataType_Double, v, NULL, NULL,
|
||||
"%.3f", flag)) {
|
||||
callback(*v);
|
||||
}
|
||||
};
|
||||
|
||||
if (auto p = m->GetPData()) {
|
||||
double value = p->GetValue();
|
||||
@@ -47,6 +57,11 @@ void glass::DisplayPIDController(PIDControllerModel* m) {
|
||||
createTuningParameter("Setpoint", &value,
|
||||
[=](auto v) { m->SetSetpoint(v); });
|
||||
}
|
||||
if (auto s = m->GetIZoneData()) {
|
||||
double value = s->GetValue();
|
||||
createTuningParameterNoFilter("IZone", &value,
|
||||
[=](auto v) { m->SetIZone(v); });
|
||||
}
|
||||
} else {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
|
||||
ImGui::Text("Unknown PID Controller");
|
||||
|
||||
Reference in New Issue
Block a user