-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing tests #40
Comments
My bad, I missed it. I was comparing with the tests I had locally, that tested the entire trajectory: y = clamp.(sin.(sol.t), y_min, y_max)
@test sol[sat.y] ≈ y rtol = 1e-6 so this is another case where a thorough test has been replaced by a test that could pass with arbitrarily poor result of the simulation. The current test of the PID controller is simply @test sol[ref.output.u - plant.output.u][end] ≈ 0 atol=1e-3 # zero control error after 100s which could easily pass if the entire solution was just zeros. Compare with the previous tests # linearity in u_r
controller, sys, sol1 = solve_with_input(u_r=sin(t), u_y=0)
controller, sys, sol2 = solve_with_input(u_r=2sin(t), u_y=0)
@test sum(abs, sol1[controller.ea]) < eps() # This is the acutator model error due to saturation
@test 2sol1[controller.y] ≈ sol2[controller.y] rtol=1e-3 # linearity in u_r
# linearity in u_y
controller, sys, sol1 = solve_with_input(u_y=sin(t), u_r=0)
controller, sys, sol2 = solve_with_input(u_y=2sin(t), u_r=0)
@test sum(abs, sol1[controller.ea]) < eps() # This is the acutator model error due to saturation
@test 2sol1[controller.y] ≈ sol2[controller.y] rtol=1e-3 # linearity in u_y
# zero error
controller, sys, sol1 = solve_with_input(u_y=sin(t), u_r=sin(t))
@test sum(abs, sol1[controller.y]) ≈ 0 atol=sqrt(eps())
# test saturation
controller, sys, sol1 = solve_with_input(; u_r=10sin(t), u_y=0,
controller = PID(; k, Ti, Td, wp, wd=0, Ni, Nd, y_max=10, y_min=-10, name=:controller)
)
@test extrema(sol1[controller.y]) == (-10, 10)
# test P set-point weighting
controller, sys, sol1 = solve_with_input(; u_r=sin(t), u_y=0,
controller = PID(; k, Ti, Td, wp=0, wd, Ni, Nd, y_max, y_min, name=:controller)
)
@test sum(abs, sol1[controller.ep]) ≈ 0 atol=sqrt(eps())
# test D set-point weighting
controller, sys, sol1 = solve_with_input(; u_r=sin(t), u_y=0,
controller = PID(; k, Ti, Td, wp, wd=0, Ni, Nd, y_max, y_min, name=:controller)
)
@test sum(abs, sol1[controller.ed]) ≈ 0 atol=sqrt(eps())
# zero integral gain
controller, sys, sol1 = solve_with_input(; u_r=sin(t), u_y=0,
controller = PID(; k, Ti=false, Td, wp, wd, Ni, Nd, y_max, y_min, name=:controller)
)
@test isapprox(sum(abs, sol1[controller.I.y]), 0, atol=sqrt(eps())) This issue can remain open until we have reasonable tests for all components where the tests verify all properties of the solution that we are expecting to hold. |
Yeah the PI, PID, LimPI, LimPID tests are very simple for now. However, the Limiter test is as extensive as I think it can get:
|
|
@baggepinnen can this be closed? |
Looks nice, thanks for the effort :) |
I noticed that there are still some tests missing since the recent refactor
Saturation
, nowLimiter
are missing.SlewRateLimiter
does not test that the slew rate of a signal is limited.LimPID
are deactivated. I tried to update this one but could no longer easily follow the signal in the PID controller. Explanation below.The previous implementation of the
PID
controllerhas been replaced by
which in my opinion totally obfuscates what is going on. The trivial blocks likely exists in modelica stdlib and simulink because they may be useful when building models graphically, they may not be the best choice to implement systems in code. The new implementation requires a block diagram to follow and I would suggest we opt for an implementation style that is slightly easier to maintain.
The text was updated successfully, but these errors were encountered: