# No. 400 (Brown 1868): "Four-motion feed (A. B. Wilson's patent), used on Wheeler & Wilson's, Sloat's, and other sewing machines. The bar, A, is
# forked, and has a second bar, B (carrying the spur or feeder), pivoted in the said fork. The bar, B, is lifted by a radial projection on the cam, C,
# at the same time the two bars are carried forward. A spring produces the return stroke, and the bar, B, drops of its own gravity."
#
# Model (cm, Brown's side view; the cam's shaft runs across the view): the cam C (the one driven joint, 30 rpm) has a round set off its shaft
# (the radial projection, 0.5 cm) under B's shoe, and an oblique face against a finger of A. The face carries A (and B in its fork) forward; A's
# spring brings them back; the round lifts B, which drops again by its weight. The round's throw is set a quarter turn from the face's, so the spur
# rises, goes forward, drops and comes back: the four motions. Contact only: the finger on the face, the shoe on the round.
# Generator: opencode-runs/batch13/gen400.py.
number: 400
slug: four-motion-feed
name: Four-motion feed
brown: "Four-motion feed (A. B. Wilson's patent), used on Wheeler & Wilson's, Sloat's, and other sewing machines. The bar, A, is forked, and has a second bar, B (carrying the spur or feeder), pivoted in the said fork. The bar, B, is lifted by a radial projection on the cam, C, at the same time the two bars are carried forward. A spring produces the return stroke, and the bar, B, drops of its own gravity."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 60, solver: PGS, duration_s: 8, floor: false}
bodies:
  - id: cam
    shape: part
    pos: [0, 0, 0]
    density: 7800
    color: "#c9bfa8"
    pieces:
      - {kind: loft, a: [[1.8, 1.8403, 0.3473], [1.8, 1.8215, 0.6345], [1.8, 1.7654, 0.9167], [1.8, 1.6729, 1.1892], [1.8, 1.5456, 1.4473], [1.8, 1.3857, 1.6866], [1.8, 1.196, 1.903], [1.8, 0.9796, 2.0927], [1.8, 0.7403, 2.2526], [1.8, 0.4822, 2.3799], [1.8, 0.2097, 2.4724], [1.8, -0.0725, 2.5285], [1.8, -0.3597, 2.5473], [1.8, -0.6468, 2.5285], [1.8, -0.9291, 2.4724], [1.8, -1.2016, 2.3799], [1.8, -1.4597, 2.2526], [1.8, -1.6989, 2.0927], [1.8, -1.9153, 1.903], [1.8, -2.105, 1.6866], [1.8, -2.2649, 1.4473], [1.8, -2.3922, 1.1892], [1.8, -2.4847, 0.9167], [1.8, -2.5408, 0.6345], [1.8, -2.5597, 0.3473], [1.8, -2.5408, 0.0602], [1.8, -2.4847, -0.2221], [1.8, -2.3922, -0.4946], [1.8, -2.2649, -0.7527], [1.8, -2.105, -0.9919], [1.8, -1.9153, -1.2083], [1.8, -1.6989, -1.398], [1.8, -1.4597, -1.5579], [1.8, -1.2016, -1.6852], [1.8, -0.9291, -1.7777], [1.8, -0.6468, -1.8338], [1.8, -0.3597, -1.8527], [1.8, -0.0725, -1.8338], [1.8, 0.2097, -1.7777], [1.8, 0.4822, -1.6852], [1.8, 0.7403, -1.5579], [1.8, 0.9796, -1.398], [1.8, 1.196, -1.2083], [1.8, 1.3857, -0.9919], [1.8, 1.5456, -0.7527], [1.8, 1.6729, -0.4946], [1.8, 1.7654, -0.2221], [1.8, 1.8215, 0.0602]], b: [[4.8, 1.8403, 0.3473], [4.8, 1.8215, 0.6345], [4.8, 1.7654, 0.9167], [4.8, 1.6729, 1.1892], [4.8, 1.5456, 1.4473], [4.8, 1.3857, 1.6866], [4.8, 1.196, 1.903], [4.8, 0.9796, 2.0927], [4.8, 0.7403, 2.2526], [4.8, 0.4822, 2.3799], [4.8, 0.2097, 2.4724], [4.8, -0.0725, 2.5285], [4.8, -0.3597, 2.5473], [4.8, -0.6468, 2.5285], [4.8, -0.9291, 2.4724], [4.8, -1.2016, 2.3799], [4.8, -1.4597, 2.2526], [4.8, -1.6989, 2.0927], [4.8, -1.9153, 1.903], [4.8, -2.105, 1.6866], [4.8, -2.2649, 1.4473], [4.8, -2.3922, 1.1892], [4.8, -2.4847, 0.9167], [4.8, -2.5408, 0.6345], [4.8, -2.5597, 0.3473], [4.8, -2.5408, 0.0602], [4.8, -2.4847, -0.2221], [4.8, -2.3922, -0.4946], [4.8, -2.2649, -0.7527], [4.8, -2.105, -0.9919], [4.8, -1.9153, -1.2083], [4.8, -1.6989, -1.398], [4.8, -1.4597, -1.5579], [4.8, -1.2016, -1.6852], [4.8, -0.9291, -1.7777], [4.8, -0.6468, -1.8338], [4.8, -0.3597, -1.8527], [4.8, -0.0725, -1.8338], [4.8, 0.2097, -1.7777], [4.8, 0.4822, -1.6852], [4.8, 0.7403, -1.5579], [4.8, 0.9796, -1.398], [4.8, 1.196, -1.2083], [4.8, 1.3857, -0.9919], [4.8, 1.5456, -0.7527], [4.8, 1.6729, -0.4946], [4.8, 1.7654, -0.2221], [4.8, 1.8215, 0.0602]], collide: 2}   # the round (radial projection) under B's shoe
      - {kind: loft, a: [[6.0, 2.6, 0.0], [6.1305, 2.5778, 0.3394], [6.2588, 2.5114, 0.6729], [6.3827, 2.4021, 0.995], [6.5, 2.2517, 1.3], [6.6088, 2.0627, 1.5828], [6.7071, 1.8385, 1.8385], [6.7934, 1.5828, 2.0627], [6.866, 1.3, 2.2517], [6.9239, 0.995, 2.4021], [6.9659, 0.6729, 2.5114], [6.9914, 0.3394, 2.5778], [7.0, 0.0, 2.6], [6.9914, -0.3394, 2.5778], [6.9659, -0.6729, 2.5114], [6.9239, -0.995, 2.4021], [6.866, -1.3, 2.2517], [6.7934, -1.5828, 2.0627], [6.7071, -1.8385, 1.8385], [6.6088, -2.0627, 1.5828], [6.5, -2.2517, 1.3], [6.3827, -2.4021, 0.995], [6.2588, -2.5114, 0.6729], [6.1305, -2.5778, 0.3394], [6.0, -2.6, 0.0], [5.8695, -2.5778, -0.3394], [5.7412, -2.5114, -0.6729], [5.6173, -2.4021, -0.995], [5.5, -2.2517, -1.3], [5.3912, -2.0627, -1.5828], [5.2929, -1.8385, -1.8385], [5.2066, -1.5828, -2.0627], [5.134, -1.3, -2.2517], [5.0761, -0.995, -2.4021], [5.0341, -0.6729, -2.5114], [5.0086, -0.3394, -2.5778], [5.0, -0.0, -2.6], [5.0086, 0.3394, -2.5778], [5.0341, 0.6729, -2.5114], [5.0761, 0.995, -2.4021], [5.134, 1.3, -2.2517], [5.2066, 1.5828, -2.0627], [5.2929, 1.8385, -1.8385], [5.3912, 2.0627, -1.5828], [5.5, 2.2517, -1.3], [5.6173, 2.4021, -0.995], [5.7412, 2.5114, -0.6729], [5.8695, 2.5778, -0.3394]], b: [[6.8, 2.6, 0.0], [6.9305, 2.5778, 0.3394], [7.0588, 2.5114, 0.6729], [7.1827, 2.4021, 0.995], [7.3, 2.2517, 1.3], [7.4088, 2.0627, 1.5828], [7.5071, 1.8385, 1.8385], [7.5934, 1.5828, 2.0627], [7.666, 1.3, 2.2517], [7.7239, 0.995, 2.4021], [7.7659, 0.6729, 2.5114], [7.7914, 0.3394, 2.5778], [7.8, 0.0, 2.6], [7.7914, -0.3394, 2.5778], [7.7659, -0.6729, 2.5114], [7.7239, -0.995, 2.4021], [7.666, -1.3, 2.2517], [7.5934, -1.5828, 2.0627], [7.5071, -1.8385, 1.8385], [7.4088, -2.0627, 1.5828], [7.3, -2.2517, 1.3], [7.1827, -2.4021, 0.995], [7.0588, -2.5114, 0.6729], [6.9305, -2.5778, 0.3394], [6.8, -2.6, 0.0], [6.6695, -2.5778, -0.3394], [6.5412, -2.5114, -0.6729], [6.4173, -2.4021, -0.995], [6.3, -2.2517, -1.3], [6.1912, -2.0627, -1.5828], [6.0929, -1.8385, -1.8385], [6.0066, -1.5828, -2.0627], [5.934, -1.3, -2.2517], [5.8761, -0.995, -2.4021], [5.8341, -0.6729, -2.5114], [5.8086, -0.3394, -2.5778], [5.8, -0.0, -2.6], [5.8086, 0.3394, -2.5778], [5.8341, 0.6729, -2.5114], [5.8761, 0.995, -2.4021], [5.934, 1.3, -2.2517], [6.0066, 1.5828, -2.0627], [6.0929, 1.8385, -1.8385], [6.1912, 2.0627, -1.5828], [6.3, 2.2517, -1.3], [6.4173, 2.4021, -0.995], [6.5412, 2.5114, -0.6729], [6.6695, 2.5778, -0.3394]], collide: 2}   # the oblique face (its right side) for A's finger
      - {kind: loft, a: [[4.8, 1.2, 0.0], [4.8, 1.1897, 0.1566], [4.8, 1.1591, 0.3106], [4.8, 1.1087, 0.4592], [4.8, 1.0392, 0.6], [4.8, 0.952, 0.7305], [4.8, 0.8485, 0.8485], [4.8, 0.7305, 0.952], [4.8, 0.6, 1.0392], [4.8, 0.4592, 1.1087], [4.8, 0.3106, 1.1591], [4.8, 0.1566, 1.1897], [4.8, 0.0, 1.2], [4.8, -0.1566, 1.1897], [4.8, -0.3106, 1.1591], [4.8, -0.4592, 1.1087], [4.8, -0.6, 1.0392], [4.8, -0.7305, 0.952], [4.8, -0.8485, 0.8485], [4.8, -0.952, 0.7305], [4.8, -1.0392, 0.6], [4.8, -1.1087, 0.4592], [4.8, -1.1591, 0.3106], [4.8, -1.1897, 0.1566], [4.8, -1.2, 0.0], [4.8, -1.1897, -0.1566], [4.8, -1.1591, -0.3106], [4.8, -1.1087, -0.4592], [4.8, -1.0392, -0.6], [4.8, -0.952, -0.7305], [4.8, -0.8485, -0.8485], [4.8, -0.7305, -0.952], [4.8, -0.6, -1.0392], [4.8, -0.4592, -1.1087], [4.8, -0.3106, -1.1591], [4.8, -0.1566, -1.1897], [4.8, -0.0, -1.2], [4.8, 0.1566, -1.1897], [4.8, 0.3106, -1.1591], [4.8, 0.4592, -1.1087], [4.8, 0.6, -1.0392], [4.8, 0.7305, -0.952], [4.8, 0.8485, -0.8485], [4.8, 0.952, -0.7305], [4.8, 1.0392, -0.6], [4.8, 1.1087, -0.4592], [4.8, 1.1591, -0.3106], [4.8, 1.1897, -0.1566]], b: [[6.2, 1.2, 0.0], [6.2, 1.1897, 0.1566], [6.2, 1.1591, 0.3106], [6.2, 1.1087, 0.4592], [6.2, 1.0392, 0.6], [6.2, 0.952, 0.7305], [6.2, 0.8485, 0.8485], [6.2, 0.7305, 0.952], [6.2, 0.6, 1.0392], [6.2, 0.4592, 1.1087], [6.2, 0.3106, 1.1591], [6.2, 0.1566, 1.1897], [6.2, 0.0, 1.2], [6.2, -0.1566, 1.1897], [6.2, -0.3106, 1.1591], [6.2, -0.4592, 1.1087], [6.2, -0.6, 1.0392], [6.2, -0.7305, 0.952], [6.2, -0.8485, 0.8485], [6.2, -0.952, 0.7305], [6.2, -1.0392, 0.6], [6.2, -1.1087, 0.4592], [6.2, -1.1591, 0.3106], [6.2, -1.1897, 0.1566], [6.2, -1.2, 0.0], [6.2, -1.1897, -0.1566], [6.2, -1.1591, -0.3106], [6.2, -1.1087, -0.4592], [6.2, -1.0392, -0.6], [6.2, -0.952, -0.7305], [6.2, -0.8485, -0.8485], [6.2, -0.7305, -0.952], [6.2, -0.6, -1.0392], [6.2, -0.4592, -1.1087], [6.2, -0.3106, -1.1591], [6.2, -0.1566, -1.1897], [6.2, -0.0, -1.2], [6.2, 0.1566, -1.1897], [6.2, 0.3106, -1.1591], [6.2, 0.4592, -1.1087], [6.2, 0.6, -1.0392], [6.2, 0.7305, -0.952], [6.2, 0.8485, -0.8485], [6.2, 0.952, -0.7305], [6.2, 1.0392, -0.6], [6.2, 1.1087, -0.4592], [6.2, 1.1591, -0.3106], [6.2, 1.1897, -0.1566]]}   # the hub between
      - {kind: rod, from: [-1.5, 0, 0], to: [12.5, 0, 0], radius: 0.6, color: "#6f6a60"}   # the shaft
  - id: bara
    shape: part
    pos: [0, 0, 6]
    density: 7800
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-10, 4.6677], [9.5, 4.6677], [9.5, 5.8677], [-10, 5.8677]], y: [0.6, 1.0]}   # A: a side of its fork
      - {kind: poly, points: [[-10, 4.6677], [9.5, 4.6677], [9.5, 5.8677], [-10, 5.8677]], y: [-1.0, -0.6]}   # A: a side of its fork
      - {kind: poly, points: [[-10, 5.8677], [-8.6, 5.8677], [-8.6, 0.5677], [-10, 0.5677]], y: [-1.0, 1.0]}   # its down-turned end (the spring's)
      - {kind: poly, points: [[-6.8, 3.1677], [-5.2, 3.1677], [-5.2, 4.6677], [-6.8, 4.6677]], y: [-1.0, 1.0]}   # the fork's cheek round B's pivot (drawn)
      - {kind: rod, from: [7.8808, -0.8, 4.9677], to: [7.8808, -1.4, 4.9677], radius: 0.35}   # the finger's arm
      - {kind: rod, from: [7.8808, -1.4, 4.9677], to: [7.8808, -1.4, 1.9], radius: 0.25}   # the finger
      - {kind: rod, from: [7.8808, -1.7, 1.9], to: [7.8808, -1.0999999999999999, 1.9], radius: 0.3, collide: 1, capsule: true, color: "#6f6a60"}   # its nib on the oblique face
  - id: barb
    shape: part
    pos: [-6.0, 0, 3.7677]
    mount: bara
    density: 7800
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-6.0, 3.2677], [11.5, 3.2677], [11.5, 4.2677], [-6.0, 4.2677]], y: [-0.5, 0.5]}   # the bar B
      - {kind: poly, points: [[2.6, 2.8677], [4.0, 2.8677], [4.0, 3.2677], [2.6, 3.2677]], y: [-0.5, 0.5]}   # its shoe's block
      - {kind: rod, from: [2.4, 0, 2.8677], to: [4.2, 0, 2.8677], radius: 0.3, collide: 1, capsule: true, color: "#6f6a60"}   # its shoe on the round
      - {kind: poly, points: [[11.5, 3.2677], [14.8, 3.2677], [14.55, 4.6677], [14.0, 4.2677], [13.75, 4.6677], [13.2, 4.2677], [12.95, 4.6677], [12.4, 4.2677], [12.15, 4.6677], [11.6, 4.2677], [11.5, 4.2677]], y: [-0.5, 0.5], color: "#8f8a80"}   # the spur (feeder)
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-13.8, 1.3677], [-11.0, 1.3677], [-11.0, 1.9677], [-13.8, 1.9677]], y: [-1.2, 1.2]}   # the spring's socket (Brown's, at A's end), cut away: its lower wall
      - {kind: poly, points: [[-13.8, 3.1677], [-11.0, 3.1677], [-11.0, 3.7677], [-13.8, 3.7677]], y: [-1.2, 1.2]}   # its upper wall
      - {kind: poly, points: [[-14.4, 1.3677], [-13.8, 1.3677], [-13.8, 3.7677], [-14.4, 3.7677]], y: [-1.2, 1.2]}   # its end
      - {kind: rod, from: [-13.6, 0, 2.5677], to: [-10.4, 0, 2.5677], radius: 0.25, color: "#6f6a60"}   # its stem
      - {kind: rod, from: [-1.2, -1.6, 0], to: [-1.2, 1.6, 0], radius: 0.5}   # the shaft's bearing
      - {kind: rod, from: [11.8, -1.6, 0], to: [11.8, 1.6, 0], radius: 0.5}
