# No. 78 (Brown 1868): "A modification of 77."
#
# Model (cm), after the plate: the 30-tooth ratchet-wheel A turns on a fixed centre in an A-frame and is
# held by its bearing friction. The lever on the frame's apex, 7.5 cm over A's centre, is rocked about
# 0.27 rad each way by a crank (the one driven joint, 30 turns a minute) whose pin works in a slot at the
# lever's right end, where the plate's rod B joins it. Two hooked pawls hang from the lever and pull: the
# one from the left end (2.8892 cm out) hooks a tooth on A's left side and draws it up as that end
# rises; the one from the right pin (4.2967 cm out) reaches down to A's upper left and draws a tooth on as
# that pin rises. On the return each is pushed back and rides over the teeth by its weight. They pull on
# alternate strokes, so A, like 77's wheel, goes a tooth each stroke. Generator: opencode-runs/batch8/gen078.py.
number: 78
slug: lever-two-pulling-pawls
name: A modification of 77, with two pulling pawls on a lever over the wheel
brown: "A modification of 77."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: false
  duration_s: 14
  floor: false
bodies:
  - id: wheel_a
    shape: part
    pos: [0, 0, 0]
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 4.3, inner: 0.6, y: [-0.6, 0.6]}
      - {kind: poly, points: [[-3.7909, 1.8081], [-4.8618, 1.1672], [-4.084, 0.9805]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-4.084, 0.9805], [-4.9983, 0.1309], [-4.1986, 0.1099]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-4.1986, 0.1099], [-4.9163, -0.9112], [-4.1297, -0.7654]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-4.1297, -0.7654], [-4.6194, -1.9134], [-3.8803, -1.6073]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-3.8803, -1.6073], [-4.1206, -2.832], [-3.4613, -2.3789]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-3.4613, -2.3789], [-3.4418, -3.6269], [-2.8911, -3.0466]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-2.8911, -3.0466], [-2.6125, -4.2632], [-2.1945, -3.5811]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-2.1945, -3.5811], [-1.669, -4.7132], [-1.402, -3.9591]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-1.402, -3.9591], [-0.6526, -4.9572], [-0.5482, -4.1641]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-0.5482, -4.1641], [0.3923, -4.9846], [0.3295, -4.1871]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[0.3295, -4.1871], [1.4201, -4.7941], [1.1929, -4.027]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[1.1929, -4.027], [2.3858, -4.3941], [2.0041, -3.691]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[2.0041, -3.691], [3.2472, -3.802], [2.7277, -3.1937]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[2.7277, -3.1937], [3.9668, -3.0438], [3.3321, -2.5568]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[3.3321, -2.5568], [4.5129, -2.1526], [3.7909, -1.8081]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[3.7909, -1.8081], [4.8618, -1.1672], [4.084, -0.9805]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[4.084, -0.9805], [4.9983, -0.1309], [4.1986, -0.1099]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[4.1986, -0.1099], [4.9163, 0.9112], [4.1297, 0.7654]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[4.1297, 0.7654], [4.6194, 1.9134], [3.8803, 1.6073]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[3.8803, 1.6073], [4.1206, 2.832], [3.4613, 2.3789]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[3.4613, 2.3789], [3.4418, 3.6269], [2.8911, 3.0466]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[2.8911, 3.0466], [2.6125, 4.2632], [2.1945, 3.5811]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[2.1945, 3.5811], [1.669, 4.7132], [1.402, 3.9591]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[1.402, 3.9591], [0.6526, 4.9572], [0.5482, 4.1641]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[0.5482, 4.1641], [-0.3923, 4.9846], [-0.3295, 4.1871]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-0.3295, 4.1871], [-1.4201, 4.7941], [-1.1929, 4.027]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-1.1929, 4.027], [-2.3858, 4.3941], [-2.0041, 3.691]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-2.0041, 3.691], [-3.2472, 3.802], [-2.7277, 3.1937]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-2.7277, 3.1937], [-3.9668, 3.0438], [-3.3321, 2.5568]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[-3.3321, 2.5568], [-4.5129, 2.1526], [-3.7909, 1.8081]], y: [-0.6, 0.6], collide: 1}
  - id: lever
    shape: part
    pos: [0, 0, 7.5]
    friction: 0.1
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-3.4892, 7.1], [4.6, 7.1], [4.6, 7.9], [-3.4892, 7.9]], y: [-1.3, -0.7]}   # the lever
      - {kind: disc, center: [0, 7.5], radius: 0.7, inner: 0.3, y: [-1.3, -0.7]}
      - {kind: poly, points: [[4.6, 6.83], [11.2, 6.83], [11.2, 7.23], [4.6, 7.23]], y: [-1.3, -0.3], collide: 2}   # the slot's cheeks
      - {kind: poly, points: [[4.6, 7.77], [11.2, 7.77], [11.2, 8.17], [4.6, 8.17]], y: [-1.3, -0.3], collide: 2}
      - {kind: poly, points: [[11.2, 6.83], [11.6, 6.83], [11.6, 8.17], [11.2, 8.17]], y: [-1.3, -0.3]}
      - {kind: rod, from: [-2.8892, -0.8, 7.5], to: [-2.8892, 0.5, 7.5], radius: 0.18, color: "#8f8a80"}   # the pawls' pins
      - {kind: rod, from: [4.2967, -0.8, 7.5], to: [4.2967, 0.0, 7.5], radius: 0.18, color: "#8f8a80"}
  - id: pawl_l
    shape: part
    pos: [-2.8892, 0, 7.5]
    mount: lever
    friction: 0.1
    color: "#6b5a44"
    pieces:
      - {kind: rod, from: [-2.8892, 0.3, 7.5], to: [-5.5149, 0.3, 0.9724], radius: 0.15, capsule: true, collide: 2}   # the shank, clear of the teeth
      - {kind: rod, from: [-5.5149, 0.3, 0.9724], to: [-4.6778, 0.3, 0.8248], radius: 0.15, capsule: true, collide: 2}   # the hook's nib
  - id: pawl_r
    shape: part
    pos: [4.2967, 0, 7.5]
    mount: lever
    friction: 0.1
    color: "#6b5a44"
    pieces:
      - {kind: rod, from: [4.2967, -0.2, 7.5], to: [-2.9675, -0.2, 4.7491], radius: 0.15, capsule: true, collide: 2}
      - {kind: rod, from: [-2.9675, -0.2, 4.7491], to: [-2.5171, -0.2, 4.0282], radius: 0.15, capsule: true, collide: 2}
  - id: crank
    shape: part
    pos: [8.0, 0, 7.5]
    color: "#a39d90"
    pieces:
      - {kind: disc, center: [8.0, 7.5], radius: 2.8000000000000003, y: [0.4, 1.2]}   # the crank disc, behind
      - {kind: rod, from: [10.2, -1.5, 7.5], to: [10.2, 0.4, 7.5], radius: 0.25, capsule: true, collide: 1}   # its pin, in the slot at B's end
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, -2.2, 0], to: [0, 0.6, 0], radius: 0.6, color: "#8f8a80"}   # A's axle
      - {kind: rod, from: [0, -2.2, 7.5], to: [0, -1.3, 7.5], radius: 0.3, color: "#8f8a80"}   # the lever's centre
      - {kind: poly, points: [[-6.2, -8], [-4.8, -8], [0.7, 7.5], [-0.7, 7.5]], y: [-2.2, -1.6]}   # the A-frame's legs, in front
      - {kind: poly, points: [[4.8, -8], [6.2, -8], [0.7, 7.5], [-0.7, 7.5]], y: [-2.2, -1.6]}
      - {kind: poly, points: [[-2.6, -0.5], [2.6, -0.5], [2.6, 0.5], [-2.6, 0.5]], y: [-2.2, -1.6]}   # its cross-bar at A's axle
      - {kind: rod, from: [8.0, 1.2, 7.5], to: [8.0, 2.0, 7.5], radius: 0.35, color: "#8f8a80"}
      - {kind: poly, points: [[7.5, -8], [8.5, -8], [8.5, 7.5], [7.5, 7.5]], y: [1.4, 2.0]}   # the crank's standard
      - {kind: poly, points: [[-8, -9], [12.0, -9], [12.0, -8], [-8, -8]], y: [-3, 3], color: "#b9b09c"}
