number: 351
slug: stamp-mutilated-pinion-rack
name: Stamp
brown: "Stamp. Vertical percussive falls derived from horizontal rotating shaft. The mutilated toothed pinion acts upon the rack to raise the rod until its teeth leave the rack and allow the rod to fall."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 10
  floor: false
bodies:
  # the mutilated pinion A on the horizontal shaft, cut down to its root circle where it has no teeth
  - id: gear_a
    shape: part
    pos: [0, 0, 0]
    density: 7800
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: disc, center: [0, 0], radius: 5.55, inner: 0.6, y: [-0.8, 0.8]}
      - {kind: poly, points: [[-3.813, -4.1873], [-2.4094, -5.1252], [-3.5765, -5.981], [-4.157, -5.5931]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[-1.9204, -5.3277], [-0.2646, -5.6571], [-1.0154, -6.8944], [-1.7002, -6.7582]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[0.2646, -5.6571], [1.9204, -5.3277], [1.7002, -6.7582], [1.0154, -6.8944]], y: [-0.8, 0.8], collide: 1}
      - {kind: poly, points: [[2.4094, -5.1252], [3.813, -4.1873], [4.157, -5.5931], [3.5765, -5.981]], y: [-0.8, 0.8], collide: 1}
  # the stamp-rod with its rack, sliding upright in its guides, and the stamp head at its foot
  - id: rod
    shape: part
    pos: [-7.7, 0, -18.8496]
    density: 7800
    friction: 0.1
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-8.2, -18.8496], [-7.2, -18.8496], [-7.2, 1.2566], [-8.2, 1.2566]], y: [-0.8, 0.8], collide: 0}
      - {kind: poly, points: [[-7.2, 0.819], [-7.2, -0.819], [-6.0, -0.3822], [-6.0, 0.3822]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-7.2, -1.6943], [-7.2, -3.3322], [-6.0, -2.8955], [-6.0, -2.1311]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-7.2, -4.2076], [-7.2, -5.8455], [-6.0, -5.4087], [-6.0, -4.6443]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-7.2, -6.7209], [-7.2, -8.3588], [-6.0, -7.922], [-6.0, -7.1576]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-7.2, -9.2341], [-7.2, -10.8721], [-6.0, -10.4353], [-6.0, -9.6709]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-7.2, -11.7474], [-7.2, -13.3853], [-6.0, -12.9486], [-6.0, -12.1842]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-7.2, -14.2607], [-7.2, -15.8986], [-6.0, -15.4618], [-6.0, -14.6974]], y: [-0.8, 0.8], collide: 2}
      - {kind: poly, points: [[-7.2, -16.774], [-7.2, -18.4119], [-6.0, -17.9751], [-6.0, -17.2107]], y: [-0.8, 0.8], collide: 2}
      - {kind: rod, from: [-7.7, 0, 1.2566], to: [-7.7, 0, 8.2566], radius: 0.5}
      - {kind: rod, from: [-7.7, 0, -18.8496], to: [-7.7, 0, -27.8496], radius: 0.5}
      - {kind: poly, points: [[-9.1, -27.8496], [-6.3, -27.8496], [-5.5, -29.0496], [-5.5, -30.6496], [-6.3, -31.8496], [-9.1, -31.8496], [-9.9, -30.6496], [-9.9, -29.0496]], y: [-1.6, 1.6], collide: 1}
  # the frame: the shaft, the guides the rod slides in, and the die the stamp falls on
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, -1.4, 0], to: [0, 2.2, 0], radius: 0.6, color: "#8f8a80"}
      - {kind: poly, points: [[-1.0, -1.0], [1.0, -1.0], [1.4, -34.8496], [-1.4, -34.8496]], y: [1.2, 2.2], collide: 0}
      - {kind: poly, points: [[-12.2, 16.0796], [-3.2, 16.0796], [-3.2, 17.6796], [-12.2, 17.6796]], y: [-1.2, 1.2], collide: 0}
      - {kind: poly, points: [[-12.2, -22.4496], [-3.2, -22.4496], [-3.2, -20.8496], [-12.2, -20.8496]], y: [-1.2, 1.2], collide: 0}
      - {kind: poly, points: [[-13.7, 16.0796], [-12.2, 16.0796], [-12.2, -34.8496], [-13.7, -34.8496]], y: [1.2, 2.2], collide: 0}
      - {kind: poly, points: [[-12.7, -34.3496], [-2.7, -34.3496], [-2.7, -31.8496], [-12.7, -31.8496]], y: [-2.0, 2.0], collide: 2, color: "#8f8a80"}
      - {kind: poly, points: [[-16.7, -35.8496], [6.3, -35.8496], [6.3, -34.3496], [-16.7, -34.3496]], y: [-3, 3], collide: 0, color: "#b9b09c"}
joints:
  - {id: j_A, type: hinge, body: gear_a, axis: [0, 1, 0], damping: 0.002}   # the one driven joint; + : clockwise
  - {id: j_z, type: slide, body: rod, axis: [0, 0, 1], damping: 0.05, range: [-0.5, 16.823]}   # + : up; the guides
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_A, kind: velocity, rpm: 30, kv: 8, max_torque: 20}
checks:
  # the rod rises as A's pitch line while the teeth are in ...
  - {type: follow, out: j_z, in: j_A, expect: 0.064, tol: 0.0013, min_r2: 0.995, settle_s: 2.3, window_s: 0.5}
  # ... through its teeth, no further, and falls back on the die before they come round again
  - {type: position, joint: j_z, min: -0.2, max: 14.423, settle_s: 0.5, window_s: 9}
  - {type: position, joint: j_z, min: -0.1, max: 0.1, settle_s: 3.4, window_s: 0.6}
  # the blow of the stamp on the die presses deepest
  - {type: penetration, max: 0.002, settle_s: 0.5}
camera: {target: [-4, 0, -21.5], position: [-4, -220, -21.5], fov: 30}
display:
  output: j_z
  labels: {j_A: "Mutilated pinion (driver)", j_z: "Stamp-rod"}

