# No. 214 (Brown 1868): "214 and 215. Other modifications of the stop, the operations of which will be easily understood by a comparison with 212."
#
# Model (cm): No. 214 is two spur wheels in gear, 12 and 11 teeth (module 1, centres 11.5 apart), each with a tapered finger, 6.6 long, on its square arbor
# in a plane in front of the teeth. The fingers reach past the middle of the line of centres, so they meet if both point along it together; the wheels turn
# at 12:11, so that happens once in 11 turns of the 12-wheel, and the fingers then stop the wheels, from one side going forward and from the other going back.
# So the arbor can make only about 11 turns between its stops (the sweep gives -34.094..34.094 rad). Only the 12-wheel's arbor is driven: to and fro by hand,
# +-40 rad at 0.035 Hz, torque limit 3 N m, so it stalls at each stop. Generator: opencode-runs/batch11/gen214.py.
number: 214
slug: stop-fingers-on-wheels
name: A stop by fingers on two wheels in gear
brown: "Other modifications of the stop, the operations of which will be easily understood by a comparison with 212."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 29.0
  floor: false
bodies:
  - id: a
    shape: part
    pos: [0, 0, 0]
    density: 2700
    friction: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[0.5, 0.75], [-6.3, 0.15], [-6.6, 0.0], [-6.3, -0.15], [0.5, -0.75]], y: [-2.0, -1.4], collide: 1}   # the finger
      - {kind: disc, center: [0, 0], radius: 1.1, inner: 0.4, y: [-2.1, 1.3], collide: 0, color: "#c4b895"}   # the boss
      - {kind: poly, points: [[-0.45, -0.45], [0.45, -0.45], [0.45, 0.45], [-0.45, 0.45]], y: [-2.15, -2.1], collide: 0, color: "#4a463f"}   # the square of the arbor, drawn
      - {kind: disc, center: [2.6, -0.0], radius: 1.2814, y: [1.3, 1.9], collide: 0, color: "#b8ab8a"}   # counterweight to the finger
  - id: b
    shape: part
    pos: [11.5, 0, 0]
    density: 2700
    friction: 0.1
    color: "#cbbd99"
    pieces:
      - {kind: poly, points: [[12.0, 0.75], [5.2, 0.15], [4.9, 0.0], [5.2, -0.15], [12.0, -0.75]], y: [-2.0, -1.4], collide: 2}   # the finger
      - {kind: disc, center: [11.5, 0], radius: 1.1, inner: 0.4, y: [-2.1, 1.3], collide: 0, color: "#c4b895"}   # the boss
      - {kind: poly, points: [[11.05, -0.45], [11.95, -0.45], [11.95, 0.45], [11.05, 0.45]], y: [-2.15, -2.1], collide: 0, color: "#4a463f"}   # the square, drawn
      - {kind: disc, center: [14.1, -0.0], radius: 1.2814, y: [1.3, 1.9], collide: 0, color: "#b8ab8a"}   # counterweight to the finger
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: rod, from: [0, 1.3, 0], to: [0, 3.2, 0], radius: 0.4, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [11.5, 1.3, 0], to: [11.5, 3.2, 0], radius: 0.4, collide: 0, color: "#8f8a80"}
      - {kind: poly, points: [[-1, -0.9], [12.5, -0.9], [12.5, 0.9], [-1, 0.9]], y: [2.4, 3.2], collide: 0}   # the bar, behind
      - {kind: poly, points: [[4.85, -9.5], [6.65, -9.5], [6.65, -0.9], [4.85, -0.9]], y: [2.4, 3.2], collide: 0}   # the standard
      - {kind: poly, points: [[-2.25, -10.5], [13.75, -10.5], [13.75, -9.5], [-2.25, -9.5]], y: [-2, 3.2], collide: 0, color: "#b9b09c"}
joints:
  - {id: j_a, type: hinge, body: a, axis: [0, -1, 0], damping: 0.01}   # the one driven joint; +: counter-clockwise
  - {id: j_b, type: hinge, body: b, axis: [0, -1, 0], damping: 0.01}
spurs:
  - {id: sa, body: a, pos: [0, 0, 0], teeth: 12, module: 1, width: 2.4, backlash: 0.03, phase: 0}
  - {id: sb, body: b, pos: [0, 0, 0], teeth: 11, module: 1, width: 2.4, backlash: 0.03, phase: 3.4272}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_a, kind: velocity, rpm: 0, swing: {amplitude: 40, hz: 0.035}, kv: 20, max_torque: 3}
checks:
  - {type: ratio, out: j_b, in: j_a, expect: -1.0909, tol: 0.02, settle_s: 0.5, window_s: 3}   # 12:11, while the fingers are clear
  - {type: position, joint: j_a, min: -34.39, max: 34.39, settle_s: 0, window_s: 28.9}   # the arbor's two stops
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [5.75, 0, -1.5], position: [5.75, -72, 0], fov: 34}
display:
  output: j_b
  labels: {j_a: "12-wheel A (driver)", j_b: "11-wheel B"}
  expect: {default: -1.0909}
  proof: {label: "Contact off", sub: "A turns alone and B stays put"}