joints:
  - {id: j_c, type: hinge, body: cam, axis: [1, 0, 0], damping: 0.01}   # the cam C: the one driven joint
  - {id: j_a, type: slide, body: bara, axis: [1, 0, 0], damping: 0.5, stiffness: 400, springref: -2.5, range: [-2.5, 2.5]}   # the bar A; + : forward (right); its spring draws it back
  - {id: j_b, type: hinge, body: barb, axis: [0, 1, 0], damping: 0.002, range: [-0.3, 0.3]}   # the bar B in A's fork; + : its spur down
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_c, kind: velocity, rpm: 30, kv: 0.3, max_torque: 3}
checks:
  - {type: amplitude, joint: j_a, min: 0.007, max: 0.011, settle_s: 1.0, window_s: 6.5}   # A (and B in its fork) carried forward by the oblique face and back by the spring, ~1.8 cm
  - {type: amplitude, joint: j_b, min: 0.035, max: 0.07, settle_s: 1.0, window_s: 6.5}   # B lifted by the round and dropping by its weight, ~0.1 rad
  - {type: period, joint: j_a, expect_s: 2.13, tol: 0.06, settle_s: 1.0, window_s: 6.5}   # once a turn of the cam
  - {type: period, joint: j_b, expect_s: 2.13, tol: 0.06, settle_s: 1.0, window_s: 6.5}
  - {type: penetration, max: 0.002, settle_s: 0.5}
camera: {target: [1, 0, 1], position: [1, -42, 1], fov: 34}
display:
  output: j_b
  labels: {j_c: "Cam C (driver)", j_a: "Bar A", j_b: "Bar B (spur)"}
