Skip to content

Commit 5cd1e2d

Browse files
authored
Merge pull request #121 from JuliaComputing/cut_wheelset
add cut option to connect multiple wheel sets to the same body
2 parents 0ef1a24 + 9128e00 commit 5cd1e2d

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

src/wheels.jl

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,19 @@ end
347347
theta2_0 = 0,
348348
der_theta1_0 = 0,
349349
der_theta2_0 = 0,
350-
render = true
350+
render = true,
351+
iscut = false,
351352
)
353+
352354
Joint (no mass, no inertia) that describes an ideal rolling wheel set (two ideal rolling wheels connected together by an axis)
353355
354356
An assembly joint for a wheelset rolling on the x-z plane of the world frame. The frames `frame1` and `frame2` are connected to rotating wheels; the `frame_middle` moves in a plane parallel to the x-z plane of the world and should be connected to the vehicle body.
355357
356358
To work properly, the gravity acceleration vector g of the world must point in the negative y-axis (default)
357359
360+
# Arguments and parameters:
361+
- `iscut`: if more than one wheel set is connected to the same rigid body, `iscut` must be set to true for all but one set. This avoids overconstraining the system by replacing the planar joint giving the set coordinates by an unconstrained FreeMotion joint.
362+
358363
# Connectors:
359364
- `frame_middle`: Frame fixed in middle of axis connecting both wheels (z-axis: along wheel axis, y-axis: upwards)
360365
- `frame1`: Frame fixed in center point of left wheel (z-axis: along wheel axis, y-axis: upwards)
@@ -393,9 +398,6 @@ function RollingWheelSetJoint(;
393398
frame2 = Frame()
394399
fixed = Fixed(; r = [0, radius, 0], render)
395400
rod1 = FixedTranslation(; r = [0, 0, track / 2], render, color)
396-
prismatic1 = Prismatic(; n = [1, 0, 0], render, state_priority=10, color=[0,1,1,0.1], radius=0.01)
397-
prismatic2 = Prismatic(; n = [0, 0, 1], render, state_priority=10, color=[0,1,1,0.1], radius=0.01)
398-
revolute = Revolute(; render, n = [0, 1, 0], color)
399401
rod2 = FixedTranslation(; r = [0, 0, -track / 2], render, color)
400402
revolute1 = Revolute(; n = [0, 0, 1], axisflange = true, render, state_priority=11, radius, length=width_wheel, color)
401403
revolute2 = Revolute(; n = [0, 0, 1], axisflange = true, render, state_priority=11, radius, length=width_wheel, color)
@@ -406,6 +408,17 @@ function RollingWheelSetJoint(;
406408
mounting1D = Mounting1D()
407409
support = Rotational.Flange()
408410
end
411+
if iscut
412+
@named freemotion = FreeMotion(iscut=false, isroot=true, state=false)
413+
push!(systems, freemotion)
414+
else
415+
more = @named begin
416+
revolute = Revolute(; render, n = [0, 1, 0], color)
417+
prismatic1 = Prismatic(; n = [1, 0, 0], render, state_priority=10, color=[0,1,1,0.1], radius=0.01)
418+
prismatic2 = Prismatic(; n = [0, 0, 1], render, state_priority=10, color=[0,1,1,0.1], radius=0.01)
419+
end
420+
append!(systems, more)
421+
end
409422

410423
sts = @variables begin
411424
(x(t) = x0), [description = "x coordinate for center between wheels", state_priority = state_priority]
@@ -417,24 +430,37 @@ function RollingWheelSetJoint(;
417430
(der_theta2(t) = der_theta2_0), [description = "Derivative of theta 2", state_priority = state_priority]
418431
end
419432
equations = Equation[
420-
prismatic1.s ~ x
421-
prismatic2.s ~ z
422-
revolute.phi ~ phi
433+
if iscut
434+
[
435+
connect(freemotion.frame_a, fixed.frame_b)
436+
connect(freemotion.frame_b, frame_middle)
437+
freemotion.r_rel_a[1] ~ x
438+
freemotion.r_rel_a[3] ~ z
439+
# freemotion.phi[2] ~ phi
440+
phi ~ 0
441+
]
442+
else
443+
[prismatic1.s ~ x
444+
prismatic2.s ~ z
445+
revolute.phi ~ phi
446+
connect(revolute.frame_b, frame_middle)
447+
connect(prismatic1.frame_a, fixed.frame_b)
448+
connect(prismatic1.frame_b, prismatic2.frame_a)
449+
connect(prismatic2.frame_b, revolute.frame_a)]
450+
end
451+
423452
revolute1.phi ~ theta1
424453
revolute2.phi ~ theta2
425454
der_theta1 ~ D(theta1)
426455
der_theta2 ~ D(theta2)
427456

428-
connect(revolute.frame_b, frame_middle)
429457
connect(rod1.frame_a, frame_middle)
430458
connect(rod2.frame_a, frame_middle)
431459
connect(rod1.frame_b, revolute1.frame_a)
432460
connect(revolute1.frame_b, frame1)
433461
connect(revolute2.frame_a, rod2.frame_b)
434462
connect(revolute2.frame_b, frame2)
435-
connect(prismatic1.frame_a, fixed.frame_b)
436-
connect(prismatic1.frame_b, prismatic2.frame_a)
437-
connect(prismatic2.frame_b, revolute.frame_a)
463+
438464
connect(rolling1.frame_a, revolute1.frame_b)
439465
connect(rolling2.frame_a, revolute2.frame_b)
440466
connect(revolute1.axis, axis1)
@@ -465,12 +491,16 @@ end
465491
width_wheel = 0.01,
466492
color = [0.3, 0.3, 0.3, 1],
467493
render = true,
494+
iscut = false,
468495
)
469496
470497
Ideal rolling wheel set consisting of two ideal rolling wheels connected together by an axis
471498
472499
Two wheels are connected by an axis and can rotate around this axis. The wheels are rolling on the x-z plane of the world frame. The coordinate system attached to the center of the wheel axis (`frame_middle`) is constrained so that it is always parallel to the x-z plane. If all generalized coordinates are zero, `frame_middle` is parallel to the world frame.
473500
501+
# Arguments and parameters:
502+
- `iscut`: if more than one wheel set is connected to the same rigid body, `iscut` must be set to true for all but one set. This avoids overconstraining the system by replacing the planar joint giving the set coordinates by an unconstrained FreeMotion joint.
503+
474504
# Connectors
475505
- `frame_middle`: Frame fixed in middle of axis connecting both wheels (z-axis: along wheel axis, y-axis: upwards)
476506
- `frame1`: Frame fixed in center point of left wheel (z-axis: along wheel axis, y-axis: upwards)

0 commit comments

Comments
 (0)