@@ -11,14 +11,14 @@ old_logger = global_logger(); global_logger(errlogger);
1111
1212## Pendulum Example
1313
14- This example integrates the simple pendulum model of the [ last section] ( @man_nonlin ) in the
14+ This example integrates the simple pendulum model of the [ last section] (@ref man_nonlin) in the
1515[ ModelingToolkit.jl] ( https://docs.sciml.ai/ModelingToolkit/stable/ ) (MTK) framework and
1616extracts appropriate ` f! ` and ` h! ` functions to construct a [ ` NonLinModel ` ] ( @ref ) .
1717
1818!!! danger "Disclaimer"
1919 This simple example is not an official interface to ` ModelingToolkit.jl ` . It is provided
20- as a basic template to combine both packages. There is no guarantee that it will work
21- for all corner cases.
20+ as a basic starting point template to combine both packages. There is no guarantee that
21+ it will work for all corner cases.
2222
2323We first construct and instantiate the pendulum model:
2424
@@ -93,7 +93,7 @@ f_plant, h_plant, _, _ = generate_f_h(mtk_model, inputs, outputs)
9393plant = setname!(NonLinModel(f_plant, h_plant, Ts, nu, nx, ny); u=vu, x=vx, y=vy)
9494```
9595
96- We can than reproduce the Kalman filter and the controller design of the [ last section] ( @man_nonlin ) :
96+ We can than reproduce the Kalman filter and the controller design of the [ last section] (@ref man_nonlin):
9797
9898``` @example 1
9999α=0.01; σQ=[0.1, 1.0]; σR=[5.0]; nint_u=[1]; σQint_u=[0.1]
@@ -104,11 +104,14 @@ umin, umax = [-1.5], [+1.5]
104104nmpc = setconstraint!(nmpc; umin, umax)
105105```
106106
107- The angular setpoint response is identical:
107+ The 180° setpoint response is identical:
108108
109109``` @example 1
110+ using Plots
111+ N = 35
112+ using JuMP; unset_time_limit_sec(nmpc.optim) # hide
110113res_ry = sim!(nmpc, N, [180.0], plant=plant, x_0=[0, 0], x̂_0=[0, 0, 0])
111- display( plot(res_ry) )
114+ plot(res_ry)
112115savefig("plot1_MTK.svg"); nothing # hide
113116```
114117
@@ -118,12 +121,14 @@ and also the output disturbance rejection:
118121
119122``` @example 1
120123res_yd = sim!(nmpc, N, [180.0], plant=plant, x_0=[π, 0], x̂_0=[π, 0, 0], y_step=[10])
121- display( plot(res_yd) )
124+ plot(res_yd)
122125savefig("plot2_MTK.svg"); nothing # hide
123126```
124127
125128![ plot2_MTK] ( plot2_MTK.svg )
126129
130+ Authored by ` 1-Bart-1 ` and ` baggepinnen ` , thanks for the contribution.
131+
127132``` @setup 1
128133global_logger(old_logger);
129134```
0 commit comments