Skip to content

Commit 37e3092

Browse files
authored
rename w1,z1 args to external_inputs, external_outputs (#107)
* rename `w1,z1` args to `external_inputs, external_outputs` * change order
1 parent 56aa3db commit 37e3092

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

docs/src/hinf_connection.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ nothing # hide
8080

8181
When we specify the external inputs and outputs to [`connect`](@ref), we include $y$ and $u$ since they are external from the view of `connect`:
8282
```@example hinfcon
83-
w1 = [ # External inputs
83+
external_inputs = [
8484
:do, :u
8585
]
86-
z1 = [ # External outputs
86+
external_outputs = [
8787
:e, :uw, :y
8888
]
8989
nothing # hide
9090
```
9191

9292
We are now ready to form the system we want to minimize the norm of
9393
```@example hinfcon
94-
G = connect([P,We,Wu,Wd,sumP,split_u], connections; z1, w1)
94+
G = connect([P,We,Wu,Wd,sumP,split_u], connections; external_outputs, external_inputs)
9595
```
9696
At this stage, it's good practice to check that the poles, inputs and outputs of $G$ looks correct, it's easy to forget some signal..
9797

@@ -108,7 +108,7 @@ we also check the equivalences we know should hold
108108
system_mapping(Gsyn) == P.sys
109109
```
110110
```@example hinfcon
111-
G[:uw, :u].sys == Wu.sys
111+
sminreal(G[:uw, :u].sys) == Wu.sys
112112
```
113113
These will not be identical, the realization might differ, but they should represent the same system
114114
```@example hinfcon

examples/complicated_feedback.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#=
22
This example illustrates how named systems can be used to form complicated feedback interconnections.
33
=#
4-
using RobustAndOptimalControl, ControlSystemsBase
4+
using RobustAndOptimalControl, ControlSystemsBase, Test, LinearAlgebra
55
const ROC = RobustAndOptimalControl
66
w = exp10.(LinRange(-2, 2, 300))
77
F = named_ss(ssrand(1, 1, 2, proper=true), x=:xF, u=:uF, y=:yF)
@@ -40,9 +40,9 @@ connections = [
4040
:uC => :uC
4141
:yR => :yR
4242
]
43-
w1 = [:uF]
43+
external_inputs = [:uF]
4444

45-
G = ROC.connect([F, R, C, P, addP, addC], connections; w1)
45+
G = ROC.connect([F, R, C, P, addP, addC], connections; external_inputs)
4646

4747

4848
@test sminreal(G[:yF, :uF].sys) F.sys

examples/flexible_servo.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ function flexible_servo_loop(;
4040
:qm => :y
4141
:e => :e
4242
]
43-
w1 = [:r] # r is an external input
44-
G = connect([P, K, sumE], connections; w1)
43+
external_inputs = [:r] # r is an external input
44+
G = connect([P, K, sumE], connections; external_inputs)
4545

4646
# Alternative calling convention:
4747
# u1 = [:u, :y, :e] # inputs
4848
# y1 = [:Cu, :qm, :e] # outputs
49-
# G = connect([P, K, sumE]; u1, y1, w1)
49+
# G = connect([P, K, sumE]; u1, y1, external_inputs)
5050

5151
(; P, K, G)
5252
end

src/named_systems2.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,13 @@ end
407407

408408
ControlSystemsBase.feedback(s1::NamedStateSpace{T}, s2::AbstractStateSpace{T}; kwargs...) where {T <: CS.TimeEvolution} = feedback(s1, named_ss(s2); kwargs...)
409409

410-
function connect(systems; u1::Vector{Symbol}, y1::Vector{Symbol}, w1, z1 = (:), verbose = true, unique = true, kwargs...)
410+
function connect(systems; u1::Vector{Symbol}, y1::Vector{Symbol}, external_inputs = nothing, w1 = nothing, external_outputs = (:), z1 = nothing, verbose = true, unique = true, kwargs...)
411411
full = append(systems...; unique)
412412
@assert length(y1) == length(u1)
413413

414+
z1 = something(z1, external_outputs)
415+
w1 = something(external_inputs, w1)
416+
w1 === nothing && error("The keyword argument `external_inputs` must be provided")
414417
if unique
415418
@check_unique u1 "Connected inputs not unique. If you want to connect several signals to the same input, use a summation node, e.g., named_ss(ss([1 1]), u=[:u1, :u2], y=:usum)"
416419
@check_unique full.u "system inputs" "To allow connecting a single input signal to several inputs with the same name, pass `unique = false`."
@@ -439,7 +442,7 @@ end
439442

440443

441444
"""
442-
connect(systems, connections; w1, z1 = (:), verbose = true, unique = true, kwargs...)
445+
connect(systems, connections; external_inputs, external_outputs = (:), verbose = true, unique = true, kwargs...)
443446
444447
Create block connections using named inputs and outputs.
445448
@@ -448,8 +451,8 @@ Addition and subtraction nodes are achieved by creating a linear combination nod
448451
# Arguments:
449452
- `systems`: A vector of named systems to be connected
450453
- `connections`: a vector of pairs output => input, where each pair maps an output to an input. Each output must appear as an output in one of `systems`, and similarly each input must appear as an input in one of `systems`. All inputs must have unique names and so must all outputs, but an input may have the same name as an output. In the example below the connection `:uP => :uP` connects the output `:uP` of the `addP` block to `P`'s input `:uP`
451-
- `w1`: external signals to be used as inputs in the constructed system. Use `(:)` to indicate all signals
452-
- `z1`: outputs of the constructed system. Use `(:)` to indicate all signals
454+
- `external_inputs`: external signals to be used as inputs in the constructed system. Use `(:)` to indicate all signals
455+
- `external_outputs`: outputs of the constructed system. Use `(:)` to indicate all signals
453456
- `verbose`: Issue warnings for signals that have no connection
454457
- `unique`: If `true`, all input names must be unique. If `false`, a single external input signal may be connected to multiple input ports with the same name.
455458
@@ -489,9 +492,9 @@ connections = [
489492
:uC => :uC
490493
:yR => :yR
491494
]
492-
w1 = [:uF] # External inputs
495+
external_inputs = [:uF] # External inputs
493496
494-
G = connect([F, R, C, P, addP, addC], connections; w1)
497+
G = connect([F, R, C, P, addP, addC], connections; external_inputs)
495498
```
496499
497500
If an external input is to be connected to multiple points, use a `splitter` to split up the signal into a set of unique names which are then used in the connections.

0 commit comments

Comments
 (0)