Skip to content

Commit 61f19a3

Browse files
Add AbsolutePoision sensor to AbsoluteAccCentrifugal test
1 parent fcc3707 commit 61f19a3

3 files changed

Lines changed: 28 additions & 13 deletions

File tree

src/Mechanical/PlanarMechanics/components.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ A fixed translation between two components (rigid rod)
123123
@extend frame_a, frame_b = partial_frames = PartialTwoFrames()
124124

125125
@parameters begin
126-
rx,
126+
rx = 0,
127127
[
128128
description = "Fixed x-length of the rod resolved w.r.t to body frame_a at phi = 0",
129129
]
130-
ry,
130+
ry = 0,
131131
[
132132
description = "Fixed y-length of the rod resolved w.r.t to body frame_a at phi = 0",
133133
]

src/Mechanical/PlanarMechanics/joints.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@ A revolute joint
2121
- `support` [Support](@ref) if `use_flange == true`
2222
2323
"""
24-
@component function Revolute(; name, phi = 0.0, ω = 0.0, tau = 0.0, use_flange = false)
24+
@component function Revolute(;
25+
name,
26+
constant_phi = nothing,
27+
constant_ω = nothing,
28+
constat_tau = nothing,
29+
use_flange = false)
2530
@named partial_frames = PartialTwoFrames()
2631
@unpack frame_a, frame_b = partial_frames
2732
@named fixed = Rotational.Fixed()
2833
systems = [frame_a, frame_b, fixed]
2934

3035
vars = @variables begin
31-
phi(t) = phi
32-
ω(t) = ω
36+
phi(t) = 0.0
37+
ω(t) = 0.0
3338
α(t) = 0.0
34-
j(t) = tau
39+
j(t) = 0.0
3540
end
3641

3742
eqs = [
38-
ω ~ D(phi),
39-
α ~ D(ω),
43+
phi ~ ifelse(constant_phi === nothing, phi, constant_phi),
44+
ω ~ ifelse(constant_ω === nothing, D(phi), constant_ω),
45+
α ~ ifelse(constant_ω === nothing, D(ω), 0.0),
4046
# rigidly connect positions
4147
frame_a.x ~ frame_b.x,
4248
frame_a.y ~ frame_b.y,
@@ -46,6 +52,7 @@ A revolute joint
4652
frame_a.fy + frame_b.fy ~ 0,
4753
# balance torques
4854
frame_a.j + frame_b.j ~ 0,
55+
j ~ ifelse(constat_tau === nothing, j, constat_tau),
4956
frame_a.j ~ j,
5057
]
5158

test/Mechanical/planar_mechanics.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434
@named ceiling = Fixed()
3535
@named rod = FixedTranslation(rx = 1.0, ry = 0.0)
3636
@named body = Body(m = 1, j = 0.1)
37-
@named revolute = Revolute(phi = 0.0, ω = 0.0)
37+
@named revolute = Revolute()
3838

3939
connections = [
4040
connect(ceiling.frame, revolute.frame_a),
@@ -65,18 +65,25 @@ end
6565
m = 1
6666
j = 0.1
6767
ω = 10
68-
resolve_in_frame = :world
6968

7069
# components
7170
@named body = Body(; m, j, gy = 0.0)
7271
@named fixed_translation = FixedTranslation(; rx = 10.0, ry = 0.0)
7372
@named fixed = Fixed()
74-
@named revolute = Revolute= ω)
73+
@named revolute = Revolute(constant_ω = ω)
74+
75+
# sensors
76+
@named abs_pos_sensor = AbsolutePosition()
7577

7678
eqs = [
77-
connect(fixed_translation.frame_b, body.frame),
7879
connect(fixed.frame, revolute.frame_a),
7980
connect(revolute.frame_b, fixed_translation.frame_a),
81+
connect(fixed_translation.frame_b, body.frame),
82+
connect(abs_pos_sensor.frame_a, body.frame),
83+
# TODO: the following equations shouldn't be necessary
84+
body.ω ~ revolute.ω,
85+
fixed.frame.fy ~ -body.fy,
86+
fixed.frame.fx ~ -body.fx,
8087
]
8188

8289
@named model = ODESystem(eqs,
@@ -88,9 +95,10 @@ end
8895
fixed_translation,
8996
fixed,
9097
revolute,
98+
abs_pos_sensor,
9199
])
92100
sys = structural_simplify(model)
93-
prob = ODEProblem(sys, [0.0, 10.0, 0.0], tspan, []; jac = true)
101+
prob = ODEProblem(sys, [0.0], tspan, []; jac = true)
94102
sol = solve(prob, Rodas5P())
95103

96104
# phi

0 commit comments

Comments
 (0)