# No. 174 (Brown 1868): "Carpenters' bench-clamp. By pushing the clamp between the jaws they are made to turn on the screws and clamp the sides"
#
# Model (cm, no gravity; a plan): the wedge-shaped clamp (the one driven joint, a slide pushed at 0.698 cm/s) goes up between the jaws' mouths; the 4 cm mouth end of each jaw (a pin) rides the wedge's sloping face (taper 0.4) by real contact, so the jaw turns on its screw
# and its far end (5 cm the other side of the screw) closes 1.6 cm on the work after the clamp has gone 3.3 cm. Both jaws turn, in mirror. Generator: opencode-runs/batch11/gen180.py (MODE=174).
number: 174
slug: carpenters-bench-clamp
name: Carpenters' bench-clamp
brown: "Carpenters' bench-clamp. By pushing the clamp between the jaws they are made to turn on the screws and clamp the sides"
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 6.0
  floor: false
  gravity: 0
bodies:
  - id: jaw_a
    shape: part
    pos: [3.2, 0, 0]
    mass: 0.2
    friction: 0.02
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[2.6, -4.0], [3.8, -4.0], [3.8, 5.0], [2.6, 5.0]], y: [-2.4, -1.4], collide: 0, color: "#d9cfb6"}
      - {kind: rod, from: [3.2, -2.0, -4.0], to: [3.2, -0.2, -4.0], radius: 0.3, collide: 1, capsule: true, color: "#8f8a80"}
      - {kind: rod, from: [3.2, -3.0, 0.0], to: [3.2, 0.6, 0.0], radius: 0.7, collide: 0, color: "#8f8a80"}
  - id: jaw_b
    shape: part
    pos: [-3.2, 0, 0]
    mass: 0.2
    friction: 0.02
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-3.8, -4.0], [-2.6, -4.0], [-2.6, 5.0], [-3.8, 5.0]], y: [-2.4, -1.4], collide: 0, color: "#d9cfb6"}
      - {kind: rod, from: [-3.2, -2.0, -4.0], to: [-3.2, -0.2, -4.0], radius: 0.3, collide: 1, capsule: true, color: "#8f8a80"}
      - {kind: rod, from: [-3.2, -3.0, 0.0], to: [-3.2, 0.6, 0.0], radius: 0.7, collide: 0, color: "#8f8a80"}
  - id: wedge
    shape: part
    pos: [0, 0, 0]
    mass: 0.3
    friction: 0.02
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-4.8769, -9.0], [4.8769, -9.0], [2.0769, -2.0], [-2.0769, -2.0]], y: [-1.2, -0.4], collide: 2, color: "#a89a7e"}
      - {kind: rod, from: [0.0, -0.8, -9.0], to: [0.0, -0.8, -11.0], radius: 0.7, collide: 0, color: "#a89a7e"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-7.8, -9.0], [-6.2, -9.0], [-6.2, 8.5], [-7.8, 8.5]], y: [-1.4, 0.0], collide: 0, color: "#b9b09c"}   # the bench's side pieces, left
      - {kind: poly, points: [[6.2, -9.0], [7.8, -9.0], [7.8, 8.5], [6.2, 8.5]], y: [-1.4, 0.0], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[-14.0, -12.0], [14.0, -12.0], [14.0, -11.0], [-14.0, -11.0]], y: [-1.2, 1.2], collide: 0, color: "#b9b09c"}
joints:
  - {id: j_a, type: hinge, body: jaw_a, axis: [0, -1, 0], damping: 0.002}   # the jaw on the +x side: + : its mouth end outward
  - {id: j_b, type: hinge, body: jaw_b, axis: [0, 1, 0], damping: 0.002}   # the other jaw, mirrored: + : its mouth end outward
  - {id: j_w, type: slide, body: wedge, axis: [0, 0, 1], damping: 0.05, range: [0, 3.5487]}   # the clamp: the one driven joint; + : pushed up between the jaws
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_w, kind: velocity, speed: 0.698, kv: 6000.0, max_torque: 400}
checks:
  - {type: follow, out: j_a, in: j_w, expect: 9.6751, tol: 0.774, min_r2: 0.99, settle_s: 0.9, window_s: 1.0}
  - {type: follow, out: j_a, in: j_w, expect: 9.471, tol: 0.7577, min_r2: 0.99, settle_s: 2.1, window_s: 1.2}
  - {type: follow, out: j_a, in: j_w, expect: 9.3417, tol: 0.7473, min_r2: 0.99, settle_s: 3.5, window_s: 1.1}
  - {type: follow, out: j_b, in: j_w, expect: 9.6751, tol: 0.774, min_r2: 0.99, settle_s: 0.9, window_s: 1.0}
  - {type: follow, out: j_b, in: j_w, expect: 9.471, tol: 0.7577, min_r2: 0.99, settle_s: 2.1, window_s: 1.2}
  - {type: follow, out: j_b, in: j_w, expect: 9.3417, tol: 0.7473, min_r2: 0.99, settle_s: 3.5, window_s: 1.1}
  - {type: position, joint: j_a, min: -0.02, max: 0.36, settle_s: 0.0, window_s: 5.5}
  - {type: penetration, max: 0.003, settle_s: 0.5}
camera: {target: [0.0, 0, -3.8], position: [0.0, -46.0, -3.8], fov: 34}
display:
  output: j_a
  labels: {j_w: "Clamp (driver)", j_a: "Jaw", j_b: "Other jaw"}

