@@ -60,22 +60,22 @@ function generate_f_h(model, inputs, outputs)
6060 if any(ModelingToolkit.is_alg_equation, equations(io_sys))
6161 error("Systems with algebraic equations are not supported")
6262 end
63- h_ = ModelingToolkit.build_explicit_observed_function(io_sys, outputs; inputs = inputs )
63+ h_ = ModelingToolkit.build_explicit_observed_function(io_sys, outputs; inputs)
6464 nx = length(dvs)
6565 vx = string.(dvs)
66- par = varmap_to_vars(defaults(io_sys), psym)
67- function f!(ẋ, x, u, _ , _ )
68- f_ip(ẋ, x, u, par , 1)
69- nothing
66+ p = varmap_to_vars(defaults(io_sys), psym)
67+ function f!(ẋ, x, u, _ , p )
68+ f_ip(ẋ, x, u, p , 1)
69+ return nothing
7070 end
71- function h!(y, x, _ , _ )
72- y .= h_(x, 1, par , 1)
73- nothing
71+ function h!(y, x, _ , p )
72+ y .= h_(x, 1, p , 1)
73+ return nothing
7474 end
75- return f!, h!, nx, vx
75+ return f!, h!, p, nx, vx
7676end
7777inputs, outputs = [mtk_model.τ], [mtk_model.y]
78- f!, h!, nx, vx = generate_f_h(mtk_model, inputs, outputs)
78+ f!, h!, p, nx, vx = generate_f_h(mtk_model, inputs, outputs)
7979nu, ny, Ts = length(inputs), length(outputs), 0.1
8080vu, vy = ["\$τ\$ (Nm)"], ["\$θ\$ (°)"]
8181nothing # hide
@@ -84,15 +84,15 @@ nothing # hide
8484A [ ` NonLinModel ` ] ( @ref ) can now be constructed:
8585
8686``` @example 1
87- model = setname!(NonLinModel(f!, h!, Ts, nu, nx, ny); u=vu, x=vx, y=vy)
87+ model = setname!(NonLinModel(f!, h!, Ts, nu, nx, ny; p ); u=vu, x=vx, y=vy)
8888```
8989
9090We also instantiate a plant model with a 25 % larger friction coefficient `` K `` :
9191
9292``` @example 1
9393mtk_model.K = defaults(mtk_model)[mtk_model.K] * 1.25
94- f_plant, h_plant, _, _ = generate_f_h(mtk_model, inputs, outputs)
95- plant = setname!(NonLinModel(f_plant, h_plant, Ts, nu, nx, ny); u=vu, x=vx, y=vy)
94+ f_plant, h_plant, p = generate_f_h(mtk_model, inputs, outputs)
95+ plant = setname!(NonLinModel(f_plant, h_plant, Ts, nu, nx, ny; p ); u=vu, x=vx, y=vy)
9696```
9797
9898## Controller Design
0 commit comments