# No. 4, Pulleys with Right Angle Transition (Brown 1868, p. 1).
#
# "A method of transmitting motion from a shaft at right angles to another whose axis is in the same
# plane. This is shown with a crossed belt. An open belt may be used, but the crossed one is
# preferable, as it gives more surface of contact."
#
# Layout from the plate (1 unit = 1 cm; driving pulley r 9 = 58 px of the engraving): the driving
# pulley at the top on a shaft towards the reader; a crossed cord from it down to two guide pulleys at
# the lower corners, over their outsides and in along the bottom to an upright drum in the middle,
# round which it takes a full turn in a spiral before going on. The upright shaft and the driver's
# shaft are at right angles and meet (their axes are in one plane). The guides stand a little apart
# front to back (±1.7) so the crossing leaves pass each other; the full turn on the drum advances 1.2
# up its shaft, so the right guide stands 1.2 higher than the left.
#
# Fully physical: only the driving pulley is motor-driven. The cord is a closed chain of elastic links
# on the common tangents in space (src/geom/path3d.ts), pretensioned; the guides and the drum turn by
# friction alone, and the crossing leaves rub past each other.
number: 4
slug: pulleys-with-right-angle-transition
name: Pulleys with Right Angle Transition
brown: "A method of transmitting motion from a shaft at right angles to another whose axis is in the same plane. This is shown with a crossed belt. An open belt may be used, but the crossed one is preferable, as it gives more surface of contact."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 50, duration_s: 8, floor: false}
bodies:
  - {id: p_top, shape: pulley, radius: 9, width: 3, groove: 1.2, flange: 0.6, pos: [0, -5.8, 49], mass: 2.0, spokes: 4, hub: 2.4}
  # The guides, each on a stud set square to the plane of its own leaf and bottom run (about 4° off
  # the driver's shaft), so the cord enters and leaves each in its plane.
  - {id: g_left, shape: assembly, pos: [-23, -7.5, 5.3], color: "#e6dcc4"}
  - {id: g_right, shape: assembly, pos: [23, -4.1, 6.5], color: "#e6dcc4"}
  # the upright drum, its shaft at right angles to the driver's and meeting it
  - {id: drum, shape: assembly, pos: [0, 0, 0], color: "#ded2b6"}
wheels:
  - {id: gl, body: g_left, pos: [0, 0, 0], quat: [0.999356, 0.005406, 0, 0.035463], radius: 5, width: 2.4, groove: 1.2, flange: 0.5, mass: 0.5, spokes: 0, hub: 1.1, color: "#e6dcc4"}
  - {id: gr, body: g_right, pos: [0, 0, 0], quat: [0.999334, -0.005927, 0, 0.035999], radius: 5, width: 2.4, groove: 1.2, flange: 0.5, mass: 0.5, spokes: 0, hub: 1.1, color: "#e6dcc4"}
  - {id: p_drum, body: drum, pos: [0, 0, 0.6], quat: [0.7071068, 0.7071068, 0, 0], radius: 5.5, width: 6, groove: 4, flange: 0.6, mass: 1.2, spokes: 0, hub: 4.6, color: "#ded2b6"}
shafts:
  - {id: drum_shaft, body: drum, from: [0, 0, -6], to: [0, 0, 6], radius: 0.6}
joints:
  - {id: j_top, type: hinge, body: p_top, axis: [0, 1, 0], damping: 0.002}
  - {id: j_left, type: hinge, body: g_left, axis: [-0.07088, 0.99743, 0.01081], damping: 0.0005}
  - {id: j_right, type: hinge, body: g_right, axis: [-0.07195, 0.99734, -0.01185], damping: 0.0005}
  - {id: j_drum, type: hinge, body: drum, axis: [0, 0, 1], damping: 0.01}   # the load
belts:
  - id: belt
    # in the order the cord runs: down the crossed leaf to the left guide, round its outside and along
    # the bottom, a full turn round the drum, on to the right guide and up the other leaf
    around: [p_top, gl, p_drum, gr]
    senses: [1, -1, 1, -1]
    wraps: [{wheel: p_drum, turns: 1, advance: 1.2}]
    section: round
    self_contact: true
    links: 150
    segments: 15
    thickness: 0.6
    width: 0.6
    density: 950
    stiffness: 30000
    damping: 2
    pretension: 20
    joint_armature: 0.000001
    root_damping: 0.0001   # stops free spin of straight runs about their own axis (see schema)
    friction: 0.6
contact: {solref: [0.002, 1], solimp: [0.9, 0.95, 0.001], margin: 0}
driver: {joint: j_top, kind: velocity, rpm: 30, kv: 2, max_torque: 5}
checks:
  # each wheel turns at (driver centre-line radius / its own) in its own sense: 9.3/5.8 for the drum,
  # about its upright shaft; 9.3/5.3 for each guide, both against the driver (crossed)
  - {type: ratio, out: j_drum, in: j_top, expect: 1.603, tol: 0.06, settle_s: 1, window_s: 1}
  - {type: ratio, out: j_left, in: j_top, expect: -1.755, tol: 0.07, settle_s: 1, window_s: 1}
  - {type: ratio, out: j_right, in: j_top, expect: -1.755, tol: 0.07, settle_s: 1, window_s: 1}
  # The drum face is smooth (Brown's spiral groove is not cut), so the turn settles down the face by
  # up to ~2 cm from its nominal helix; the leaves reach the driver ±1.7 off its plane and press its
  # flange edges (up to 3 mm into the soft contact).
  - {type: belt_on, belt: belt, max_radial_dev: 2.5, max_lateral: 1.0, duration_s: 2}
  - {type: penetration, max: 0.0035, settle_s: 0.5}
camera: {target: [0, -5, 22], position: [40, -150, 50], fov: 30}
display:
  output: j_drum
  labels: {j_top: Driving pulley (motor), j_left: Left guide pulley, j_right: Right guide pulley, j_drum: Upright drum}
  expect: {default: 1.603}
