You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/components.jl
+176-1Lines changed: 176 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -320,7 +320,7 @@ Representing a body with 3 translational and 3 rotational degrees-of-freedom.
320
320
end
321
321
collect(frame_a.tau .~ I * z_a +cross(w_a, I * w_a) +cross(r_cm, frame_a.f))]
322
322
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]
324
324
325
325
sys =ODESystem(eqs, t; name=:nothing, metadata =Dict(:isroot=> isroot), systems = [frame_a])
326
326
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
449
449
450
450
ODESystem(eqs, t; name, systems = [systems; links; joints])
451
451
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.
# # 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_parametersbegin
547
+
r = [1, 0, 0]
548
+
r_shape = [0, 0, 0]
549
+
end
550
+
551
+
@parametersbegin
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)",
0 commit comments