diff --git a/README.md b/README.md index 6aeeee0c86a89ec4d8917acb741f0350b46b8b6f..035f5fe326f908bc6ee7620ae760620c460fed76 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,10 @@ implementing the same interface (or a simulated version) by changeing a single line of code :) ## Installation -1. Start julia -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. +1. Start julia by typing `julia` in a terminal, make sure the printed info says it's +`v0.6+` running. If not, visit [julialang.org](https://julialang.org/downloads/) +to get the latest release. +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 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.) @@ -23,10 +25,17 @@ copied definitions and implement them. See [/interface_implementations/ballandbe ```julia struct BallAndBeam <: PhysicalProcess h::Float64 + bias::Float64 end - BallAndBeam() = BallAndBeam(0.01) # Constructor with default value of sample time + BallAndBeam() = BallAndBeam(0.01, 0.0) # Constructor with default value of sample time ``` Make sure you inherit from `PhysicalProcess` or `SimulatedProcess` as appropriate. +This type must contains fields that hold information about everything that is +relevant to a particular instance of the process. Different ballandbeam-process +have different biases, hence this must be stored. A simulated process would have +to keep track of its state etc. in order to implement the measure and control +methods. See [Types in julia documentation](https://docs.julialang.org/en/stable/manual/types/#Composite-Types-1) +for additional info regarding user defined types and (constructors)[https://docs.julialang.org/en/stable/manual/constructors/]. 5. Documentation of all interface functions is available in the file [interface_documentation.jl](https://gitlab.control.lth.se/processes/LabProcesses.jl/blob/master/src/interface_documentation.jl) ## Control a process @@ -34,6 +43,7 @@ The interface `AbstractProcess` defines the functions `control(P, u)` and `measu These functions can be used to implement your own control loops. A common loop with a feedback controller and a feedforward filter on the reference is implemented in the function [`run_control_2DOF`](@ref). + The macro `@periodically` might come in handy if you want to implement your own loop. Consider the following example, in which the loop body will be run periodically diff --git a/docs/feedback4.png b/docs/feedback4.png new file mode 100644 index 0000000000000000000000000000000000000000..696bf353a387ba1ef2f86ba0b3dbb0c62cdb7252 Binary files /dev/null and b/docs/feedback4.png differ diff --git a/src/controllers.jl b/src/controllers.jl index 8b91d744b5e2a6432bd4a07427d79cd65271f5bb..74a2153b74dd89315fc37cc885d33e39106aedbd 100644 --- a/src/controllers.jl +++ b/src/controllers.jl @@ -8,6 +8,7 @@ Perform control experiemnt where the feedback and feedforward controllers are gi `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))`. The outputs `y,u,r` are the beam angle, control signal and reference respectively. + """ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10, reference = t->sign(sin(2π*t))) h = sampletime(P)