# No. 144 (Brown 1868): "A system of crossed levers, termed 'Lazy Tongs.' A short alternating rectilinear motion of rod at the right will give a similar but much greater motion to rod at the left."
#
# Model (cm, no gravity; a plan): ten levers of 7 cm, pinned in pairs at their middles (the crossings) and end to end, form a chain of 5 cells. The fourth crossing from the left is pinned to the frame, the first is pinned
# to the rod at the left, the last to the rod at the right. The right rod is the one driven joint, slid to and fro 0.6 cm each way (0.25 strokes a second). The crossings stay on one line, each a lever length times the cosine of the lever's
# angle from the next, so the right rod's one cell against the left rod's four makes the left rod go 4 times as far, the other way: about 2.4 cm each way. All joints are pins. Generator: opencode-runs/batch10/gen144.py.
number: 144
slug: lazy-tongs
name: Lazy Tongs, a chain of crossed levers
brown: "A system of crossed levers, termed 'Lazy Tongs.' A short alternating rectilinear motion of rod at the right will give a similar but much greater motion to rod at the left, the rods being connected by the levers as shown."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 8.0
  floor: false
  gravity: 0
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-35.9981, -12.0], [22.4995, -12.0], [22.4995, -10.0], [-35.9981, -10.0]], y: [0.0, 2.2], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[-32.4981, -10.0], [-30.4981, -10.0], [-30.4981, 2.4], [-32.4981, 2.4]], y: [0.2, 0.7], collide: 0, color: "#c3baa6"}
      - {kind: poly, points: [[16.9995, -10.0], [18.9995, -10.0], [18.9995, 2.4], [16.9995, 2.4]], y: [0.2, 0.7], collide: 0, color: "#c3baa6"}
      - {kind: poly, points: [[-1.2, -10.0], [1.2, -10.0], [1.2, -1.6], [-1.2, -1.6]], y: [0.2, 0.7], collide: 0, color: "#c3baa6"}
      - {kind: disc, center: [0.0, 0.0], radius: 1.1, inner: 0.0, y: [-0.1, 1.8], color: "#8f8a80"}
      - {kind: rod, from: [0, -0.3, 0], to: [0, 1.9, 0], radius: 0.5, collide: 0, color: "#8f8a80"}
  - id: rod_r
    shape: part
    pos: [4.4995, 0, 0]
    mass: 0.1
    color: "#b3a88f"
    pieces:
      - {kind: rod, from: [4.4995, 0.45, 0], to: [17.4995, 0.45, 0], radius: 0.4, collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [17.4995, 0.45, 0], to: [19.4995, 0.45, 0], radius: 0.8, collide: 0, color: "#8f8a80"}
      - {kind: disc, center: [4.4995, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 1.6]}
  - id: rod_l
    shape: part
    pos: [-17.9981, 0, 0]
    mass: 0.1
    color: "#b3a88f"
    pieces:
      - {kind: rod, from: [-30.9981, 0.45, 0], to: [-17.9981, 0.45, 0], radius: 0.4, collide: 0, color: "#a89a7e"}
      - {kind: rod, from: [-32.9981, 0.45, 0], to: [-30.9981, 0.45, 0], radius: 0.8, collide: 0, color: "#8f8a80"}
      - {kind: disc, center: [-17.9981, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 1.6]}
  - id: u4
    shape: part
    pos: [0.0, 0, 0.0]
    mass: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-2.6328, -2.3598], [1.8667, 3.0025], [2.6328, 2.3598], [-1.8667, -3.0025]], y: [0.0, 0.7], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [-2.2498, -2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [2.2498, 2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [0.0, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
  - id: d4
    shape: part
    pos: [0.0, 0, 0.0]
    mass: 0.1
    color: "#c9bfa6"
    pieces:
      - {kind: poly, points: [[-1.8667, 3.0025], [2.6328, -2.3598], [1.8667, -3.0025], [-2.6328, 2.3598]], y: [0.9, 1.6], collide: 0, color: "#c9bfa6"}
      - {kind: disc, center: [-2.2498, 2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [2.2498, -2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [0.0, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
  - id: d5
    shape: part
    pos: [2.2498, 0, 2.6812]
    mount: u4
    mass: 0.1
    color: "#c9bfa6"
    pieces:
      - {kind: poly, points: [[2.6328, 3.0025], [4.8825, 0.3214], [4.1165, -0.3214], [1.8667, 2.3598]], y: [0.9, 1.6], collide: 0, color: "#c9bfa6"}
      - {kind: disc, center: [2.2498, 2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [4.4995, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [4.4995, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
  - id: u5
    shape: part
    pos: [4.4995, 0, 0.0]
    mount: d5
    mass: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[1.8667, -2.3598], [4.1165, 0.3214], [4.8825, -0.3214], [2.6328, -3.0025]], y: [0.0, 0.7], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [2.2498, -2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [4.4995, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [4.4995, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
  - id: u3
    shape: part
    pos: [-2.2498, 0, 2.6812]
    mount: d4
    mass: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-7.1323, -2.3598], [-2.6328, 3.0025], [-1.8667, 2.3598], [-6.3662, -3.0025]], y: [0.0, 0.7], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [-6.7493, -2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-2.2498, 2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-4.4995, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
  - id: d3
    shape: part
    pos: [-4.4995, 0, 0.0]
    mount: u3
    mass: 0.1
    color: "#c9bfa6"
    pieces:
      - {kind: poly, points: [[-6.3662, 3.0025], [-1.8667, -2.3598], [-2.6328, -3.0025], [-7.1323, 2.3598]], y: [0.9, 1.6], collide: 0, color: "#c9bfa6"}
      - {kind: disc, center: [-6.7493, 2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-2.2498, -2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-4.4995, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
  - id: u2
    shape: part
    pos: [-6.7493, 0, 2.6812]
    mount: d3
    mass: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-11.6318, -2.3598], [-7.1323, 3.0025], [-6.3662, 2.3598], [-10.8658, -3.0025]], y: [0.0, 0.7], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [-11.2488, -2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-6.7493, 2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-8.999, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
  - id: d2
    shape: part
    pos: [-8.999, 0, 0.0]
    mount: u2
    mass: 0.1
    color: "#c9bfa6"
    pieces:
      - {kind: poly, points: [[-10.8658, 3.0025], [-6.3662, -2.3598], [-7.1323, -3.0025], [-11.6318, 2.3598]], y: [0.9, 1.6], collide: 0, color: "#c9bfa6"}
      - {kind: disc, center: [-11.2488, 2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-6.7493, -2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-8.999, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
  - id: u1
    shape: part
    pos: [-11.2488, 0, 2.6812]
    mount: d2
    mass: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-16.1313, -2.3598], [-11.6318, 3.0025], [-10.8658, 2.3598], [-15.3653, -3.0025]], y: [0.0, 0.7], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [-15.7483, -2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-11.2488, 2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-13.4985, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
  - id: d1
    shape: part
    pos: [-13.4985, 0, 0.0]
    mount: u1
    mass: 0.1
    color: "#c9bfa6"
    pieces:
      - {kind: poly, points: [[-15.3653, 3.0025], [-10.8658, -2.3598], [-11.6318, -3.0025], [-16.1313, 2.3598]], y: [0.9, 1.6], collide: 0, color: "#c9bfa6"}
      - {kind: disc, center: [-15.7483, 2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-11.2488, -2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-13.4985, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
  - id: u0
    shape: part
    pos: [-15.7483, 0, 2.6812]
    mount: d1
    mass: 0.1
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-18.3811, 0.3214], [-16.1313, 3.0025], [-15.3653, 2.3598], [-17.615, -0.3214]], y: [0.0, 0.7], collide: 0, color: "#d9cfb6"}
      - {kind: disc, center: [-17.9981, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-15.7483, 2.6812], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
      - {kind: disc, center: [-17.9981, 0.0], radius: 0.8, inner: 0.3, y: [0.0, 0.7]}
  - id: d0
    shape: part
    pos: [-17.9981, 0, 0.0]
    mount: u0
    mass: 0.1
    color: "#c9bfa6"
    pieces:
      - {kind: poly, points: [[-17.615, 0.3214], [-15.3653, -2.3598], [-16.1313, -3.0025], [-18.3811, -0.3214]], y: [0.9, 1.6], collide: 0, color: "#c9bfa6"}
      - {kind: disc, center: [-17.9981, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-15.7483, -2.6812], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
      - {kind: disc, center: [-17.9981, 0.0], radius: 0.8, inner: 0.3, y: [0.9, 1.6]}
joints:
  - {id: j_r, type: slide, body: rod_r, axis: [1, 0, 0], damping: 0.05}   # the driven rod at the right; + : to the right
  - {id: j_l, type: slide, body: rod_l, axis: [1, 0, 0], damping: 0.05}   # the rod at the left
  - {id: j_u4, type: hinge, body: u4, axis: [0, 1, 0], damping: 0.002}
  - {id: j_d4, type: hinge, body: d4, axis: [0, 1, 0], damping: 0.002}
  - {id: j_d5, type: hinge, body: d5, axis: [0, 1, 0], damping: 0.002}
  - {id: j_u5, type: hinge, body: u5, axis: [0, 1, 0], damping: 0.002}
  - {id: j_u3, type: hinge, body: u3, axis: [0, 1, 0], damping: 0.002}
  - {id: j_d3, type: hinge, body: d3, axis: [0, 1, 0], damping: 0.002}
  - {id: j_u2, type: hinge, body: u2, axis: [0, 1, 0], damping: 0.002}
  - {id: j_d2, type: hinge, body: d2, axis: [0, 1, 0], damping: 0.002}
  - {id: j_u1, type: hinge, body: u1, axis: [0, 1, 0], damping: 0.002}
  - {id: j_d1, type: hinge, body: d1, axis: [0, 1, 0], damping: 0.002}
  - {id: j_u0, type: hinge, body: u0, axis: [0, 1, 0], damping: 0.002}
  - {id: j_d0, type: hinge, body: d0, axis: [0, 1, 0], damping: 0.002}
pins:
  - {id: pin_b1, a: d0, b: u1, at: [-15.7483, 0, -2.6812]}
  - {id: pin_b2, a: d1, b: u2, at: [-11.2488, 0, -2.6812]}
  - {id: pin_b3, a: d2, b: u3, at: [-6.7493, 0, -2.6812]}
  - {id: pin_b4, a: d3, b: u4, at: [-2.2498, 0, -2.6812]}
  - {id: pin_b5, a: d4, b: u5, at: [2.2498, 0, -2.6812]}
  - {id: pin_r, a: d5, b: rod_r, at: [4.4995, 0, 0]}
  - {id: pin_l, a: d0, b: rod_l, at: [-17.9981, 0, 0]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_r, kind: velocity, rpm: 0, swing: {amplitude: 0.006, hz: 0.25}, kv: 60000.0, max_torque: 600.0}
checks:
  - {type: follow, out: j_l, in: j_r, expect: -4.0, tol: 0.1, min_r2: 0.998, settle_s: 0.5, window_s: 3.0}   # the left rod goes 4 times as far, the other way
  - {type: follow, out: j_l, in: j_r, expect: -4.0, tol: 0.1, min_r2: 0.998, settle_s: 4.5, window_s: 3.0}
  - {type: position, joint: j_l, min: -2.8, max: 2.8, settle_s: 0.0, window_s: 7.5}
  - {type: position, joint: j_r, min: -0.8, max: 0.8, settle_s: 0.0, window_s: 7.5}
camera: {target: [-6.7493, 0, -3], position: [-6.7493, -68.0, -3], fov: 34}
display:
  output: j_l
  labels: {j_r: "Rod at right (driver)", j_l: "Rod at left"}
  proof: {label: "Last pin removed", sub: "the right rod slides but the left rod stays"}

