# No. 157 (Brown 1868): "A modification of the movement last described; a connecting-rod being substituted for the slot in the bell-crank."
#
# Model (cm, a plan: no gravity): No. 156 with a connecting-rod (9 cm, a pin at each end) in place of the slot in the bell-crank. The disk (the one driven joint, 12 turns a minute, clockwise in the view) carries the crank-pin 3.5 cm out;
# the rod carries it to the end of arm 1 (6.5 cm) of the bell-crank, pivoted 11 cm away (a crank-and-rocker: the disk turns right round, the bell-crank rocks through -58..8 degrees);
# arm 2 (9 cm, a right angle from arm 1) has a pin working in the slot across a sliding bar, which goes up and down 7.9 cm. The loop is closed by the two pins (real pin joints); the bar's speed varies through the turn.
# Generator: opencode-runs/batch11/gen157.py.
number: 157
slug: crank-pin-connecting-rod-bell-crank
name: A connecting-rod substituted for the slot in the bell-crank
brown: "A modification of the movement last described; a connecting-rod being substituted for the slot in the bell-crank."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: PGS
  multiccd: true
  duration_s: 12.0
  floor: false
  gravity: 0
bodies:
  - id: disk
    shape: part
    pos: [0, 0, 0]
    mass: 1.0
    friction: 0.05
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, 0.0, 0], to: [0, 4.0, 0], radius: 0.9, collide: 0, color: "#8f8a80"}
      - {kind: disc, center: [0, 0], radius: 5.1, inner: 4.3, y: [0.0, 0.6], color: "#d9cfb6"}
      - {kind: disc, center: [0, 0], radius: 1.5, y: [0.0, 0.6], color: "#d9cfb6"}
      - {kind: poly, points: [[-0.45, 0.0], [-0.45, 4.7], [0.45, 4.7], [0.45, -0.0]], y: [0.0, 0.6], collide: 0, color: "#d9cfb6"}
      - {kind: poly, points: [[-0.0, 0.45], [4.7, 0.45], [4.7, -0.45], [0.0, -0.45]], y: [0.0, 0.6], collide: 0, color: "#d9cfb6"}
      - {kind: poly, points: [[0.45, 0.0], [0.45, -4.7], [-0.45, -4.7], [-0.45, -0.0]], y: [0.0, 0.6], collide: 0, color: "#d9cfb6"}
      - {kind: poly, points: [[0.0, -0.45], [-4.7, -0.45], [-4.7, 0.45], [-0.0, 0.45]], y: [0.0, 0.6], collide: 0, color: "#d9cfb6"}
      - {kind: rod, from: [3.5, -3.2, 0.0], to: [3.5, 0.0, 0.0], radius: 0.3, collide: 0, color: "#8f8a80"}
  - id: conrod
    shape: part
    pos: [3.5, 0, 0.0]
    mount: disk
    mass: 0.2
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [3.5, -2.6, 0.0], to: [9.8333, -2.6, 6.3944], radius: 0.28, color: "#b8ad97"}
      - {kind: disc, center: [3.5, 0.0], radius: 0.75, y: [-2.9, -2.3000000000000003], color: "#b8ad97"}
      - {kind: disc, center: [9.8333, 6.3944], radius: 0.75, y: [-2.9, -2.3000000000000003], color: "#b8ad97"}
  - id: crank
    shape: part
    pos: [11.0, 0, 0.0]
    mass: 0.4
    friction: 0.05
    color: "#a89a7e"
    pieces:
      - {kind: poly, points: [[10.5573, -0.0808], [9.3906, 6.3137], [10.276, 6.4752], [11.4427, 0.0808]], y: [-1.5, -0.8], collide: 0, color: "#a89a7e"}
      - {kind: poly, points: [[10.9192, 0.4427], [19.7731, 2.0581], [19.9346, 1.1727], [11.0808, -0.4427]], y: [-1.5, -0.8], collide: 0, color: "#a89a7e"}
      - {kind: disc, center: [11.0, 0.0], radius: 1.2, y: [-1.7, -0.6000000000000001], color: "#8f8a80"}
      - {kind: rod, from: [9.8333, -3.1, 6.3944], to: [9.8333, -0.8, 6.3944], radius: 0.3, collide: 0, color: "#8f8a80"}
      - {kind: rod, from: [19.8538, -1.7, 1.6154], to: [19.8538, -0.5, 1.6154], radius: 0.4, collide: 1, capsule: true, color: "#8f8a80"}
  - id: bar
    shape: part
    pos: [0, 0, 0]
    mass: 0.4
    friction: 0.05
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[13.4065, 2.1354], [21.4892, 2.1354], [21.4892, 2.6354], [13.4065, 2.6354]], y: [-1.6, -0.6], collide: 2, color: "#b8ad97"}
      - {kind: poly, points: [[13.4065, 0.5954], [21.4892, 0.5954], [21.4892, 1.0954], [13.4065, 1.0954]], y: [-1.6, -0.6], collide: 2, color: "#b8ad97"}
      - {kind: poly, points: [[21.4892, -7.3846], [22.8892, -7.3846], [22.8892, 10.6154], [21.4892, 10.6154]], y: [-1.6, 0.4], collide: 0, color: "#b8ad97"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-12.0, -17.5], [30.0, -17.5], [30.0, -16.5], [-12.0, -16.5]], y: [-3.5, 5.0], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[-1.0, -16.5], [1.0, -16.5], [1.0, -1.0], [-1.0, -1.0]], y: [3.4, 4.4], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[10.1, -16.5], [11.9, -16.5], [11.9, -1.0], [10.1, -1.0]], y: [3.4, 4.4], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[20.4892, -10.3846], [23.8892, -10.3846], [23.8892, -9.3846], [20.4892, -9.3846]], y: [-1.8, 1.4], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[20.4892, 12.6154], [23.8892, 12.6154], [23.8892, 13.6154], [20.4892, 13.6154]], y: [-1.8, 1.4], collide: 0, color: "#cfc6b4"}
      - {kind: poly, points: [[22.8892, -16.5], [23.8892, -16.5], [23.8892, 13.6154], [22.8892, 13.6154]], y: [0.4, 1.4], collide: 0, color: "#cfc6b4"}
