Skip to content

Commit 998acb1

Browse files
committed
minor tutorial updates
1 parent 8f9a7ab commit 998acb1

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

docs/src/examples/pendulum.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ This results in a simplified model with the minimum required variables and equat
5959
multibody
6060
```
6161

62-
We are now ready to create an `ODEProblem` and simulate it. We use the `Rodas4` solver from OrdinaryDiffEq.jl, and pass a dictionary for the initial conditions. We specify only initial condition for some variables, for those variables where no initial condition is specified, the default initial condition defined the model will be used.
62+
We are now ready to create an `ODEProblem` and simulate it. We use the `Tsit5` solver from OrdinaryDiffEq.jl, and pass a dictionary for the initial conditions. We specify only initial condition for some variables, for those variables where no initial condition is specified, the default initial condition defined the model will be used.
6363
```@example pendulum
6464
D = Differential(t)
6565
defs = Dict() # We may specify the initial condition here
@@ -334,10 +334,10 @@ gray = [0.5, 0.5, 0.5, 1]
334334
fixed = Fixed()
335335
cart = BodyShape(m = 1, r = [0.2, 0, 0], color=[0.2, 0.2, 0.2, 1], shape="box")
336336
mounting_point = FixedTranslation(r = [0.1, 0, 0])
337-
prismatic = Prismatic(n = [1, 0, 0], axisflange = true, color=gray, state_priority=100)
337+
prismatic = Prismatic(n = [1, 0, 0], s0 = 0, axisflange = true, color=gray, state_priority=100)
338338
revolute = Revolute(n = [0, 0, 1], axisflange = false, state_priority=100)
339339
pendulum = BodyCylinder(r = [0, 0.5, 0], diameter = 0.015, color=gray)
340-
motor = TranslationalModelica.Force(use_support = true)
340+
motor = TranslationalModelica.Force(use_support = false)
341341
tip = Body(m = 0.05)
342342
end
343343
@@ -356,7 +356,7 @@ gray = [0.5, 0.5, 0.5, 1]
356356
connect(revolute.frame_b, pendulum.frame_a)
357357
connect(pendulum.frame_b, tip.frame_a)
358358
connect(motor.flange, prismatic.axis)
359-
connect(prismatic.support, motor.support)
359+
# connect(prismatic.support, motor.support)
360360
u ~ motor.f.u
361361
x ~ prismatic.s
362362
v ~ prismatic.v
@@ -411,13 +411,13 @@ op = Dict([ # Operating point to linearize in
411411
cp.revolute.phi => 0 # Pendulum pointing upwards
412412
]
413413
)
414-
matrices, simplified_sys = linearize(cp, inputs, outputs; op)
414+
matrices, simplified_sys = linearize(cp, inputs, outputs; op, Multibody.linsys...)
415415
matrices
416416
```
417417
This gives us the matrices $A,B,C,D$ in a linearized statespace representation of the system. To make these easier to work with, we load the control packages and call `named_ss` instead of `linearize` to get a named statespace object instead:
418418
```@example pendulum
419419
using ControlSystemsMTK
420-
lsys = named_ss(cp, inputs, outputs; op) # identical to linearize, but packages the resulting matrices in a named statespace object for convenience
420+
lsys = named_ss(cp, inputs, outputs; op, Multibody.linsys...) # identical to linearize, but packages the resulting matrices in a named statespace object for convenience
421421
```
422422

423423
### LQR and LQG Control design

ext/Render.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ end
241241

242242
function get_shapefile(sys, sol)::String
243243
try
244-
sf = sol(sol.t[1], idxs=sys.shapefile)
244+
return sf = sol(sol.t[1], idxs=[sys.shapefile])[]
245245
# decode(sf)
246246
catch
247247
""
@@ -250,7 +250,7 @@ end
250250

251251
function get_shape(sys, sol)::String
252252
try
253-
sf = sol(sol.t[1], idxs=sys.shape)
253+
return sf = sol(sol.t[1], idxs=[sys.shape])[]
254254
# decode(sf)
255255
catch
256256
""
@@ -631,7 +631,6 @@ function render!(scene, ::typeof(BodyShape), sys, sol, t)
631631
if isempty(shapepath)
632632
r_0a = get_fun(sol, collect(sys.frame_a.r_0))
633633
r_0b = get_fun(sol, collect(sys.frame_b.r_0))
634-
shape = get_shape(sys, sol)
635634
if shape == "cylinder"
636635
radius = Float32(sol(sol.t[1], idxs=sys.radius))
637636
thing = @lift begin

0 commit comments

Comments
 (0)