Commit a4963135 authored by Martin Heyden's avatar Martin Heyden
Browse files

Updated flexible servo

parent 615a470c
Pipeline #727 failed with stage
......@@ -17,6 +17,7 @@ include("interface.jl")
include("interface_documentation.jl")
include("interface_implementations/ballandbeam.jl")
include("interface_implementations/eth_helicopter.jl")
include("interface_implementations/flexibleservo.jl")
include("reference_generators.jl")
include("controllers.jl")
......
......@@ -3,7 +3,7 @@
#TODO export get_states and define process
export FlexibleServo, FlexibleServoSimulator, AbstractFlexibleServo, define_flexible_servo
export num_states, get_state
struct FlexibleServo <: PhysicalProcess
h::Float64
stream::LabStream
......@@ -14,7 +14,7 @@ end
function FlexibleServo(;
h::Float64 = 0.01,
stream:LabStream = ComediStream(),
stream::LabStream = ComediStream(),
measure1::AnalogInput10V = AnalogInput10V(0),
measure2::AnalogInput10V = AnalogInput10V(1),
control::AnalogOutput10V = AnalogOutput10V(1))
......@@ -46,17 +46,17 @@ function define_flexible_servo()
end
struct FlexibleServoSimulator <: SimulatedProcess
x::Array{Float64,1}
h::Float64
x::Array{Float64,2} #TODO Dim 1 or 2? Result of matrix mult is dim 2?
Φ::Array{Float64,2}
Γ::Array{Float64,2}
C::Array{Float64,2}
end
function FlexibleServoSimulator (;h::Float64 =0.01)
Gp = ss(A,B,C,D)
function FlexibleServoSimulator(;h::Float64 =0.01)
Gp = define_flexible_servo()
Gp_disc = c2d(Gp, h)
return FlexibleServo(h, Gp_disc[1].A, Gp_disc[1].B, Gp_disc[1].C)
return FlexibleServoSimulator(h,zeros(4,1), Gp_disc[1].A, Gp_disc[1].B, Gp_disc[1].C)
end
const AbstractFlexibleServo = Union{FlexibleServo, FlexibleServoSimulator}
......@@ -65,6 +65,7 @@ const AbstractFlexibleServo = Union{FlexibleServo, FlexibleServoSimulator}
num_outputs(p::AbstractFlexibleServo) = 2
num_inputs(p::AbstractFlexibleServo) = 1
num_states(P::AbstractFlexibleServo) = 4 #For statefeedback simulation in ak lab3
outputrange(p::AbstractFlexibleServo) = [(-10,10),(-10,10)] #Process has two outputs, only one uses in AK lab3
inputrange(p::AbstractFlexibleServo) = [(-10,10)]
isstable(p::AbstractFlexibleServo) = true
......@@ -79,7 +80,7 @@ end
control(p::FlexibleServo, u) = send(p.control,u)
function control(p::FlexibleServoSimulator, u)
x = p.Φ*x + p.Γ*u
p.x .= p.Φ*p.x + p.Γ*u
nothing
end
......
Supports Markdown
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