Skip to content

Commit 82e7426

Browse files
committed
add example with named IO to docs
1 parent 6efaf3c commit 82e7426

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/src/index.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pkg> add ControlSystemsMTK
2121

2222

2323
## From ControlSystems to ModelingToolkit
24-
Simply calling `ODESystem(sys)` converts a `StateSpace` object from ControlSystems into the corresponding [`ModelingToolkitStandardLibrary.Blocks.StateSpace`](http://mtkstdlib.sciml.ai/dev/API/blocks/#ModelingToolkitStandardLibrary.Blocks.StateSpace). If `sys` is a [named statespace object](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/#Named-systems), the names will be retained in the `ODESystem`.
24+
Simply calling `ODESystem(sys)` converts a `StateSpace` object from ControlSystems into the corresponding [`ModelingToolkitStandardLibrary.Blocks.StateSpace`](http://mtkstdlib.sciml.ai/dev/API/blocks/#ModelingToolkitStandardLibrary.Blocks.StateSpace). If `sys` is a [named statespace object](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/#Named-systems), the names of inputs and outputs will be retained in the `ODESystem` as connectors, that is, if `my_input` is an input variable in the named statespace object, `my_input` will be a connector of type `RealInput` in the resulting ODESystem. Names of state variables are currently ignored.
2525

2626
### Example:
2727

@@ -55,6 +55,22 @@ julia> equations(P)
5555
output₊u(t) ~ x[1](t)
5656
```
5757

58+
To connect `P` to the input and output of `P`, use the connectors `P.input` and `P.output`. If the inputs or outputs are multivariable, there are _additional_ scalar connectors for each input/output variable respectively.
59+
60+
### Example with named signals
61+
The following creates a named statespace system with named inputs `u = :torque` and outputs `y = [:motor_angle, :load_angle]`:
62+
```@example CONNECT
63+
using ControlSystemsMTK, ControlSystemsBase, ModelingToolkit, RobustAndOptimalControl
64+
65+
P = named_ss(DemoSystems.double_mass_model(outputs = [1,3]), u=:torque, y=[:motor_angle, :load_angle])
66+
```
67+
68+
When we convert this system to an ODESystem, we get a system with connectors `P.torque` and `P.motor_angle`, in addition to the standard connectors `P.input` and `P.output`:
69+
```@example CONNECT
70+
@named P_ode = ODESystem(P)
71+
```
72+
Here, `P.torque` is equal to `P.input`, so you may choose to connect to either of them. However, since the output is multivariable, the connector `P.output` represents both outputs, while `P.motor_angle` and `P.load_angle` represent the individual scalar outputs.
73+
5874

5975
## From ModelingToolkit to ControlSystems
6076
An `ODESystem` can be converted to a named statespace object from [RobustAndOptimalControl.jl](https://github.com/JuliaControl/RobustAndOptimalControl.jl) by calling [`named_ss`](@ref)

0 commit comments

Comments
 (0)