You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to connect a linear system with a sensor. The output of the sensor is continuous and updated at sampled times, it stays constant in between sampled times.
My issue is that in the dynamics equation of the sensor, the state and control of the linear system do not appear. They appear only in the discrete_events affect. This throws an error when I try to connect the sensor and the system.
The code is the following.
using ModelingToolkit
using DifferentialEquations
A = [0.1. ; 0.0.] # 2×2 Matrix{Float64}
B = [0. ; 1.0 ;;] # 2×1 Matrix{Float64}
C = [1.00.0 ] # 1×2 Matrix{Float64}
D = [0.0 ;;] # 1×1 Matrix{Float64}
x0 = [0.0 ; 1.0 ;;] # 2×1 Matrix{Float64}
u0 = [0.0 ;;] # 1×1 Matrix{Float64}
Δt =1.0
tf =10.0
y0 = C*x0 + D*u0 # 1×1 Matrix{Float64}functionlinear_system(A,B;name)
nx =size(A,1)
nu =size(B,2)
@variables t x(t)[1:nx,1] u(t)[1:nu,1]
d_dt =Differential(t)
eqs =d_dt.(x) ~ A * x + B * u
ODESystem(eqs;name)
end@named system =linear_system(A,B)
functionlinear_sensor(C,D,Δt;name)
nx =size(C,2)
ny =size(C,1)
nu =size(D,2)
@variables t x(t)[1:nx,1] u(t)[1:nu,1] y(t)[1:ny,1]
d_dt =Differential(t)
eqs =d_dt.(y) .~0.
measure = y ~ C * x + D * u
update = [Δt => measure]
ODESystem(eqs;name,discrete_events=update)
end@named sensor =linear_sensor(C,D,Δt)
connections = [ Symbolics.scalarize(sensor.x ~ system.x) ;
Symbolics.scalarize(sensor.u ~ system.u) ]
The error occurring at the last line
ERROR: ArgumentError: System sensor: variable x does not exist
Stacktrace:
[1] getvar(sys::ODESystem, name::Symbol; namespace::Bool)
@ ModelingToolkit D:\fdietric\.julia\packages\ModelingToolkit\5qzZn\src\systems\abstractsystem.jl:316
[2] getproperty(sys::ODESystem, name::Symbol; namespace::Bool)
@ ModelingToolkit D:\fdietric\.julia\packages\ModelingToolkit\5qzZn\src\systems\abstractsystem.jl:270
[3] getproperty(sys::ODESystem, name::Symbol)
@ ModelingToolkit D:\fdietric\.julia\packages\ModelingToolkit\5qzZn\src\systems\abstractsystem.jl:269
[4] top-level scope
@ d:\fdietric\Documents\Julia\ModelingToolkit\kalmanfilter\kalmanfilter.jl:51
Additionally, I think my affect equation also throws an error of the type
pkg> status
Status `D:\fdietric\Documents\Julia\ModelingToolkit\kalmanfilter\Project.toml`
[0c46a032] DifferentialEquations v7.3.0
[961ee093] ModelingToolkit v8.20.0
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to connect a linear system with a sensor. The output of the sensor is continuous and updated at sampled times, it stays constant in between sampled times.
My issue is that in the dynamics equation of the sensor, the state and control of the linear system do not appear. They appear only in the discrete_events affect. This throws an error when I try to connect the sensor and the system.
The code is the following.
The error occurring at the last line
Additionally, I think my affect equation also throws an error of the type
Thanks in advance for your help
The text was updated successfully, but these errors were encountered: