# No. 72 (Brown 1868): a tilt-hammer motion.
#
# As drawn (cm; the drawing plane is x-z, depth y): the wiper wheel B (the one motor-driven shaft, turning
# with the clock) carries 4 wipers. The helve of the hammer A, on a fixed centre at the left, rests by its
# head on the anvil with its nose over B. Each wiper rises under the nose, lifts it, and slips off its end;
# the hammer falls on the anvil by its own weight. Four blows to each turn of B. Nothing but B is driven:
# the helve is lifted only by the wipers' contact and brought down only by gravity.
# Generator: opencode-runs/batch8/gen072.py.
number: 72
slug: tilt-hammer
name: A tilt-hammer motion
brown: "Is a tilt-hammer motion, the revolution of the cam or wiper-wheel, B, lifting the hammer, A, four times in each revolution."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: false
  duration_s: 12
  floor: false
bodies:
  - id: wheel_b
    shape: part
    pos: [0, 0, 0]
    friction: 0.1
    color: "#e8dec6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 1.3, y: [-0.6, 0.6]}   # B
      - {kind: rod, from: [-0.866, 0, 0.5], to: [-3.1177, 0, 1.8], radius: 0.3, capsule: true, collide: 1, color: "#6b5a44"}
      - {kind: rod, from: [0.5, 0, 0.866], to: [1.8, 0, 3.1177], radius: 0.3, capsule: true, collide: 1, color: "#6b5a44"}
      - {kind: rod, from: [0.866, 0, -0.5], to: [3.1177, 0, -1.8], radius: 0.3, capsule: true, collide: 1, color: "#6b5a44"}
      - {kind: rod, from: [-0.5, 0, -0.866], to: [-1.8, 0, -3.1177], radius: 0.3, capsule: true, collide: 1, color: "#6b5a44"}
      - {kind: disc, center: [0, 0], radius: 0.5, y: [0.6, 3.0], color: "#8f8a80"}   # its shaft
      - {kind: disc, center: [0, 0], radius: 1.6, y: [3.0, 6.0], color: "#8f8a80"}   # a flywheel behind
  - id: hammer
    shape: part
    pos: [-10.0, 0, 3.0]
    friction: 0.1
    color: "#d9cdb2"
    pieces:
      - {kind: rod, from: [-10.0, 0, 3.0], to: [0.8, 0, 3.0], radius: 0.3, capsule: true, collide: 2}   # the helve
      - {kind: disc, center: [-10.0, 3.0], radius: 0.7, y: [-0.8, 0.8], color: "#8f8a80"}   # its eye
      - {kind: poly, points: [[-5.8, 0.6], [-4.2, 0.6], [-4.2, 3.5], [-5.8, 3.5]], y: [-0.9, 0.9], collide: 2, color: "#6b5a44"}   # the head A
  - id: anvil
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-6.2, -2.5], [-3.8000000000000003, -2.5], [-3.8000000000000003, 0.598], [-6.2, 0.598]], y: [-1.2, 1.2], collide: 1}   # the anvil
      - {kind: poly, points: [[-7.199999999999999, -3.5], [-2.8000000000000003, -3.5], [-3.2, -2.5], [-6.8, -2.5]], y: [-1.6, 1.6]}
  - id: frame
    shape: frame
    color: "#8f8a80"
    rods:
      - {from: [-10.0, 0.8, 3.0], to: [-10.0, 2.0, 3.0], radius: 0.35}
      - {from: [-10.0, -0.8, 3.0], to: [-10.0, -2.0, 3.0], radius: 0.35}
      - {from: [0, 6.0, 0], to: [0, 7.2, 0], radius: 0.6}
joints:
  - {id: j_b, type: hinge, body: wheel_b, axis: [0, 1, 0], damping: 0.02}   # positive: with the clock, as drawn
  - {id: j_a, type: hinge, body: hammer, axis: [0, -1, 0], damping: 0.002}   # positive: the nose (and head) up
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_b, kind: velocity, rpm: 12, kv: 2, max_torque: 20}
checks:
  - {type: advance, joint: j_b, beat: j_a, expect: 0.7854, tol: 0.01, settle_s: 1.4, window_s: 9.2}   # from just before one rise of A to just after the eighth: B turns a quarter between blows: half of it each rise and each fall of A
  - {type: position, joint: j_a, min: -0.01, max: 0.1326, settle_s: 0.5, window_s: 11.0}   # lifted no higher than the wipers reach (0.1226 rad)
  - {type: clicks, joint: j_a, lift: 0.098, min: 8, settle_s: 1.4, window_s: 9.2}   # each lift nearly the full 0.1226 rad, and back on the anvil
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [-5.5, 0, 1.0], position: [-5.5, -46, 6], fov: 34}
display:
  output: j_a
  labels: {j_b: "Wiper wheel B (driver)", j_a: "Hammer A on its helve"}
  proof: {label: "Wipers out of contact", sub: "the hammer is never lifted"}

