# No. 189 (Brown 1898): "Another modification of 186."
#
# Model (cm, no gravity; a plan): the eccentric (throw 2.4 cm, the one driven joint, 30 turns a minute) works the eccentric rod through a 13 cm drop-link; the rod slides to and fro 4.8 cm in its guide.
# Its end is the gab: a notch between two jaws that holds the pin (1.2 cm) of the rock-shaft arm (7 cm long), so the rock-shaft rocks 20 deg each way (real contact, 0.12 cm of play each side).
# The gab end of the rod is hinged (a light spring holds it down) and has a tail with a link up to one arm of a bell crank; the other arm is joined by a short link to a vertical hand rod. At 5 s a hand pulls the rod down (the hand schedule moves its spring's rest position),
# the bell crank lifts the tail and with it the gab, and the notch clears the pin: the rock-shaft stands where it is while the eccentric and rod go on. (Putting it back is not modelled.) Generator: opencode-runs/batch11/gen189.py.
number: 189
slug: disengaging-by-rod-and-bell-crank
name: Disengaging the eccentric-rod by a rod and bell crank
brown: "Another modification of 186."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 9.0
  floor: false
  gravity: 0
bodies:
  - id: eccentric
    shape: part
    pos: [29.0, 0, 1.6]
    mass: 0.4
    color: "#cfc6b4"
    pieces:
      - {kind: disc, center: [29.0, 1.6], radius: 3.6, y: [-2.0, -1.2], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [29.0, 4.0], radius: 1.0, y: [-1.5, -0.9], collide: 0, color: "#b9b09c"}
      - {kind: disc, center: [29.0, 1.6], radius: 1.7, y: [-2.4, -2.0], collide: 0, color: "#8f8a80"}
  - id: link
    shape: part
    pos: [29.0, 0, 4.0]
    mount: eccentric
    mass: 0.3
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[29.1015, 3.4595], [16.325, 1.0595], [16.1219, 2.1405], [28.8985, 4.5405]], y: [-1.0, -0.5], collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [29.0, -1.6, 4.0], to: [29.0, -0.8, 4.0], radius: 0.5, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [16.2235, -1.0, 1.6], to: [16.2235, 0.1, 1.6], radius: 0.5, collide: 0, color: "#8f8a80"}
  - id: rod
    shape: part
    pos: [16.2235, 0, 1.6]
    mass: 0.4
    friction: 0.02
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[13.2235, 0.8], [17.0235, 0.8], [17.0235, 2.4], [13.2235, 2.4]], y: [-0.4, 0.4], collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [12.2235, -0.7, 1.6], to: [12.2235, 0.7, 1.6], radius: 0.45, collide: 0, color: "#8f8a80"}
  - id: gab
    shape: part
    pos: [12.2235, 0, 1.6]
    mount: rod
    mass: 0.3
    friction: 0.02
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-9.7765, 1.15], [13.2235, 1.15], [13.2235, 2.75], [-9.7765, 2.75]], y: [-0.4, 0.4], collide: 2, color: "#a89a7e"}
      - {kind: poly, points: [[0.9435, -0.9], [2.4435, -0.9], [2.4435, 1.16], [0.9435, 1.16]], y: [-0.4, 0.4], collide: 2, color: "#a89a7e"}
      - {kind: poly, points: [[-1.9965, -0.9], [-0.4965, -0.9], [-0.4965, 1.16], [-1.9965, 1.16]], y: [-0.4, 0.4], collide: 2, color: "#a89a7e"}
      - {kind: rod, from: [-7.7765, -0.7, 1.95], to: [-7.7765, 0.9, 1.95], radius: 0.4, collide: 0, color: "#8f8a80"}

  - id: bell
    shape: part
    pos: [-13.7765, 0, 8.95]
    mass: 0.2
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-17.7765, 9.45], [-7.7765, 9.45], [-7.7765, 8.45], [-17.7765, 8.45]], y: [1.0, 1.6], collide: 0, color: "#8f8a80"}
      - {kind: disc, center: [-13.7765, 8.95], radius: 1.0, y: [1.0, 1.8], collide: 0, color: "#6e6452"}
      - {kind: rod, from: [-17.7765, 1.0, 8.95], to: [-17.7765, 2.2, 8.95], radius: 0.4, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [-7.7765, 1.0, 8.95], to: [-7.7765, 2.2, 8.95], radius: 0.4, collide: 0, color: "#8f8a80"}
  - id: hrod
    shape: part
    pos: [-17.7765, 0, 4.95]
    mass: 0.2
    friction: 0.02
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-18.1765, -4.05], [-18.1765, 4.95], [-17.3765, 4.95], [-17.3765, -4.05]], y: [1.0, 1.6], collide: 0, color: "#a89a7e"}
      - {kind: disc, center: [-17.7765, -4.65], radius: 1.1, y: [1.0, 1.6], collide: 0, color: "#6e6452"}
      - {kind: rod, from: [-17.7765, 1.0, 4.95], to: [-17.7765, 2.8, 4.95], radius: 0.4, collide: 0, color: "#8f8a80"}
  - id: link1
    shape: part
    pos: [-17.7765, 0, 4.95]
    mount: hrod
    mass: 0.1
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-18.1265, 4.95], [-18.1265, 8.95], [-17.4265, 8.95], [-17.4265, 4.95]], y: [2.2, 2.7], collide: 0, color: "#a89a7e"}
  - id: link2
    shape: part
    pos: [-7.7765, 0, 8.95]
    mount: bell
    mass: 0.1
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[-7.4265, 8.95], [-7.4265, 1.95], [-8.1265, 1.95], [-8.1265, 8.95]], y: [2.2, 2.7], collide: 0, color: "#a89a7e"}
  - id: rocker
    shape: part
    pos: [0.0, 0, -7.0]
    mass: 0.2
    friction: 0.01
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-0.5497, -6.9824], [-0.3263, 0.014], [0.7732, -0.0211], [0.5497, -7.0176]], y: [0.6, 1.2], collide: 0, color: "#d9cfb6"}
      - {kind: rod, from: [0.2235, -0.45, -0.0036], to: [0.2235, 1.2, -0.0036], radius: 0.6, collide: 1, capsule: true, color: "#8f8a80"}
      - {kind: disc, center: [0.0, -7.0], radius: 2.4, y: [0.6, 1.2], collide: 0, color: "#cfc6b4"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [29.0, 0.0, 1.6], to: [29.0, 3.0, 1.6], radius: 1.0, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [0.0, 0.0, -7.0], to: [0.0, 3.0, -7.0], radius: 0.9, collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-1.0, -9.4], [1.0, -9.4], [0.8, -7.0], [-0.8, -7.0]], y: [1.4, 2.6], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[27.8, 6.6], [30.2, 6.6], [30.0, 1.6], [28.0, 1.6]], y: [1.4, 2.6], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[-8.0, -9.4], [37.0, -9.4], [37.0, -10.4], [-8.0, -10.4]], y: [-3, 3], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[9.0, 0.6], [23.0, 0.6], [23.0, -0.2], [9.0, -0.2]], y: [-1.0, 1.0], collide: 0, color: "#a39a86"}
      - {kind: poly, points: [[9.0, 3.4], [23.0, 3.4], [23.0, 2.6], [9.0, 2.6]], y: [-1.0, 1.0], collide: 0, color: "#a39a86"}
joints:
  - {id: j_e, type: hinge, body: eccentric, axis: [0, -1, 0], damping: 0.002}   # the one driven joint
  - {id: j_l, type: hinge, body: link, axis: [0, -1, 0], damping: 0.002}
  - {id: j_rod, type: slide, body: rod, axis: [1, 0, 0], damping: 0.05}   # the eccentric rod in its guide
  - {id: j_g, type: hinge, body: gab, axis: [0, 1, 0], range: [-0.05, 0.4], stiffness: 1.0, springref: 0, damping: 0.05}   # the gab end of the rod; + lifts it (the hand lifts the spring handle)
  - {id: j_b, type: hinge, body: bell, axis: [0, -1, 0], damping: 0.01}
  - {id: j_hr, type: slide, body: hrod, axis: [0, 0, 1], range: [-4.5, 0.5], stiffness: 300, springref: 0, damping: 30}   # the hand rod, pulled down by hand
  - {id: j_l1, type: hinge, body: link1, axis: [0, -1, 0], damping: 0.002}
  - {id: j_l2, type: hinge, body: link2, axis: [0, -1, 0], damping: 0.002}
  - {id: j_rk, type: hinge, body: rocker, axis: [0, -1, 0], damping: 0.0005}   # the rock-shaft arm
pins:
  - {"id": "pin_a", "a": "link1", "b": "bell", "at": [-17.7765, 0, 8.95]}
  - {"id": "pin_b", "a": "link2", "b": "gab", "at": [-7.7765, 0, 1.95]}
  - {"id": "pin_l", "a": "link", "b": "rod", "at": [16.2235, 0, 1.6]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_e, kind: velocity, rpm: 30, kv: 2.0, max_torque: 20}
hand:
  - {t: 5, springref: {j_hr: -3.0}}
checks:
  - {type: follow, out: j_rk, in: j_rod, expect: -14.6, tol: 0.9, min_r2: 0.995, settle_s: 0.6, window_s: 0.8}   # engaged: the rock-shaft arm goes as the rod's stroke (asin of 4.8 cm on a 7 cm arm: 14.6 rad per m)
  - {type: follow, out: j_rk, in: j_rod, expect: -14.6, tol: 0.9, min_r2: 0.995, settle_s: 2.6, window_s: 0.8}
  - {type: position, joint: j_rod, min: -2.9, max: 2.5, settle_s: 0.0, window_s: 8.8}
  - {type: position, joint: j_g, min: 0.15, max: 0.25, settle_s: 5.6, window_s: 3.2}   # the bell crank holds the gab up
  - {type: still, joint: j_rk, max: 0.02, settle_s: 6.6, window_s: 2.2}   # disengaged: the rock-shaft stands though the rod goes on
  - {type: follow, out: j_rod, in: j_e, expect: -0.0262, tol: 0.012, min_r2: 0.9, settle_s: 0.0, window_s: 0.25}   # and the eccentric keeps the rod going all the while
  - {type: penetration, max: 0.003, settle_s: 0.5}
camera: {target: [6.0, 0, -0.3], position: [6.0, -66.0, -0.3], fov: 34}
display:
  output: j_rk
  labels: {j_e: "Eccentric (driver)", j_rod: "Eccentric rod", j_rk: "Rock-shaft arm", j_hr: "Hand rod (pulled by hand)", j_g: "Gab (lifted through the bell crank)"}