joints:
  - {id: j_k, type: hinge, body: crank, axis: [0, -1, 0], damping: 0.0005}   # the one driven joint
  - {id: j_l, type: hinge, body: lever, axis: [0, -1, 0], damping: 0.0005}   # + : left end down
  - {id: j_pl, type: hinge, body: pawl_l, axis: [0, -1, 0], damping: 0.0002, range: [-0.9, 0.9]}
  - {id: j_pr, type: hinge, body: pawl_r, axis: [0, -1, 0], damping: 0.0002, range: [-0.9, 0.9]}
  - {id: j_a, type: hinge, body: wheel_a, axis: [0, 1, 0], damping: 0.002, frictionloss: 0.01}   # + : clockwise
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_k, kind: velocity, rpm: 30.0, kv: 2, max_torque: 20}
checks:
  - {type: ratio, out: j_a, in: j_k, expect: 0.0667, tol: 0.001, settle_s: 3, window_s: 10}   # two teeth a crank turn
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [3.0, 0, 0], position: [3.0, -54, 2], fov: 34}
display:
  output: j_a
  labels: {j_k: "Crank at B (driver)", j_l: "Lever", j_pl: "Left pawl", j_pr: "Right pawl", j_a: "Ratchet-wheel A"}
  proof: {label: "Pawls out of contact", sub: "the lever rocks but A never moves"}

