-
Notifications
You must be signed in to change notification settings - Fork 85
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
More LQG updates #467
Closed
Closed
More LQG updates #467
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b11ee26
merge
baggepinnen 799251b
pick some
baggepinnen 0c58595
throw away some comments
baggepinnen 188e33b
clarify what controller is
baggepinnen 30a05a3
simplify handling of Fr Fy
baggepinnen 6789ea0
refactor and add some tests
baggepinnen 9eb1a6f
add some model augmentation
baggepinnen 7f7d269
cp
baggepinnen 797b85b
resolve
baggepinnen 6f77a5d
bugfix in model augmentation
baggepinnen 65db880
rm infile tests
baggepinnen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" | ||
add_disturbance(sys::AbstractStateSpace{Continuous}, Ad::AbstractMatrix, Cd::AbstractMatrix) | ||
|
||
See CCS pp. 144 | ||
|
||
# Arguments: | ||
- `sys`: System to augment | ||
- `Ad`: The dynamics of the disturbance | ||
- `Cd`: How the disturbance states affect the states of `sys`. This matrix as the shape (sys.nx, size(Ad, 1)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This matrix has the shape... |
||
|
||
See also `add_low_frequency_disturbance, add_resonant_disturbance` | ||
""" | ||
function add_disturbance(sys::AbstractStateSpace{Continuous}, Ad::AbstractMatrix, Cd::AbstractMatrix) | ||
A,B,C,D = ControlSystems.ssdata(sys) | ||
T = eltype(A) | ||
nx,nu,ny = sys.nx,sys.nu,sys.ny | ||
Ae = [A Cd; zeros(T, size(Ad, 1), nx) Ad] | ||
Be = [B; zeros(T, size(Ad, 1), nu)] | ||
Ce = [C zeros(T, ny, size(Ad, 1))] | ||
De = D | ||
ss(Ae,Be,Ce,De) | ||
end | ||
|
||
function add_measurement_disturbance(sys::AbstractStateSpace{Continuous}, Ad::AbstractMatrix, Cd::AbstractMatrix) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have a docstring if we export. Same for the rest |
||
A,B,C,D = ControlSystems.ssdata(sys) | ||
T = eltype(A) | ||
nx,nu,ny = sys.nx,sys.nu,sys.ny | ||
Ae = [A zeros(T, nx, size(Ad, 1)); zeros(T, size(Ad, 1), nx) Ad] | ||
Be = [B; zeros(T, size(Ad, 1), nu)] | ||
Ce = [C Cd] | ||
De = D | ||
ss(Ae,Be,Ce,De) | ||
end | ||
|
||
function add_low_frequency_disturbance(sys::AbstractStateSpace{Continuous}, Ai::Integer; ϵ=0) | ||
nx,nu,ny = sys.nx,sys.nu,sys.ny | ||
Cd = zeros(nx, 1) | ||
Cd[Ai] = 1 | ||
add_disturbance(sys, fill(-ϵ, 1, 1), Cd) | ||
end | ||
|
||
function add_low_frequency_disturbance(sys::AbstractStateSpace{Continuous}; ϵ=0, measurement=false) | ||
nx,nu,ny = sys.nx,sys.nu,sys.ny | ||
if measurement | ||
Cd = I(nu) | ||
add_measurement_disturbance(sys, -ϵ*I(nu), Cd) | ||
else | ||
Cd = sys.B | ||
add_disturbance(sys, -ϵ*I(nu), Cd) | ||
end | ||
end | ||
|
||
function add_resonant_disturbance(sys::AbstractStateSpace{Continuous}, ω, ζ, Ai::Integer; measurement=false) | ||
nx,nu,ny = sys.nx,sys.nu,sys.ny | ||
if measurement | ||
Cd = zeros(ny, 2) | ||
Cd[Ai, 1] = 1 | ||
else | ||
Cd = zeros(nx, 2) | ||
Cd[Ai, 1] = 1 | ||
end | ||
Ad = [-ζ -ω; ω -ζ] | ||
measurement ? add_measurement_disturbance(sys, Ad, Cd) : add_disturbance(sys, Ad, Cd) | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the description should be a bit better here, I could not figure out what the function was doing without reading the code. Maybe the expression for the new system matrix is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that you probably use this to introduce disturbances, but it seems that it could be called something more general, like 'augment_system'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, all augmentation functions require better docstrings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, your first comment probably got eaten up by autocorrect ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that was tough to read, fixed now.