Skip to content

Commit 3a9340b

Browse files
Revert "Fix Pendulum model, and break AbsoluteAccCentrifugal while doing so"
This reverts commit f454f1b.
1 parent 78d0f86 commit 3a9340b

File tree

4 files changed

+34
-43
lines changed

4 files changed

+34
-43
lines changed

src/Mechanical/PlanarMechanics/components.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Frame fixed in the planar world frame at a given position and orientation
1212
# Connectors:
1313
1414
- `frame: 2-dim. Coordinate system
15-
16-
https://github.com/dzimmer/PlanarMechanics/blob/743462f58858a808202be93b708391461cbe2523/PlanarMechanics/Parts/Fixed.mo
1715
"""
1816
@mtkmodel Fixed begin
1917
@parameters begin
@@ -60,8 +58,6 @@ Body component with mass and inertia
6058
# Connectors:
6159
6260
- `frame`: 2-dim. Coordinate system
63-
64-
https://github.com/dzimmer/PlanarMechanics/blob/743462f58858a808202be93b708391461cbe2523/PlanarMechanics/Parts/Body.mo
6561
"""
6662
@component function Body(; name, m, j, rx = 0, ry = 0, gy = -9.807)
6763
@named frame = Frame()
@@ -119,11 +115,9 @@ A fixed translation between two components (rigid rod)
119115
- `ry`: [m] Fixed y-length of the rod resolved w.r.t to body frame_a at phi = 0
120116
121117
# Connectors:
122-
118+
123119
- `frame_a` [Frame](@ref) Coordinate system fixed to the component with one cut-force and cut-torque
124120
- `frame_b` [Frame](@ref) Coordinate system fixed to the component with one cut-force and cut-torque
125-
126-
https://github.com/dzimmer/PlanarMechanics/blob/743462f58858a808202be93b708391461cbe2523/PlanarMechanics/Parts/FixedTranslation.mo
127121
"""
128122
@mtkmodel FixedTranslation begin
129123
@extend frame_a, frame_b = partial_frames = PartialTwoFrames()
@@ -147,12 +141,12 @@ https://github.com/dzimmer/PlanarMechanics/blob/743462f58858a808202be93b70839146
147141

148142
@equations begin
149143
# rigidly connect positions
150-
frame_a.x + rx ~ frame_b.x
151-
frame_a.y + ry ~ frame_b.y
144+
frame_a.x + r0[1] ~ frame_b.x
145+
frame_a.y + r0[2] ~ frame_b.y
152146
frame_a.phi ~ frame_b.phi
153147
# balancing force including lever principle
154148
frame_a.fx + frame_b.fx ~ 0
155149
frame_a.fy + frame_b.fy ~ 0
156-
frame_a.j + frame_b.j + r0' * [frame_b.fy, -frame_b.fx] ~ 0
150+
frame_a.j + frame_b.j + r0[1] * frame_b.fy - r0[2] * frame_b.fx ~ 0
157151
end
158152
end

src/Mechanical/PlanarMechanics/joints.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ A revolute joint
1919
- `fixed` [Fixed](@ref) if `use_flange == false`
2020
- `flange_a` [Flange](@ref) if `use_flange == true`
2121
- `support` [Support](@ref) if `use_flange == true`
22-
https://github.com/dzimmer/PlanarMechanics/blob/master/PlanarMechanics/Joints/Revolute.mo
22+
2323
"""
2424
@component function Revolute(;
25-
name,
26-
constant_phi = nothing,
27-
constant_ω = nothing,
28-
constat_tau = nothing,
29-
use_flange = false)
25+
name,
26+
constant_phi = nothing,
27+
constant_ω = nothing,
28+
constat_tau = nothing,
29+
use_flange = false)
3030
@named partial_frames = PartialTwoFrames()
3131
@unpack frame_a, frame_b = partial_frames
3232
@named fixed = Rotational.Fixed()
@@ -98,12 +98,12 @@ A prismatic joint
9898
- `support` [Support](@ref) if `use_flange == true`
9999
"""
100100
@component function Prismatic(;
101-
name,
102-
x,
103-
y,
104-
constant_f = 0,
105-
constant_s = 0,
106-
use_flange = false)
101+
name,
102+
x,
103+
y,
104+
constant_f = 0,
105+
constant_s = 0,
106+
use_flange = false)
107107
@named partial_frames = PartialTwoFrames()
108108
@unpack frame_a, frame_b = partial_frames
109109
@named fixed = TranslationalModelica.Support()

src/Mechanical/PlanarMechanics/sensors.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ Measure relative position and orientation between the origins of two frame conne
309309
end
310310

311311
@component function BasicTransformAbsoluteVector(;
312-
name,
313-
frame_in = :frame_a,
314-
frame_out = frame_in)
312+
name,
313+
frame_in = :frame_a,
314+
frame_out = frame_in)
315315
@named x_in = RealInput()
316316
@named y_in = RealInput()
317317
@named phi_in = RealInput()
@@ -399,9 +399,9 @@ end
399399
end
400400

401401
@component function TransformAbsoluteVector(;
402-
name,
403-
frame_in = :frame_a,
404-
frame_out = frame_in)
402+
name,
403+
frame_in = :frame_a,
404+
frame_out = frame_in)
405405
@named frame_a = Frame()
406406

407407
@named x_in = RealInput()
@@ -493,9 +493,9 @@ end
493493
end
494494

495495
@component function BasicTransformRelativeVector(;
496-
name,
497-
frame_in = :frame_a,
498-
frame_out = frame_in)
496+
name,
497+
frame_in = :frame_a,
498+
frame_out = frame_in)
499499
@named x_in = RealInput()
500500
@named y_in = RealInput()
501501
@named phi_in = RealInput()
@@ -578,9 +578,9 @@ end
578578
end
579579

580580
@component function TransformRelativeVector(;
581-
name,
582-
frame_in = :frame_a,
583-
frame_out = frame_in)
581+
name,
582+
frame_in = :frame_a,
583+
frame_out = frame_in)
584584
@named x_in = RealInput()
585585
@named y_in = RealInput()
586586
@named phi_in = RealInput()
@@ -801,4 +801,4 @@ function connect_sensor(component_frame, sensor_frame)
801801
component_frame.y ~ sensor_frame.y,
802802
component_frame.phi ~ sensor_frame.phi,
803803
]
804-
end
804+
end

test/Mechanical/planar_mechanics.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ end
4848
[],
4949
systems = [body, revolute, rod, ceiling])
5050
sys = structural_simplify(model)
51-
@test length(states(sys)) == 2
52-
unset_vars = setdiff(states(sys), keys(ModelingToolkit.defaults(sys)))
53-
prob = ODEProblem(sys, unset_vars .=> 0.0, tspan, [])
54-
sol = solve(prob, Rodas5P())
55-
@test SciMLBase.successful_retcode(sol)
51+
52+
@test length(states(sys)) == 7
5653
end
5754

5855
@testset "Prismatic" begin
@@ -95,7 +92,7 @@ end
9592
abs_v_sensor,
9693
])
9794
sys = structural_simplify(model)
98-
u0 = [0.0, ω]
95+
u0 = [0.0, ω, 0.0]
9996
prob = ODEProblem(sys, u0, tspan, []; jac = true)
10097
sol = solve(prob, Rodas5P())
10198

@@ -107,11 +104,11 @@ end
107104

108105
# instantaneous linear velocity
109106
v_singal(t) = -ω^2 * sin.(ω .* t)
110-
@test_broken all(v_singal.(test_points) .≈ sol.(test_points; idxs = abs_v_sensor.v_x.u))
107+
@test all(v_singal.(test_points) .≈ sol.(test_points; idxs = abs_v_sensor.v_x.u))
111108

112109
# instantaneous linear acceleration
113110
a_singal(t) = -ω^3 * cos.(ω .* t)
114-
@test_broken all(a_singal.(test_points) .≈ sol.(test_points; idxs = body.ax))
111+
@test all(a_singal.(test_points) .≈ sol.(test_points; idxs = body.ax))
115112
end
116113

117114
@testset "Sensors (two free falling bodies)" begin

0 commit comments

Comments
 (0)