Commit 1b5a03c8 authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

Add a bias term to interface spec.

parent d5e320c6
#__precompile__()
__precompile__()
module LabProcesses
......
......@@ -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)
......
......@@ -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))")
......
......@@ -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)`
......
......@@ -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))
......
......@@ -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]))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment