Skip to content

Commit cb652cb

Browse files
committed
pass some parameters along
1 parent 0442f7e commit cb652cb

2 files changed

Lines changed: 25 additions & 27 deletions

File tree

docs/src/examples/prescribed_pose.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,34 @@ BP = 129.03 / 1000
4141
DE = 310.31 / 1000
4242
t5 = 19.84 |> deg2rad
4343
44-
@component function QuarterCarSuspension(; name, spring = true, jc = [0.5, 0.5, 0.5, 0.7], mirror = false)
44+
@component function QuarterCarSuspension(; name, spring = true, jc = [0.5, 0.5, 0.5, 0.7], mirror = false,
45+
cs = 4000, ks = 44000, rod_radius = 0.02, jr = 0.03)
4546
dir = mirror ? -1 : 1
4647
rRod1_ia = AB*normalize([0, -0.1, 0.2dir])
4748
rRod2_ib = BC*normalize([0, 0.2, 0dir])
4849
4950
pars = @parameters begin
50-
cs = 4000, [description = "Damping constant [Ns/m]"]
51-
ks = 44000, [description = "Spring constant [N/m]"]
52-
rod_radius = 0.02
53-
jr = 0.03, [description = "Radius of revolute joint"]
51+
cs = cs, [description = "Damping constant [Ns/m]"]
52+
ks = ks, [description = "Spring constant [N/m]"]
53+
rod_radius = rod_radius
54+
jr = jr, [description = "Radius of revolute joint"]
5455
end
55-
5656
systems = @named begin
5757
r123 = JointRRR(n_a = n*dir, n_b = n*dir, rRod1_ia, rRod2_ib, rod_radius=0.018, rod_color=jc)
5858
r2 = Revolute(; n=n*dir, radius=jr, color=jc)
5959
b1 = FixedTranslation(radius = rod_radius, r = CD*normalize([0, -0.1, 0.3dir])) # CD
6060
chassis = FixedTranslation(r = DA*normalize([0, 0.2, 0.2*sin(t5)*dir]), render=false)
6161
chassis_frame = Frame()
6262
63+
end
6364
if spring
64-
springdamper = SpringDamperParallel(c = ks, d = cs, s_unstretched = 1.3*BC, radius=rod_radius, num_windings=10)
65-
end
66-
if spring
67-
spring_mount_F = FixedTranslation(r = 0.7*CD*normalize([0, -0.1, 0.3dir]), render=false)
68-
end
69-
if spring
70-
spring_mount_E = FixedTranslation(r = 1.3DA*normalize([0, 0.2, 0.2*sin(t5)*dir]), render=true)
65+
more_systems = @named begin
66+
springdamper = SpringDamperParallel(c = ks, d = cs, s_unstretched = 1.3*BC, radius=rod_radius, num_windings=10)
67+
spring_mount_F = FixedTranslation(r = 0.7*CD*normalize([0, -0.1, 0.3dir]), render=false)
68+
spring_mount_E = FixedTranslation(r = 1.3DA*normalize([0, 0.2, 0.2*sin(t5)*dir]), render=true)
69+
end
70+
systems = [systems; more_systems]
7171
end
72-
end
7372
7473
A = chassis.frame_b
7574
D = chassis.frame_a
@@ -98,9 +97,9 @@ t5 = 19.84 |> deg2rad
9897
return System(equations, t; name, systems)
9998
end
10099
101-
@component function ExcitedWheelAssembly(; name)
100+
@component function ExcitedWheelAssembly(; name, rod_radius = 0.02)
102101
pars = @parameters begin
103-
rod_radius = 0.02
102+
rod_radius = rod_radius
104103
end
105104
106105
systems = @named begin
@@ -131,10 +130,10 @@ end
131130
end
132131
133132
134-
@component function SuspensionWithExcitationAndMass(; name)
133+
@component function SuspensionWithExcitationAndMass(; name, rod_radius = 0.02, ms=1500/4)
135134
pars = @parameters begin
136-
ms = 1500/4, [description = "Mass of the car [kg]"]
137-
rod_radius = 0.02
135+
ms = ms, [description = "Mass of the car [kg]"]
136+
rod_radius = rod_radius
138137
end
139138
140139
systems = @named begin
@@ -155,14 +154,13 @@ end
155154
end
156155
157156
@named model = SuspensionWithExcitationAndMass()
158-
model = complete(model)
159157
ssys = multibody(model)
160158
display([unknowns(ssys) diag(ssys.mass_matrix)])
161159
162160
defs = [
163-
model.excited_suspension.suspension.ks => 30*44000
164-
model.excited_suspension.suspension.cs => 30*4000
165-
model.excited_suspension.suspension.r2.phi => -0.6031*(1)
161+
ssys.excited_suspension.suspension.ks => 30*44000
162+
ssys.excited_suspension.suspension.cs => 30*4000
163+
ssys.excited_suspension.suspension.r2.phi => -0.6031*(1)
166164
]
167165
prob = ODEProblem(ssys, defs, (0, 2π))
168166
sol = solve(prob, Rodas5P(autodiff=false), initializealg = BrownFullBasicInit())

src/fancy_joints.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ end
489489
ori(frame_b) ~ Rb
490490
# ori(frame_b).w ~ Rb.w
491491

492-
0 ~ frame_a.f + resolve1(Rrel, frame_b.f)
493-
0 ~ frame_a.tau + resolve1(Rrel, frame_b.tau)
492+
zeros(3) ~ frame_a.f + resolve1(Rrel, frame_b.f)
493+
zeros(3) ~ frame_a.tau + resolve1(Rrel, frame_b.tau)
494494

495495
if use_arrays
496496
angle ~ compute_angle2(length_constraint, e, r_a, r_b, positive_branch)[1]
@@ -649,9 +649,9 @@ The rest of this joint aggregation is defined by the following parameters:
649649

650650
end
651651

652-
@component function Constant3(; name)
652+
@component function Constant3(; name, k = zeros(3))
653653
pars = @parameters begin
654-
k[1:3] = zeros(3), [description = "Constant output value of block"]
654+
k[1:3] = k, [description = "Constant output value of block"]
655655
end
656656

657657
systems = @named begin

0 commit comments

Comments
 (0)