joints:
  - {id: j_d, type: hinge, body: disk, axis: [0, 1, 0], damping: 0.002}   # the one driven joint; + : clockwise
  - {id: j_r, type: hinge, body: conrod, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_c, type: hinge, body: crank, axis: [0, 1, 0], damping: 0.002}   # the bell-crank; + : clockwise (arm 1's tip goes right and down)
  - {id: j_b, type: slide, body: bar, axis: [0, 0, 1], damping: 0.3}   # the sliding bar; + : up
pins:
  - {"id": "pin_t", "a": "conrod", "b": "crank", "at": [9.8333, -2.6, 6.3944]}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_d, kind: velocity, rpm: 12, kv: 20.0, max_torque: 20}
checks:
  - {type: follow, out: j_c, in: j_d, expect: 0.5274, tol: 0.0527, min_r2: 0.97, settle_s: 2.629, window_s: 1.452}
  - {type: follow, out: j_b, in: j_c, expect: -0.0704, tol: 0.0056, min_r2: 0.97, settle_s: 2.629, window_s: 1.452}
  - {type: follow, out: j_c, in: j_d, expect: -0.4688, tol: 0.0469, min_r2: 0.97, settle_s: 5.081, window_s: 1.548}
  - {type: follow, out: j_b, in: j_c, expect: -0.0666, tol: 0.0053, min_r2: 0.97, settle_s: 5.081, window_s: 1.548}
  - {type: position, joint: j_c, min: -1.0641, max: 0.1815, settle_s: 0.3, window_s: 11.2}
  - {type: position, joint: j_b, min: -1.6748, max: 7.2552, settle_s: 0.3, window_s: 11.2}
  - {type: penetration, max: 0.0015, settle_s: 0.5}
camera: {target: [8.0, 0, -2.0], position: [8.0, -72.0, -2.0], fov: 34}
display:
  output: j_b
  labels: {j_d: "Disk (driver)", j_c: "Bell-crank", j_b: "Sliding bar"}
  proof: {label: "Connecting-rod unpinned", sub: "the disk turns but the bell-crank and the bar stand"}

