# No. 3, Pulleys with Right Angle Guides (Brown 1868, p. 1).
#
# "A method of transmitting motion from a shaft at right angles to another, by means of guide-pulleys.
# There are two of these pulleys, side by side, one for each leaf of the belt."
#
# Layout from the plate (1 unit = 1 cm; driving pulley r 9 = 55 px of the engraving): the driving
# pulley at the upper right, its shaft towards the reader; the guide pulleys at the upper left on a
# parallel shaft line; and below them the driven drum, whose shaft lies across the picture, at right
# angles to the driver's. The two leaves of the cord drop from the guides one in front of the other
# (the plate shows them as one line) and go round the drum. Each guide pulley carries one leaf, so the
# two guides are side by side, 2 × 5.3 apart, and turn opposite ways, each loose on its own bearing.
# The driver stands well off (40 cm) so the leaves reach its single groove at a fleet angle of ~7.5°;
# at ~9° (a larger drum, guides further apart, or the driver nearer) the cord walks over the flange.
#
# Fully physical: only the driving pulley is motor-driven. The cord is a closed chain of elastic links,
# laid on the common tangents of the wheels in space (src/geom/path3d.ts), pretensioned, and it turns
# the guides and the drum by friction alone.
number: 3
slug: pulleys-with-right-angle-guides
name: Pulleys with Right Angle Guides
brown: "A method of transmitting motion from a shaft at right angles to another, by means of guide-pulleys. There are two of these pulleys, side by side, one for each leaf of the belt."
units: cm
sim: {timestep: 0.0001, integrator: implicitfast, iterations: 50, duration_s: 8, floor: false}
bodies:
  - {id: p_drive, shape: pulley, radius: 9, width: 3, groove: 1.2, flange: 0.6, pos: [40, 0, 43], mass: 2.0, spokes: 4, hub: 2.4}
  # the guide pulleys, side by side, one for each leaf
  - {id: g_front, shape: pulley, radius: 4.1, width: 2.4, groove: 1.2, flange: 0.5, pos: [0, -5.3, 48], mass: 0.4, spokes: 0, hub: 1.0, color: "#e6dcc4"}
  - {id: g_back, shape: pulley, radius: 4.1, width: 2.4, groove: 1.2, flange: 0.5, pos: [0, 5.3, 48], mass: 0.4, spokes: 0, hub: 1.0, color: "#e6dcc4"}
  # the driven drum, its shaft across the picture (along x): at right angles to the driver's shaft
  - {id: drum, shape: assembly, pos: [-4.4, 0, 2], color: "#ded2b6"}
wheels:
  - {id: p_drum, body: drum, pos: [0, 0, 0], quat: [0.7071068, 0, 0, -0.7071068], radius: 5, width: 12, groove: 1.2, flange: 0.5, mass: 1.2, spokes: 0, hub: 4.2, color: "#ded2b6"}
shafts:
  - {id: drum_shaft, body: drum, from: [-11, 0, 0], to: [11, 0, 0], radius: 0.6}
joints:
  - {id: j_drive, type: hinge, body: p_drive, axis: [0, 1, 0], damping: 0.002}
  - {id: j_front, type: hinge, body: g_front, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_back, type: hinge, body: g_back, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_drum, type: hinge, body: drum, axis: [1, 0, 0], damping: 0.01}   # the load
belts:
  - id: belt
    # in the order the cord runs: off the top of the driver, over the front guide and down in front of
    # the drum, under it, up behind it, over the back guide and down to the bottom of the driver
    around: [p_drive, g_front, p_drum, g_back]
    senses: [-1, -1, 1, 1]
    section: round
    links: 145
    segments: 14
    thickness: 0.6        # cord diameter
    width: 0.6
    density: 950
    stiffness: 30000
    damping: 2
    pretension: 20
    joint_armature: 0.000001
    friction: 0.6
contact: {solref: [0.002, 1], solimp: [0.9, 0.95, 0.001], margin: 0}
driver: {joint: j_drive, 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.3 for the drum,
  # about its own (x) shaft; 9.3/4.4 for each guide, the two guides opposite ways (one leaf goes down,
  # the other comes up).
  - {type: ratio, out: j_drum, in: j_drive, expect: -1.755, tol: 0.06, settle_s: 1, window_s: 1}
  - {type: ratio, out: j_front, in: j_drive, expect: 2.114, tol: 0.08, settle_s: 1, window_s: 1}
  - {type: ratio, out: j_back, in: j_drive, expect: -2.114, tol: 0.08, settle_s: 1, window_s: 1}
  # Where a leaf leaves a wheel at a fleet angle (the driver and guides lie in offset planes) it lifts
  # over the groove's flange before the nominal tangent point: up to ~1 cm from the in-plane centre line.
  - {type: belt_on, belt: belt, max_radial_dev: 1.5, max_lateral: 1.0, duration_s: 2}
  - {type: penetration, max: 0.002, settle_s: 0.5}
camera: {target: [17, 0, 24], position: [82, -145, 60], fov: 30}
display:
  output: j_drum
  labels: {j_drive: Driving pulley (motor), j_front: Front guide pulley, j_back: Back guide pulley, j_drum: Drum (shaft at right angles)}
  expect: {default: -1.755}
