Skip to content

Commit b90f804

Browse files
authored
add BodyCylinder component (#42)
* add BodyCylinder component * add tests and render * up manifest * finish up rendering and tests of BodyCylinder
1 parent 3e6819d commit b90f804

File tree

6 files changed

+275
-37
lines changed

6 files changed

+275
-37
lines changed

Manifest.toml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.4"
44
manifest_format = "2.0"
5-
project_hash = "01a86afcbc8adb6e5ba61dc34569c070c3146575"
5+
project_hash = "b274e98a59af3f38814e912f8a2f3fcae61a2929"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "fc02d55798c1af91123d07915a990fbb9a10d146"
@@ -296,9 +296,9 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
296296

297297
[[deps.DiffEqBase]]
298298
deps = ["ArrayInterface", "ConcreteStructs", "DataStructures", "DocStringExtensions", "EnumX", "EnzymeCore", "FastBroadcast", "FastClosures", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "PrecompileTools", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "Setfield", "SparseArrays", "Static", "StaticArraysCore", "Statistics", "Tricks", "TruncatedStacktraces"]
299-
git-tree-sha1 = "37d49a1f8eedfe68b7622075ff3ebe3dd0e8f327"
299+
git-tree-sha1 = "2c6b7bf16fd850c551a765e313e7522ba455cbfd"
300300
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
301-
version = "6.151.2"
301+
version = "6.151.4"
302302

303303
[deps.DiffEqBase.extensions]
304304
DiffEqBaseCUDAExt = "CUDA"
@@ -469,9 +469,9 @@ uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
469469
version = "1.0.4"
470470

471471
[[deps.EnzymeCore]]
472-
git-tree-sha1 = "a2f4588bde1588af6279729540099895f8dee843"
472+
git-tree-sha1 = "88bc63137eb033acc3afe1b9875717889c718c46"
473473
uuid = "f151be2c-9106-41f4-ab19-57ee4f262869"
474-
version = "0.7.4"
474+
version = "0.7.5"
475475
weakdeps = ["Adapt"]
476476

477477
[deps.EnzymeCore.extensions]
@@ -735,11 +735,11 @@ version = "1.1.0"
735735

736736
[[deps.JuliaSimCompiler]]
737737
deps = ["AbstractTrees", "ChainRules", "ConstructionBase", "DataStructures", "DiffEqCallbacks", "DocStringExtensions", "Expronicon", "ForwardDiff", "GPUCompiler", "Graphs", "IfElse", "JuliaFormatter", "JuliaSimBase", "JuliaSimCompilerRuntime", "LLVM", "Libdl", "LinearAlgebra", "ModelingToolkit", "NaNMath", "OffsetArrays", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SnoopPrecompile", "SparseArrays", "SparseDiffTools", "SpecialFunctions", "StaticArrays", "StrideArraysCore", "SymbolicIndexingInterface", "SymbolicUtils", "Symbolics", "UnPack"]
738-
git-tree-sha1 = "c4e20e91ed8d2f531bce11b41146b31e47566b2f"
738+
git-tree-sha1 = "44d42abc79e898c768b4b62330f7f897e9055b28"
739739
repo-rev = "master"
740740
repo-url = "[email protected]:JuliaComputing/JuliaSimCompiler.jl.git"
741741
uuid = "8391cb6b-4921-5777-4e45-fd9aab8cb88d"
742-
version = "0.1.11"
742+
version = "0.1.12"
743743

744744
[deps.JuliaSimCompiler.extensions]
745745
AcausalVisualizationExt = "CairoMakie"
@@ -1011,10 +1011,10 @@ version = "1.2.0"
10111011
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
10121012

10131013
[[deps.ModelingToolkit]]
1014-
deps = ["AbstractTrees", "ArrayInterface", "Combinatorics", "Compat", "ConstructionBase", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "DiffRules", "Distributed", "Distributions", "DocStringExtensions", "DomainSets", "DynamicQuantities", "ExprTools", "FindFirstFunctions", "ForwardDiff", "FunctionWrappersWrappers", "Graphs", "InteractiveUtils", "JuliaFormatter", "JumpProcesses", "LabelledArrays", "Latexify", "Libdl", "LinearAlgebra", "MLStyle", "NaNMath", "OrderedCollections", "OrdinaryDiffEq", "PrecompileTools", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "SciMLStructures", "Serialization", "Setfield", "SimpleNonlinearSolve", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "SymbolicUtils", "Symbolics", "URIs", "UnPack", "Unitful"]
1015-
git-tree-sha1 = "9b88b3c34a2e39f64e69a07f4c36d1bdbaf82c5d"
1014+
deps = ["AbstractTrees", "ArrayInterface", "Combinatorics", "Compat", "ConstructionBase", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "DiffRules", "Distributed", "Distributions", "DocStringExtensions", "DomainSets", "DynamicQuantities", "ExprTools", "FindFirstFunctions", "ForwardDiff", "FunctionWrappersWrappers", "Graphs", "InteractiveUtils", "JuliaFormatter", "JumpProcesses", "LabelledArrays", "Latexify", "Libdl", "LinearAlgebra", "MLStyle", "NaNMath", "NonlinearSolve", "OrderedCollections", "PrecompileTools", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "SciMLStructures", "Serialization", "Setfield", "SimpleNonlinearSolve", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "SymbolicUtils", "Symbolics", "URIs", "UnPack", "Unitful"]
1015+
git-tree-sha1 = "8d43517ec8d9895f7d5f661167c05f54146a769d"
10161016
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
1017-
version = "9.17.1"
1017+
version = "9.19.0"
10181018

10191019
[deps.ModelingToolkit.extensions]
10201020
MTKBifurcationKitExt = "BifurcationKit"
@@ -1026,7 +1026,7 @@ version = "9.17.1"
10261026

10271027
[[deps.ModelingToolkitStandardLibrary]]
10281028
deps = ["ChainRulesCore", "DiffEqBase", "IfElse", "LinearAlgebra", "ModelingToolkit", "Symbolics"]
1029-
git-tree-sha1 = "e36487496e263d82e866ce5f9d3e87f44765e6ea"
1029+
git-tree-sha1 = "8cfb89cdb4f147810a45efbcc5f98ef6596d60d4"
10301030
repo-rev = "main"
10311031
repo-url = "https://github.com/SciML/ModelingToolkitStandardLibrary.jl.git"
10321032
uuid = "16a59e39-deab-5bd0-87e4-056b12336739"
@@ -1043,9 +1043,9 @@ version = "0.2.4"
10431043

10441044
[[deps.MultivariatePolynomials]]
10451045
deps = ["ChainRulesCore", "DataStructures", "LinearAlgebra", "MutableArithmetics"]
1046-
git-tree-sha1 = "dad7be0c92b688bf8f24af170825ccedc104b116"
1046+
git-tree-sha1 = "5c1d1d9361e1417e5a065e1f84dc3686cbdaea21"
10471047
uuid = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3"
1048-
version = "0.5.5"
1048+
version = "0.5.6"
10491049

10501050
[[deps.MutableArithmetics]]
10511051
deps = ["LinearAlgebra", "SparseArrays", "Test"]
@@ -1071,9 +1071,9 @@ version = "1.2.0"
10711071

10721072
[[deps.NonlinearSolve]]
10731073
deps = ["ADTypes", "ArrayInterface", "ConcreteStructs", "DiffEqBase", "FastBroadcast", "FastClosures", "FiniteDiff", "ForwardDiff", "LazyArrays", "LineSearches", "LinearAlgebra", "LinearSolve", "MaybeInplace", "PrecompileTools", "Preferences", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SimpleNonlinearSolve", "SparseArrays", "SparseDiffTools", "StaticArraysCore", "SymbolicIndexingInterface", "TimerOutputs"]
1074-
git-tree-sha1 = "ed5500c66b726ec9fe8c1796c0a600353246ecf8"
1074+
git-tree-sha1 = "40325dcea1cb84a108efe05966bbb1f4b98e5eea"
10751075
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
1076-
version = "3.12.4"
1076+
version = "3.13.0"
10771077

10781078
[deps.NonlinearSolve.extensions]
10791079
NonlinearSolveBandedMatricesExt = "BandedMatrices"
@@ -1133,9 +1133,9 @@ version = "1.6.3"
11331133

11341134
[[deps.OrdinaryDiffEq]]
11351135
deps = ["ADTypes", "Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DocStringExtensions", "EnumX", "ExponentialUtilities", "FastBroadcast", "FastClosures", "FillArrays", "FiniteDiff", "ForwardDiff", "FunctionWrappersWrappers", "IfElse", "InteractiveUtils", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "MacroTools", "MuladdMacro", "NonlinearSolve", "Polyester", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "SimpleNonlinearSolve", "SimpleUnPack", "SparseArrays", "SparseDiffTools", "StaticArrayInterface", "StaticArrays", "TruncatedStacktraces"]
1136-
git-tree-sha1 = "b857d515bacfb46ee3603a27d6d15b196cf285d0"
1136+
git-tree-sha1 = "a6a006cbf1e563035c0e32b63234e039b599f6b2"
11371137
uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
1138-
version = "6.82.0"
1138+
version = "6.83.2"
11391139

11401140
[[deps.PDMats]]
11411141
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
@@ -1263,9 +1263,9 @@ version = "1.3.4"
12631263

12641264
[[deps.RecursiveArrayTools]]
12651265
deps = ["Adapt", "ArrayInterface", "DocStringExtensions", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "SparseArrays", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"]
1266-
git-tree-sha1 = "3400ce27995422fb88ffcd3af9945565aad947f0"
1266+
git-tree-sha1 = "980aabbeac7aee70d0e452a72b0c68b5b266cc7b"
12671267
uuid = "731186ca-8d62-57ce-b412-fbd966d074cd"
1268-
version = "3.23.1"
1268+
version = "3.24.0"
12691269

12701270
[deps.RecursiveArrayTools.extensions]
12711271
RecursiveArrayToolsFastBroadcastExt = "FastBroadcast"
@@ -1347,9 +1347,9 @@ version = "0.6.42"
13471347

13481348
[[deps.SciMLBase]]
13491349
deps = ["ADTypes", "Accessors", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"]
1350-
git-tree-sha1 = "03e56d028b9825e087cf8bd8a1fa44af5d270ddf"
1350+
git-tree-sha1 = "7a6c5c8c38d2e37f45d4686c3598c20c1aebf48e"
13511351
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
1352-
version = "2.41.2"
1352+
version = "2.41.3"
13531353

13541354
[deps.SciMLBase.extensions]
13551355
SciMLBaseChainRulesCoreExt = "ChainRulesCore"
@@ -1595,9 +1595,9 @@ version = "7.2.1+1"
15951595

15961596
[[deps.SymbolicIndexingInterface]]
15971597
deps = ["Accessors", "ArrayInterface", "RuntimeGeneratedFunctions", "StaticArraysCore"]
1598-
git-tree-sha1 = "a5f6f138b740c9d93d76f0feddd3092e6ef002b7"
1598+
git-tree-sha1 = "9bda3c1e2b771ab45fcbc264a078f612ca7ef427"
15991599
uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
1600-
version = "0.3.22"
1600+
version = "0.3.23"
16011601

16021602
[[deps.SymbolicLimits]]
16031603
deps = ["SymbolicUtils"]

ext/Render.jl

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ function get_color(sys, sol, default)
7070
try
7171
Makie.RGBA(sol(sol.t[1], idxs=collect(sys.color))...)
7272
catch
73-
default
73+
if default isa AbstractVector
74+
Makie.RGBA(default...)
75+
else
76+
default
77+
end
7478
end
7579
end
7680

@@ -339,6 +343,25 @@ function render!(scene, ::typeof(BodyShape), sys, sol, t)
339343
end
340344

341345

346+
function render!(scene, ::typeof(BodyCylinder), sys, sol, t)
347+
348+
# NOTE: This draws a solid cylinder without the hole in the middle. Cannot figure out how to render a hollow cylinder
349+
color = get_color(sys, sol, [1, 0.2, 1, 0.9])
350+
radius = Float32(sol(sol.t[1], idxs=sys.diameter)/2)
351+
r_0a = get_fun(sol, collect(sys.frame_a.r_0))
352+
r_0b = get_fun(sol, collect(sys.frame_b.r_0))
353+
thing = @lift begin
354+
r1 = Point3f(r_0a($t))
355+
r2 = Point3f(r_0b($t))
356+
origin = r1
357+
extremity = r2
358+
Makie.GeometryBasics.Cylinder(origin, extremity, radius)
359+
end
360+
mesh!(scene, thing; color, specular = Vec3f(1.5))
361+
362+
true
363+
end
364+
342365
function render!(scene, ::typeof(Damper), sys, sol, t)
343366
r_0a = get_fun(sol, collect(sys.frame_a.r_0))
344367
r_0b = get_fun(sol, collect(sys.frame_b.r_0))
@@ -421,12 +444,11 @@ function spring_mesh(p1, p2; n_wind=6, radius=0.1f0, N=200)
421444
end
422445

423446
function rot_from_line(d)
424-
d = d ./ norm(d)
425447
if d[1] == 0 && d[2] == 0
426448
return RotMatrix{3}(Matrix{Float32}(I, 3, 3))
427449
end
428450
d = d ./ norm(d)
429-
z = [0, 0, 1]
451+
z = SA[0, 0, 1]
430452
x = cross(z, d)
431453
x = x ./ norm(x)
432454
y = cross(d, x)

src/Multibody.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ include("frames.jl")
135135
export PartialTwoFrames
136136
include("interfaces.jl")
137137

138-
export World, world, Mounting1D, Fixed, FixedTranslation, FixedRotation, Body, BodyShape, Rope
138+
export World, world, Mounting1D, Fixed, FixedTranslation, FixedRotation, Body, BodyShape, BodyCylinder, Rope
139139
include("components.jl")
140140

141141
export Revolute, Prismatic, Spherical, Universal, GearConstraint, RollingWheelJoint,

src/components.jl

Lines changed: 176 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ Representing a body with 3 translational and 3 rotational degrees-of-freedom.
320320
end
321321
collect(frame_a.tau .~ I * z_a + cross(w_a, I * w_a) + cross(r_cm, frame_a.f))]
322322

323-
# pars = [m;r_cm;radius;I_11;I_22;I_33;I_21;I_31;I_32;]
323+
# pars = [m;r_cm;radius;I_11;I_22;I_33;I_21;I_31;I_32;color]
324324

325325
sys = ODESystem(eqs, t; name=:nothing, metadata = Dict(:isroot => isroot), systems = [frame_a])
326326
add_params(sys, [radius; color]; name)
@@ -449,3 +449,178 @@ function Rope(; name, l = 1, dir = [0,-1, 0], n = 10, m = 1, c = 0, d=0, air_res
449449

450450
ODESystem(eqs, t; name, systems = [systems; links; joints])
451451
end
452+
453+
# @component function BodyCylinder(; name, m = 1, r = [0.1, 0, 0], r_0 = 0, r_shape=zeros(3), length = _norm(r - r_shape), kwargs...)
454+
# @parameters begin
455+
# # r[1:3]=r, [ # MTKs symbolic language is too weak to handle this as a symbolic parameter in from_nxy
456+
# # description = "Vector from frame_a to frame_b resolved in frame_a",
457+
# # ]
458+
# # r_shape[1:3]=zeros(3), [
459+
# # description = "Vector from frame_a to cylinder origin, resolved in frame_a",
460+
# # ]
461+
# end
462+
# r, r_shape = collect.((r, r_shape))
463+
# @parameters begin
464+
# dir[1:3] = r - r_shape, [
465+
# description = "Vector in length direction of cylinder, resolved in frame_a",
466+
# ]
467+
# length = _norm(r - r_shape), [
468+
# description = "Length of cylinder",
469+
# ]
470+
# length2 = _norm(r - r_shape), [ # NOTE: strange bug in JSCompiler when both I and r_cm that are parameters if Body depend on the same paramter length. Introducing a dummy parameter with the same value works around the issue. This is not ideal though, since the two parameters must have the same value.
471+
# description = "Length of cylinder",
472+
# ]
473+
# diameter = 1, [#length/5, [
474+
# description = "Diameter of cylinder",
475+
# ]
476+
# inner_diameter = 0, [
477+
# description = "Inner diameter of cylinder (0 <= inner_diameter <= Diameter)",
478+
# ]
479+
# density = 7700, [
480+
# description = "Density of cylinder (e.g., steel: 7700 .. 7900, wood : 400 .. 800)",
481+
# ]
482+
# end
483+
# # @variables length2(t)
484+
# # @assert isequal(length, length2)
485+
# dir = collect(dir) #.|> ParentScope # The ParentScope is required, otherwise JSCompiler thinks that these parameters belong to Body.
486+
# # length = ParentScope(length)
487+
# # diameter = ParentScope(diameter)
488+
# # inner_diameter = ParentScope(inner_diameter)
489+
# # density = ParentScope(density)
490+
491+
# radius = diameter/2
492+
# innerRadius = inner_diameter/2
493+
# mo = density*pi*length*radius^2
494+
# mi = density*pi*length*innerRadius^2
495+
# I22 = (mo*(length^2 + 3*radius^2) - mi*(length^2 + 3*innerRadius^2))/12
496+
# m = mo - mi
497+
# R = from_nxy(r, [0, 1, 0])
498+
# r_cm = r_shape + _normalize(dir)*length2/2
499+
# I = resolve_dyade1(R, Diagonal([(mo*radius^2 - mi*innerRadius^2)/2, I22, I22]))
500+
501+
# # r_cm = ParentScope.(r_cm)
502+
# # I = ParentScope.(I)
503+
# # m = ParentScope(m)
504+
505+
# @variables begin
506+
# r_0(t)[1:3]=r_0, [
507+
# state_priority = 2,
508+
# description = "Position vector from origin of world frame to origin of frame_a",
509+
# ]
510+
# v_0(t)[1:3]=0, [
511+
# state_priority = 2,
512+
# description = "Absolute velocity of frame_a, resolved in world frame (= D(r_0))",
513+
# ]
514+
# a_0(t)[1:3]=0, [
515+
# description = "Absolute acceleration of frame_a resolved in world frame (= D(v_0))",
516+
# ]
517+
# end
518+
519+
# systems = @named begin
520+
# frame_a = Frame()
521+
# frame_b = Frame()
522+
# frameTranslation = FixedTranslation(r = r)
523+
# body = Body(; m, r_cm, I_11 = I[1,1], I_22 = I[2,2], I_33 = I[3,3], I_21 = I[2,1], I_31 = I[3,1], I_32 = I[3,2], kwargs...)
524+
525+
# end
526+
# r_0, v_0, a_0 = collect.((r_0, v_0, a_0))
527+
528+
# eqs = [r_0 .~ collect(frame_a.r_0)
529+
# v_0 .~ D.(r_0)
530+
# a_0 .~ D.(v_0)
531+
# connect(frame_a, frameTranslation.frame_a)
532+
# connect(frame_b, frameTranslation.frame_b)
533+
# connect(frame_a, body.frame_a)]
534+
535+
# # pars = [
536+
# # dir; length; diameter; inner_diameter; density
537+
# # ]
538+
# # vars = [r_0; v_0; a_0]
539+
# # ODESystem(eqs, t, vars, pars; name, systems)
540+
# ODESystem(eqs, t; name, systems)
541+
# end
542+
543+
544+
@mtkmodel BodyCylinder begin
545+
546+
@structural_parameters begin
547+
r = [1, 0, 0]
548+
r_shape = [0, 0, 0]
549+
end
550+
551+
@parameters begin
552+
# r[1:3]=r, [ # MTKs symbolic language is too weak to handle this as a symbolic parameter in from_nxy
553+
# description = "Vector from frame_a to frame_b resolved in frame_a",
554+
# ]
555+
# r_shape[1:3]=zeros(3), [
556+
# description = "Vector from frame_a to cylinder origin, resolved in frame_a",
557+
# ]
558+
dir[1:3] = r - r_shape, [
559+
description = "Vector in length direction of cylinder, resolved in frame_a",
560+
]
561+
length = _norm(r - r_shape), [
562+
description = "Length of cylinder",
563+
]
564+
length2 = _norm(r - r_shape), [ # NOTE: strange bug in JSCompiler when both I and r_cm that are parameters of Body depend on the same paramter length. Introducing a dummy parameter with the same value works around the issue. This is not ideal though, since the two parameters must have the same value.
565+
description = "Length of cylinder",
566+
]
567+
diameter = 1, [#length/5, [
568+
description = "Diameter of cylinder",
569+
]
570+
inner_diameter = 0, [
571+
description = "Inner diameter of cylinder (0 <= inner_diameter <= diameter)",
572+
]
573+
density = 7700, [
574+
description = "Density of cylinder (e.g., steel: 7700 .. 7900, wood : 400 .. 800)",
575+
]
576+
end
577+
begin
578+
radius = diameter/2
579+
innerRadius = inner_diameter/2
580+
mo = density*pi*length*radius^2
581+
mi = density*pi*length*innerRadius^2
582+
I22 = (mo*(length^2 + 3*radius^2) - mi*(length^2 + 3*innerRadius^2))/12
583+
m = mo - mi
584+
R = from_nxy(r, [0, 1, 0])
585+
r_cm = r_shape + _normalize(dir)*length2/2
586+
I = resolve_dyade1(R, Diagonal([(mo*radius^2 - mi*innerRadius^2)/2, I22, I22]))
587+
end
588+
589+
@variables begin
590+
r_0(t)[1:3]=0, [
591+
state_priority = 2,
592+
description = "Position vector from origin of world frame to origin of frame_a",
593+
]
594+
v_0(t)[1:3]=0, [
595+
state_priority = 2,
596+
description = "Absolute velocity of frame_a, resolved in world frame (= D(r_0))",
597+
]
598+
a_0(t)[1:3]=0, [
599+
description = "Absolute acceleration of frame_a resolved in world frame (= D(v_0))",
600+
]
601+
end
602+
begin
603+
r_cm = collect(r_cm)
604+
end
605+
@components begin
606+
frame_a = Frame()
607+
frame_b = Frame()
608+
frameTranslation = FixedTranslation(r = r)
609+
body = Body(; m, r_cm, I_11 = I[1,1], I_22 = I[2,2], I_33 = I[3,3], I_21 = I[2,1], I_31 = I[3,1], I_32 = I[3,2])
610+
end
611+
612+
@equations begin
613+
r_0[1] ~ ((frame_a.r_0)[1])
614+
r_0[2] ~ ((frame_a.r_0)[2])
615+
r_0[3] ~ ((frame_a.r_0)[3])
616+
v_0[1] ~ D(r_0[1])
617+
v_0[2] ~ D(r_0[2])
618+
v_0[3] ~ D(r_0[3])
619+
a_0[1] ~ D(v_0[1])
620+
a_0[2] ~ D(v_0[2])
621+
a_0[3] ~ D(v_0[3])
622+
connect(frame_a, frameTranslation.frame_a)
623+
connect(frame_b, frameTranslation.frame_b)
624+
connect(frame_a, body.frame_a)
625+
end
626+
end

0 commit comments

Comments
 (0)