# No. 184 (Brown 1868): "183 and 184 represent a modification of 181 and 182, the diagonal catches being superseded by two quadrants."  Nos. 181 and 182:
#  "In 181 the lower steam-valve and upper eduction-valve are open ... consequently the piston will be ascending. In the ascent of the piston-rod the lower handle
#  will be struck by the projecting tappet, and, being raised, will become engaged ... and shut the upper eduction and lower steam valves; at the same time, the upper
#  handle being disengaged ..., the back weight will pull the handle up and open the upper steam and lower eduction valves, when the piston will consequently descend.
#  182 represents the position ... when the piston is at the top of the cylinder. In going down, the tappet of the piston-rod strikes the upper handle and throws the
#  catches and handles to the position shown in 181."
#
# Model (cm): the upper handle U turns on a shaft at (0, 6), the lower L on one at (0, -6). Each carries a quadrant, an arc concentric with its own shaft
# (radius 9.92, 1 wide), and a finger whose round nose (r 0.35) lies on the other's quadrant where that handle's swing carries it straight toward the other
# shaft, so a locked handle presses radially on the other's quadrant and cannot turn it. U's back-weight turns it up (+), L's turns it down (-), both as joint
# springs set past their rest stops. With U locked down by L's quadrant and L at rest (No. 181), the plug-rod's tappet A rises under L's arm near the top and throws
# L up 15 deg: L's quadrant slides from under U's finger, U is released and swings up 8.6 deg to rest, and its quadrant swings in over L's finger, so
# when the rod turns back L drops onto it and is locked up (No. 182). Near the bottom tappet B comes down on U's arm and throws it down: U's quadrant leaves L's
# finger, L falls to rest, and its quadrant locks U down again (No. 181). The plug-rod is worked by a crank (the one driven joint, 20 rpm) standing for the
# engine; the valves are not drawn. No. 184 starts in the state of No. 182.
# Generator: opencode-runs/batch11/gen183.py.
number: 184
slug: hand-gear-quadrants-top
name: Hand-gear with locking quadrants (piston at the top)
brown: "183 and 184. represent a modification of 181 and 182, the diagonal catches being superseded by two quadrants."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: CG
  multiccd: true
  duration_s: 9.5
  floor: false
bodies:
  - id: handle_u
    shape: part
    pos: [0.0, 0, 6.0]
    density: 2700
    friction: 0.1
    color: "#e8dec6"
    pieces:
      - {kind: band, center: [0.0, 6.0], r: [8.9179, 9.9179], a: [-2.1815, -2.0315], slices: 16, y: [-0.6, 0.6], collide: 1}   # the quadrant
      - {kind: rod, from: [0.0, 0.9, 6.0], to: [-5.401, 0.9, -1.7153], radius: 0.3, collide: 0}
      - {kind: rod, from: [0.0, 0.9, 6.0], to: [-4.1874, 0.9, -2.4357], radius: 0.3, collide: 0}
      - {kind: disc, center: [-4.7613, 2.0643], radius: 0.35, y: [-0.6, 0.6], collide: 1}   # the finger's nose
      - {kind: rod, from: [0.0, 0, 6.0], to: [-4.7613, 0, 2.0643], radius: 0.3, collide: 0}   # the finger
      - {kind: poly, points: [[1.0485, 5.7539], [8.5632, 6.8897], [8.4437, 7.6807], [0.929, 6.5449]], y: [-0.6, 0.6], collide: 1}   # the tappet arm
      - {kind: disc, center: [0.0, 6.0], radius: 1.3, y: [-1.2, 1.2], collide: 0}   # the boss on its shaft
      - {kind: rod, from: [0.0, -1.0, 6.0], to: [-9.2725, -1.0, 7.127], radius: 0.3, collide: 0}   # the handle
      - {kind: disc, center: [-9.2725, 7.127], radius: 0.6, y: [-1.4, -0.6], collide: 0}
  - id: handle_l
    shape: part
    pos: [0.0, 0, -6.0]
    density: 2700
    friction: 0.1
    color: "#d9ccae"
    pieces:
      - {kind: band, center: [0.0, -6.0], r: [8.9179, 9.9179], a: [2.1815, 2.3315], slices: 16, y: [-0.6, 0.6], collide: 2}   # the quadrant
      - {kind: rod, from: [0.0, 0.9, -6.0], to: [-5.401, 0.9, 1.7153], radius: 0.3, collide: 0}
      - {kind: rod, from: [0.0, 0.9, -6.0], to: [-6.4933, 0.9, 0.8215], radius: 0.3, collide: 0}
      - {kind: disc, center: [-5.296, -2.82], radius: 0.35, y: [-0.6, 0.6], collide: 2}   # the finger's nose
      - {kind: rod, from: [0.0, 0, -6.0], to: [-5.296, 0, -2.82], radius: 0.3, collide: 0}   # the finger
      - {kind: poly, points: [[1.0, -6.4], [8.6, -6.4], [8.6, -5.6], [1.0, -5.6]], y: [-0.6, 0.6], collide: 2}   # the tappet arm
      - {kind: disc, center: [0.0, -6.0], radius: 1.3, y: [-1.2, 1.2], collide: 0}   # the boss on its shaft
      - {kind: rod, from: [0.0, -1.0, -6.0], to: [-9.0, -1.0, -8.5], radius: 0.3, collide: 0}   # the handle
      - {kind: disc, center: [-9.0, -8.5], radius: 0.6, y: [-1.4, -0.6], collide: 0}
  - id: crank
    shape: part
    pos: [10.0, 0, -28.4354]
    density: 7800
    color: "#8f8a80"
    pieces:
      - {kind: disc, center: [10.0, -28.4354], radius: 7.2, y: [1.6, 2.4], collide: 0}
      - {kind: rod, from: [5.9102, 1.0, -24.0452], to: [5.9102, 2.4, -24.0452], radius: 0.4, collide: 0}
  - id: conrod
    shape: part
    mount: crank
    pos: [5.9102, 0, -24.0452]
    density: 2700
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [5.9102, 1.0, -24.0452], to: [10.0, 1.0, -10.6559], radius: 0.4, collide: 0}
  - id: rod
    shape: part
    pos: [10.0, 0, -10.6559]
    density: 7800
    color: "#e4d9bf"
    pieces:
      - {kind: poly, points: [[9.5, -11.6559], [10.5, -11.6559], [10.5, 19.2148], [9.5, 19.2148]], y: [-0.6, 0.6], collide: 0}   # the plug-rod
      - {kind: poly, points: [[7.4, -8.8559], [9.5, -8.8559], [9.5, -7.6559], [7.4, -7.6559]], y: [-0.6, 0.6], collide: 1}
      - {kind: poly, points: [[7.4, 15.2148], [9.5, 15.2148], [9.5, 16.4148], [7.4, 16.4148]], y: [-0.6, 0.6], collide: 2}
  - id: guides
    shape: frame
    color: "#8f8a80"
    rods:
      - {from: [11.0, 0, -38.4354], to: [11.0, 0, 33.2148], radius: 0.4}   # the plug-rod's guide
      - {from: [0, 2.0, 6], to: [-14, 2.0, 6], radius: 0.6}   # the handle shafts' bracket
      - {from: [0, 2.0, -6], to: [-14, 2.0, -6], radius: 0.6}
      - {from: [-14, 2.0, 9], to: [-14, 2.0, -38.4354], radius: 0.6}
joints:
  - {id: j_U, type: hinge, body: handle_u, axis: [0, -1, 0], damping: 0.01, stiffness: 0.4, springref: 0.45, range: [-0.33, 0.0]}   # 0 = the start pose; +: up (counter-clockwise); its back-weight (spring) turns it up to rest at +0.15
  - {id: j_L, type: hinge, body: handle_l, axis: [0, -1, 0], damping: 0.01, stiffness: 0.4, springref: -0.6, range: [-0.15, 0.18]}   # +: up; its back-weight turns it down to rest at -0.15
  - {id: j_crank, type: hinge, body: crank, axis: [0, -1, 0], damping: 0.001}   # the one driven joint, standing for the engine
  - {id: j_con, type: hinge, body: conrod, axis: [0, -1, 0], damping: 0.001}
  - {id: j_rod, type: slide, body: rod, axis: [0, 0, 1], damping: 0.05}
pins:
  - {id: p_rod, a: conrod, b: rod, at: [10.0, 0, -10.6559]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_crank, kind: velocity, rpm: 20.0, kv: 2, max_torque: 12}
checks:
  - {type: position, joint: j_U, min: -0.18, max: -0.12, settle_s: 1.65, window_s: 0.45}   # after the bottom throw: U locked down by L's quadrant
  - {type: position, joint: j_L, min: -0.16, max: -0.12, settle_s: 1.65, window_s: 0.45}   # and L at rest, down by its back-weight
  - {type: position, joint: j_L, min: -0.03, max: 0.03, settle_s: 3.15, window_s: 0.45}   # after the top throw: L locked up by U's quadrant
  - {type: position, joint: j_U, min: -0.03, max: 0.01, settle_s: 3.15, window_s: 0.45}   # and U at rest, up by its back-weight
  - {type: position, joint: j_U, min: -0.18, max: -0.12, settle_s: 4.65, window_s: 0.45}   # after the bottom throw: U locked down by L's quadrant
  - {type: position, joint: j_L, min: -0.16, max: -0.12, settle_s: 4.65, window_s: 0.45}   # and L at rest, down by its back-weight
  - {type: position, joint: j_L, min: -0.03, max: 0.03, settle_s: 6.15, window_s: 0.45}   # after the top throw: L locked up by U's quadrant
  - {type: position, joint: j_U, min: -0.03, max: 0.01, settle_s: 6.15, window_s: 0.45}   # and U at rest, up by its back-weight
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [-1, 0, -11], position: [-1, -120, -10], fov: 34}
display:
  output: j_L
  labels: {j_crank: "Engine crank (driver)", j_rod: "Plug-rod", j_U: "Upper handle", j_L: "Lower handle"}
  proof: {label: "Tappets out of contact", sub: "the plug-rod runs, the handles stand"}

