diff --git a/src/LabProcesses.jl b/src/LabProcesses.jl index 83713b7af8818368573498b3afe911264840ba8c..e7cc583025c3fc871b1f54e90860fa1242b7ff4a 100644 --- a/src/LabProcesses.jl +++ b/src/LabProcesses.jl @@ -1,4 +1,4 @@ -#__precompile__() +__precompile__() module LabProcesses diff --git a/src/controllers.jl b/src/controllers.jl index 1bdb043a9d07d455b534d1771f71790831fce4fb..8b91d744b5e2a6432bd4a07427d79cd65271f5bb 100644 --- a/src/controllers.jl +++ b/src/controllers.jl @@ -24,6 +24,7 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10 rf = sysFF == nothing ? r[i] : sysfilter!(stateFF, sysFF, r[i]) e = rf-y[i] ui = sysfilter!(stateFB, sysFB, e)[1] + ui + bias(P) end initialize(P) diff --git a/src/interface.jl b/src/interface.jl index 065dbd6485a4c42dd91e54934b220396987c110a..db99995a171e2b761953b9254951ffe9c8dd032b 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -24,6 +24,7 @@ inputrange(p::AbstractProcess) = error("Function not implemented for $(typeof(p isstable(p::AbstractProcess) = error("Function not implemented for $(typeof(p))") isasstable(p::AbstractProcess) = error("Function not implemented for $(typeof(p))") sampletime(p::AbstractProcess) = error("Function not implemented for $(typeof(p))") +bias(p::AbstractProcess) = error("Function not implemented for $(typeof(p))") control(p::AbstractProcess, u) = error("Function not implemented for $(typeof(p))") measure(p::AbstractProcess) = error("Function not implemented for $(typeof(p))") diff --git a/src/interface_documentation.jl b/src/interface_documentation.jl index 59e6de51540fc76e796c1b403524eac6ce167317..d9fec072bd41704fa714412425efdc6aeca803fa 100644 --- a/src/interface_documentation.jl +++ b/src/interface_documentation.jl @@ -62,6 +62,14 @@ Return the sample time of the process in seconds. """ sampletime +""" + b = bias(P::AbstractProcess) +Return an input bias for the process. This could be, i.e., the constant input uâ‚€ around which +a nonlinear system is linearized, or whatever other bias might exist on the input. +`length(b) = num_inputs(P)` +""" +bias + """ control(P::AbstractProcess, u) Send a control signal to the process. `u` must have dimension equal to `num_inputs(P)` diff --git a/src/interface_implementations/ballandbeam.jl b/src/interface_implementations/ballandbeam.jl index e4a8a63fb0bd49a55efc1e21b776290d62b66290..fe1ed04c3c7dd295e846146d49e8b12d522aa72d 100644 --- a/src/interface_implementations/ballandbeam.jl +++ b/src/interface_implementations/ballandbeam.jl @@ -22,6 +22,9 @@ inputrange(p::BallAndBeamType) = [(-10,10)] isstable(p::BallAndBeamType) = false isasstable(p::BallAndBeamType) = false sampletime(p::BallAndBeamType) = p.h +bias(p::BallAndBeam) = p.bias +bias(p::BallAndBeamSimulator) = 0 + control(p::BallAndBeam, u) = ccall((:comedi_write, comedipath),Int32, (Int32,Int32,Int32,Int32),0,1,1,num2io(u[1]+p.bias)) diff --git a/src/interface_implementations/eth_helicopter.jl b/src/interface_implementations/eth_helicopter.jl index 1011c9901905f80da6a18becddc4fe52ee4e4038..a54157882ab9b7b10c0d8f3bc83af132949683dc 100644 --- a/src/interface_implementations/eth_helicopter.jl +++ b/src/interface_implementations/eth_helicopter.jl @@ -4,11 +4,13 @@ export ETHHelicopter, ETHHelicopterSimulator, ETHHelicopterType struct ETHHelicopter <: PhysicalProcess h::Float64 + bias::Float64 end ETHHelicopter() = ETHHelicopter(0.050) struct ETHHelicopterSimulator <: SimulatedProcess h::Float64 + bias::Float64 state::Vector{Float64} end ETHHelicopterSimulator() = ETHHelicopterSimulator(0.01, zeros(4)) @@ -21,6 +23,8 @@ inputrange(p::ETHHelicopterType) = [(-10,10)] isstable(p::ETHHelicopterType) = false isasstable(p::ETHHelicopterType) = false sampletime(p::ETHHelicopterType) = p.h +bias(p::ETHHelicopterType) = p.bias + function control(p::ETHHelicopter, u) ccall((:comedi_write, comedipath),Int32,(Int32,Int32,Int32,Int32), 0,1,0,num2io(u[1]))