LIBRARY
tests.GearConstraintTest
Gear Constraint Test
Ported from the Multibody.jl GearConstraint test (basic_tests.jl). Two parallel subsystems with the same 10:1 gear ratio:
3D side: a
GearConstraintcouples twoBodyinstances mounted on the world via the constraint'sbearingframe; a 3DTorqueapplies[2*sin(t), 0, 0]between world and the first body.1D side: a 1D
IdealGearbetween twoInertiainstances (with the sameJas the bodies), driven by a 1D torque source2*sin(t).
Both subsystems should follow the gear-ratio relation, so the angles and torques on either side of the 1D gear differ by a factor of ratio.
Usage
MultibodyComponents.tests.GearConstraintTest(ratio=10, J=0.001)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
ratio | – | 10 | |
J | kg.m2 | 0.001 |
Behavior
Source
dyad
"""
# Gear Constraint Test
Ported from the Multibody.jl GearConstraint test (basic_tests.jl).
Two parallel subsystems with the same 10:1 gear ratio:
- 3D side: a `GearConstraint` couples two `Body` instances mounted on the
world via the constraint's `bearing` frame; a 3D `Torque` applies
`[2*sin(t), 0, 0]` between world and the first body.
- 1D side: a 1D `IdealGear` between two `Inertia` instances (with the same
`J` as the bodies), driven by a 1D torque source `2*sin(t)`.
Both subsystems should follow the gear-ratio relation, so the angles and
torques on either side of the 1D gear differ by a factor of `ratio`.
"""
example component GearConstraintTest
# Common world
world = MultibodyComponents.World() {}
# 3D gear-constraint subsystem
gear = MultibodyComponents.GearConstraint(ratio = ratio, n_a = [1, 0, 0], n_b = [1, 0, 0], phi_b(initial = 0), w_b(initial = 0)) {}
cyl1 = MultibodyComponents.Body(m = 1, r_cm = [0.4, 0, 0], I_11 = J) {}
cyl2 = MultibodyComponents.Body(m = 1, r_cm = [0.4, 0, 0], I_11 = J) {}
torque1 = MultibodyComponents.Torque(resolve_in_frame = ResolveInFrame.FrameB()) {}
# 1D rotational subsystem (mirror of the 3D side)
inertia1 = RotationalComponents.Components.Inertia(J = J) {}
ideal_gear = RotationalComponents.Components.IdealGear(ratio = ratio) {}
inertia2 = RotationalComponents.Components.Inertia(J = J) {}
torque2 = RotationalComponents.Sources.TorqueSource() {}
rot_ground = RotationalComponents.Components.Fixed() {}
parameter ratio::Real = 10
parameter J::Inertia = 0.001
relations
initial inertia1.phi = 0
initial inertia1.w = 0
# 3D side
connect(world.frame_b, gear.bearing) {}
connect(gear.frame_a, cyl1.frame_a, torque1.frame_b) {}
connect(gear.frame_b, cyl2.frame_a) {}
connect(world.frame_b, torque1.frame_a) {}
torque1.torque_x = 2 * sin(time)
torque1.torque_y = 0
torque1.torque_z = 0
# 1D side
connect(torque2.spline, inertia1.spline_a) {}
connect(inertia1.spline_b, ideal_gear.spline_a) {}
connect(ideal_gear.spline_b, inertia2.spline_a) {}
connect(rot_ground.spline, ideal_gear.support, torque2.support) {}
torque2.tau = 2 * sin(time)
endFlattened Source
dyad
"""
# Gear Constraint Test
Ported from the Multibody.jl GearConstraint test (basic_tests.jl).
Two parallel subsystems with the same 10:1 gear ratio:
- 3D side: a `GearConstraint` couples two `Body` instances mounted on the
world via the constraint's `bearing` frame; a 3D `Torque` applies
`[2*sin(t), 0, 0]` between world and the first body.
- 1D side: a 1D `IdealGear` between two `Inertia` instances (with the same
`J` as the bodies), driven by a 1D torque source `2*sin(t)`.
Both subsystems should follow the gear-ratio relation, so the angles and
torques on either side of the 1D gear differ by a factor of `ratio`.
"""
example component GearConstraintTest
# Common world
world = MultibodyComponents.World() {}
# 3D gear-constraint subsystem
gear = MultibodyComponents.GearConstraint(ratio = ratio, n_a = [1, 0, 0], n_b = [1, 0, 0], phi_b(initial = 0), w_b(initial = 0)) {}
cyl1 = MultibodyComponents.Body(m = 1, r_cm = [0.4, 0, 0], I_11 = J) {}
cyl2 = MultibodyComponents.Body(m = 1, r_cm = [0.4, 0, 0], I_11 = J) {}
torque1 = MultibodyComponents.Torque(resolve_in_frame = ResolveInFrame.FrameB()) {}
# 1D rotational subsystem (mirror of the 3D side)
inertia1 = RotationalComponents.Components.Inertia(J = J) {}
ideal_gear = RotationalComponents.Components.IdealGear(ratio = ratio) {}
inertia2 = RotationalComponents.Components.Inertia(J = J) {}
torque2 = RotationalComponents.Sources.TorqueSource() {}
rot_ground = RotationalComponents.Components.Fixed() {}
parameter ratio::Real = 10
parameter J::Inertia = 0.001
relations
initial inertia1.phi = 0
initial inertia1.w = 0
# 3D side
connect(world.frame_b, gear.bearing) {}
connect(gear.frame_a, cyl1.frame_a, torque1.frame_b) {}
connect(gear.frame_b, cyl2.frame_a) {}
connect(world.frame_b, torque1.frame_a) {}
torque1.torque_x = 2 * sin(time)
torque1.torque_y = 0
torque1.torque_z = 0
# 1D side
connect(torque2.spline, inertia1.spline_a) {}
connect(inertia1.spline_b, ideal_gear.spline_a) {}
connect(ideal_gear.spline_b, inertia2.spline_a) {}
connect(rot_ground.spline, ideal_gear.support, torque2.support) {}
torque2.tau = 2 * sin(time)
metadata {}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses