From 790905d9590b706a3a197c18cf1222bad74205a8 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson <cont-frb@ulund.org> Date: Mon, 21 Aug 2017 20:25:14 +0200 Subject: [PATCH] Clarify README --- README.md | 16 +++++++++++++--- docs/feedback4.png | Bin 0 -> 3914 bytes src/controllers.jl | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 docs/feedback4.png diff --git a/README.md b/README.md index 6aeeee0..035f5fe 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 GIT binary patch literal 3914 zcmeAS@N?(olHy`uVBq!ia0y~yV3uHDV7S4-#K6GtT>g?20|NtRfk$L90|SpQ2s2(f zx7Lq=fkCdsHKHUqKdq!Zu_%?n(JjD7!963txTH9_D6^nM!9vf}(Cqq&SOx~JPEQxd zkcv5P?_Qj=%0h%SVCJj;|5KkeYISL^sPOS9ig=xw_r1jYnCu;vDVg)0vokQ<|GoYz z8v{d+*F>fjNwbz^&Wg%souYVty+#lNgJYKngTn+RRtAA39*hhuns|gR#J}cccp!gU zx-jRx_WruNXP-%)_$_@}g=4c4>xJo+^QK>)xBU8yr>{BVDt1g&-Pk_yT;XTC<=+?> znnW}k-sSK=3ZJ&vL(P4js3yaMEX#ARZDW*KFD(D+rRkxZx<pj7p>FN+&vULTHy$ou z*mrKFZG&H?-vxW^Ack1$n)?<#dcI56dN4BNs#qLc?!ova+cL|)_zhpQ<+?w`S^Nwu zQg=U_lJGave<IV1s3zyKcRIBVb8j&-a0D#@+t1LT;L63I;4zU2NoWC&ycXAmsfYb# zw`@)g`1A+lGPpX8Gm-p86Q6$<(FE&VV0HXUiqiRLjNp2@v!li5$xmLW@heVWw3&J0 zvoMJJV*OXPnu3b;E;0f<Ui0`*eqQk8=LDPky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N`h@F0V_CJ;l3+L8292 zn}DV9)puB`Kxzst*ndr$!Jr4!ym0D&R++b#^Fj~YaVJ*VHmtXt`L$q?uv~vTNZ0^W zMbg8~zq0o-GSnFOUjEnp*+%{!|Lyh6TQ!3iVxzq-t-iJ8Px0S(Ccd}pzvcYjk>JuL z;;^6Z_A#6D?b#uBrLwahYIlh^T(?_y^UJmspF?vmZIqa+<XZkFBJpFIp3Jo6Vd|&P zM85Nx$Ru$xIQwRt?ACwBkH%*0=WU$d>Zlo1azt<Hxvv|(Z1S1>_tE8Vuh*_KzyJTD zoEy)opd}2SUc9yXV!m8Kk=>Q6!8@{AO?Z9|--VTLZ(1$z2f1S3+aSBALVC}x$T?i+ z+dbv?VFz^)%?8FjnI5NvO`cqlBevB>T-y#!RsC9Xh6J0-CR^{ZEZ{~Y<;;1{uia)~ zFi_D3H530c|6z0&I@Q!_&cMLH;OXk;vd$@?iS`X(=8Mn<@U?@y2NVPjY`FBd+%8Q) zz9q$fLi)8cH4F@Me&@3@Fzh+y!N}m^#>Jpu6vV(VaUv5#M~?`DL&_2c1|?-y1_4P; fhK3WPN=CzFG%*ZpCRxNQ_?=~K+b;7s<bnhMK)czw literal 0 HcmV?d00001 diff --git a/src/controllers.jl b/src/controllers.jl index 8b91d74..74a2153 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) -- GitLab