[glass] Add Profiled PID controller support & IZone Support (#5959)

This commit is contained in:
m10653
2023-12-22 14:29:25 -05:00
committed by GitHub
parent bcef6c5398
commit 43fb6e9f87
11 changed files with 303 additions and 2 deletions

View File

@@ -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");