Skip to content

Commit 9bb528d

Browse files
committed
introduce some intermediate level parameters
1 parent d03849f commit 9bb528d

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/components.jl

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,16 +481,34 @@ The `BodyShape` component is similar to a [`Body`](@ref), but it has two frames
481481
482482
See also [`BodyCylinder`](@ref) and [`BodyBox`](@ref) for body components with predefined shapes and automatically computed inertial properties based on geometry and density.
483483
"""
484-
@component function BodyShape(; name, m = 1, r = [0, 0, 0], r_cm = 0.5*r, r_0 = 0, radius = 0.08, color=purple, shapefile="", shape_transform = I(4), shape_scale = 1, kwargs...)
484+
@component function BodyShape(; name, m = 1, r = [0, 0, 0], r_cm = 0.5*r, r_0 = 0, radius = 0.08, color=purple, shapefile="", shape_transform = I(4), shape_scale = 1,
485+
I_11 = 0.001,
486+
I_22 = 0.001,
487+
I_33 = 0.001,
488+
I_21 = 0,
489+
I_31 = 0,
490+
I_32 = 0,
491+
kwargs...
492+
)
493+
pars = @parameters begin
494+
m = m, [description = "mass"]
495+
I_11=I_11, [description = "Element (1,1) of inertia tensor"]
496+
I_22=I_22, [description = "Element (2,2) of inertia tensor"]
497+
I_33=I_33, [description = "Element (3,3) of inertia tensor"]
498+
I_21=I_21, [description = "Element (2,1) of inertia tensor"]
499+
I_31=I_31, [description = "Element (3,1) of inertia tensor"]
500+
I_32=I_32, [description = "Element (3,2) of inertia tensor"]
501+
end
485502
systems = @named begin
486503
translation = FixedTranslation(r = r, render=false)
487504
translation_cm = FixedTranslation(r = r_cm, render=false)
488-
body = Body(; m, r_cm, r_0, kwargs...)
505+
body = Body(; m, r_cm, r_0, I_11, I_22, I_33, I_21, I_31, I_32, kwargs...)
489506
frame_a = Frame()
490507
frame_b = Frame()
491508
frame_cm = Frame()
492509
end
493510

511+
# NOTE: these parameters should be defined before the `systems` block above, but due to bugs in MTK/JSC with higher-order array parameters we cannot do that. We still define the parameters so that they are available to make animations
494512
@variables r_0(t)[1:3]=r_0 [
495513
state_priority = 2,
496514
description = "Position vector from origin of world frame to origin of frame_a",
@@ -504,7 +522,7 @@ See also [`BodyCylinder`](@ref) and [`BodyBox`](@ref) for body components with p
504522
]
505523

506524
shapecode = encode(shapefile)
507-
@parameters begin
525+
more_pars = @parameters begin
508526
r[1:3]=r, [
509527
description = "Vector from frame_a to frame_b resolved in frame_a",
510528
]
@@ -516,7 +534,7 @@ See also [`BodyCylinder`](@ref) and [`BodyBox`](@ref) for body components with p
516534
end
517535

518536

519-
pars = [r; radius; color; shapefile; shape_transform; shape_scale]
537+
pars = collect_all([pars; more_pars])
520538

521539
r_0, v_0, a_0 = collect.((r_0, v_0, a_0))
522540

src/wheels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ function RollingWheelSet(;
884884
]
885885

886886
sys = ODESystem(equations, t; name=:nothing, systems)
887-
add_params(sys, [width_wheel]; name)
887+
add_params(sys, pars; name)
888888

889889
end
890890

0 commit comments

Comments
 (0)