Hi,
I’m writing an MPC with known external disturbances using JuliaSimControl.
I’m currently passing the known disturbances w as part of the parameter vector into the dynamics function, i.e.
function dynamics(x, u, p, t)
tvec, w = p.t, p.w
i = findfirst(>=(t), tvec)
u_tot = [u[1:nu]; w[:, i]]
# Assumes linear system for simplicity
return A * x + B * u_tot
end
and then p gets updated at every time step.
Now I want to use an EKF for state estimation, and saw the ObserverInput type also has a field w for known disturbances. So know I wonder what the recommended way for passing around known disturbances is in JuliaSimControl?
Any help appreciated 
Hello 
There are currently no observers that have support for the w argument. You could still make use of known external disturbances by performing the steps inside MPC.step! manually, those are
- Run the
correct! step of the observer (measurement update) with u_tot as input (if w is relevant to the measurement update)
- Create the ControllerInput and pass it to
MPC.optimize! using something like this
controllerinput = ControllerInput(MPC.state(prob.observer), prob.xr, w, u)
controlleroutput = optimize!(prob, controllerinput, p, t; kwargs...)
- Run the prediction step (
predict!) of the observer with u_tot as input.
The dynamics that is used in the observer needs to be adapted to accept this larger u as input for this to work.
Does this make sense? It’s on the roadmap to add support for the w argument, but since we use observers from the library LowLevelParticleFilters.jl which do not have this argument, there is some interface work to be done that hasn’t taken place yet.
I think it makes sense, yes. Thank you! If I get stuck I’ll just post again 
In general, fantastic work that you’ve been doing with the control packages in Julia 
1 Like