2. Install LabProcesses.jl using command `Pkg.clone("https://gitlab.control.lth.se/processes/LabProcesses.jl.git")` Lots of packages will now be installed, this will take some time. If this is your first time using Julia, you might have to run `julia> Pkg.init()` before you install any packages.
2. Install LabProcesses.jl using command `Pkg.clone("https://gitlab.control.lth.se/processes/LabProcesses.jl.git")` Lots of packages will now be installed, this will take some time. If this is your first time using Julia, you might have to run `julia> Pkg.init()` before you install any packages.
## How to implement a new process
## How to implement a new process
1. Locate the file [interface.jl](https://gitlab.control.lth.se/processes/LabProcesses.jl/blob/master/src/interface.jl). (Alternatively, you can copy all definitions from [/interface_implementations/ballandbeam.jl](https://gitlab.control.lth.se/processes/LabProcesses.jl/blob/master/src/interface_implementations/ballandbeam.jl) instead. Maybe it's easier to work from an existing implementaiton.)
1. Locate the file [interface.jl](https://gitlab.control.lth.se/processes/LabProcesses.jl/blob/master/src/interface.jl). When the package is installed, you find its directory under `~/.julia/v0.6/LabProcesses/`, if not, run `julia> Pkg.dir("LabProcesses")` to locate the directory.
(Alternatively, you can copy all definitions from [/interface_implementations/ballandbeam.jl](https://gitlab.control.lth.se/processes/LabProcesses.jl/blob/master/src/interface_implementations/ballandbeam.jl) instead. Maybe it's easier to work from an existing implementaiton.)
2. Copy all function definitions.
2. Copy all function definitions.
3. Create a new file under `/interface_implementations` where you paste all the
3. Create a new file under `/interface_implementations` where you paste all the
copied definitions and implement them. See [/interface_implementations/ballandbeam.jl](https://gitlab.control.lth.se/processes/LabProcesses.jl/blob/master/src/interface_implementations/ballandbeam.jl) for an example.
copied definitions and implement them. See [/interface_implementations/ballandbeam.jl](https://gitlab.control.lth.se/processes/LabProcesses.jl/blob/master/src/interface_implementations/ballandbeam.jl) for an example.
Perform control experiemnt where the feedback and feedforward controllers are given by
Perform control experiemnt on process where the feedback and feedforward controllers are given by
`sysFB` and `sysFF`, both of type `StateSpace`.
`sysFB` and `sysFF`, both of type `StateSpace`.
`reference` is a reference generating function that accepts a scalar `t` (time in seconds) and outputs a scalar `r`, default is `reference(t) = sign(sin(2π*t))`.
`reference` is a reference generating function that accepts a scalar `t` (time in seconds) and outputs a scalar `r`, default is `reference(t) = sign(sin(2π*t))`.
...
@@ -11,10 +11,12 @@ The outputs `y,u,r` are the beam angle, control signal and reference respectivel
...
@@ -11,10 +11,12 @@ The outputs `y,u,r` are the beam angle, control signal and reference respectivel


"""
"""
function run_control_2DOF(P::AbstractProcess,sysFB,sysFF=nothing;duration=10,reference=t->sign(sin(2π*t)))
function run_control_2DOF(P::AbstractProcess,sysFB,sysFF=nothing;duration=10,reference=t->sign(sin(2π*t)))
nu=num_inputs(P)
ny=num_outputs(P)
h=sampletime(P)
h=sampletime(P)
y=zeros(0:h:duration)
y=zeros(ny,length(0:h:duration))
u=zeros(0:h:duration)
u=zeros(nu,length(0:h:duration))
r=zeros(0:h:duration)
r=zeros(ny,length(0:h:duration))
stateFB=init_sysfilter(sysFB)
stateFB=init_sysfilter(sysFB)
ifsysFF!=nothing
ifsysFF!=nothing
...
@@ -22,19 +24,19 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10
...
@@ -22,19 +24,19 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10