number: 350
slug: traverse-motion-slotted-lever
name: Traverse or to-and-fro motion
brown: "Traverse or to-and-fro motion. The pin in the upper slot being stationary, and the one in the lower slot made to move in the direction of the horizontal dotted line, the lever will by its connection with the bar give to the latter a traversing motion in its guides, a, a."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 50, duration_s: 8, floor: false}
bodies:
  # the frame: the guides a, a, the stationary pin, and the line along which the lower pin is moved
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    density: 7800
    color: "#8a8478"
    pieces:
      - {kind: poly, points: [[-22.0000, -16.0000], [27.0000, -16.0000], [27.0000, 13.0000], [-22.0000, 13.0000]], y: [1.2, 1.4], collide: 0, color: "#efe6d2"}
      - {kind: poly, points: [[-17.6000, -11.0000], [-16.0000, -11.0000], [-16.0000, -5.6000], [-17.6000, -5.6000]], y: [-0.9, 1.2], collide: 0}
      - {kind: poly, points: [[-18.2000, -10.0000], [-15.4000, -10.0000], [-15.4000, -6.6000], [-18.2000, -6.6000]], y: [-0.7, 1.2], collide: 0}
      - {kind: poly, points: [[21.8000, -11.0000], [23.4000, -11.0000], [23.4000, -5.6000], [21.8000, -5.6000]], y: [-0.9, 1.2], collide: 0}
      - {kind: poly, points: [[21.2000, -10.0000], [24.0000, -10.0000], [24.0000, -6.6000], [21.2000, -6.6000]], y: [-0.7, 1.2], collide: 0}
      - {kind: poly, points: [[-21.0000, -12.2500], [6.0000, -12.2500], [6.0000, -11.9500], [-21.0000, -11.9500]], y: [0.6, 1.2], collide: 0, color: "#b8b2a6"}
      - {kind: disc, center: [6.4400, 6.2000], radius: 0.4, y: [-2.45, 1.2], collide: 2, color: "#6f6a60"}
      - {kind: disc, center: [6.4400, 6.2000], radius: 0.9, y: [0.6, 1.2], collide: 0, color: "#6f6a60"}
  # the bar in its guides, with its upright carrying the lever's pivot
  - id: B
    shape: part
    pos: [0, 0, 0]
    mount: frame
    density: 7800
    color: "#a39a88"
    pieces:
      - {kind: poly, points: [[-19.5000, -10.2000], [25.5000, -10.2000], [25.5000, -6.4000], [-19.5000, -6.4000]], y: [-0.5, 0.5], collide: 0}
      - {kind: poly, points: [[-2.3000, -6.4000], [2.3000, -6.4000], [2.3000, 8.6000], [-2.3000, 8.6000]], y: [-0.5, 0.5], collide: 0}
      - {kind: poly, points: [[2.3000, -6.4000], [18.0000, -6.4000], [18.0000, -5.8000], [2.3000, -5.8000]], y: [-0.5, 0.5], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 0.5, y: [-2.4, -0.5], collide: 0, color: "#6f6a60"}
  # the lever, slotted at both ends, turning on the bar's pivot
  - id: Lv
    shape: part
    pos: [0, 0, 0]
    mount: B
    density: 7800
    color: "#5d6b78"
    pieces:
      - {kind: poly, points: [[-15.1677, -16.8303], [10.1851, 7.5884], [7.9652, 9.8932], [-17.3876, -14.5255]], y: [-1.5, -0.6], collide: 0}
      - {kind: disc, center: [0.0000, 0.0000], radius: 1.8, y: [-1.5, -0.6], collide: 0}
      - {kind: poly, points: [[4.4623, 4.8810], [7.6314, 7.9334], [7.2152, 8.3655], [4.0461, 5.3132]], y: [-2.3, -1.5], collide: 1}
      - {kind: poly, points: [[5.4612, 3.8439], [8.6303, 6.8962], [8.2141, 7.3284], [5.0450, 4.2760]], y: [-2.3, -1.5], collide: 1}
      - {kind: poly, points: [[8.6303, 6.8962], [9.0625, 7.3124], [7.6473, 8.7817], [7.2152, 8.3655]], y: [-2.3, -1.5], collide: 1}
      - {kind: poly, points: [[5.0291, 3.4276], [5.4612, 3.8439], [4.0461, 5.3132], [3.6139, 4.8969]], y: [-2.3, -1.5], collide: 1}
      - {kind: poly, points: [[-15.4166, -14.2655], [-10.5189, -9.5482], [-10.9351, -9.1161], [-15.8328, -13.8334]], y: [-2.3, -1.5], collide: 1}
      - {kind: poly, points: [[-14.4177, -15.3027], [-9.5200, -10.5854], [-9.9362, -10.1533], [-14.8339, -14.8705]], y: [-2.3, -1.5], collide: 1}
      - {kind: poly, points: [[-9.5200, -10.5854], [-9.0878, -10.1692], [-10.5030, -8.6999], [-10.9351, -9.1161]], y: [-2.3, -1.5], collide: 1}
      - {kind: poly, points: [[-14.8498, -15.7189], [-14.4177, -15.3027], [-15.8328, -13.8334], [-16.2650, -14.2496]], y: [-2.3, -1.5], collide: 1}
  # the slide that carries the lower pin along the horizontal line (the one driven part)
  - id: Dr
    shape: part
    pos: [-12.5600, 0, -12.1000]
    mount: frame
    density: 7800
    color: "#b07a3c"
    pieces:
      - {kind: poly, points: [[-13.9600, -13.1000], [-11.1600, -13.1000], [-11.1600, -11.1000], [-13.9600, -11.1000]], y: [-3.1, -2.45], collide: 0}
      - {kind: disc, center: [-12.5600, -12.1000], radius: 0.4, y: [-2.45, -1.45], collide: 2, color: "#6f6a60"}
joints:
  - {id: j_d, type: slide, body: Dr, axis: [1, 0, 0], damping: 0.05, range: [-6, 6]}
  - {id: j_x, type: slide, body: B, axis: [1, 0, 0], damping: 0.05, frictionloss: 4.0, range: [-4, 4]}
  - {id: j_l, type: hinge, body: Lv, axis: [0, -1, 0], damping: 0.002}
contact: {solref: [0.002, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_d, kind: velocity, rpm: 0, swing: {amplitude: 0.04, hz: 0.25}, kv: 600, max_torque: 300}
checks:
  # the lever turns about the stationary pin, so its pivot, and the bar with it, moves a fixed part of the
  # lower pin's travel: 6.2 / 18.3 of it, the pivot's height below the fixed pin over the lower pin's
  - {type: follow, out: j_x, in: j_d, expect: 0.3388, tol: 0.03, min_r2: 0.999, settle_s: 0.5, window_s: 7.0}
  - {type: penetration, max: 0.0003, settle_s: 0.2}
camera: {target: [2.5, 0, -7], position: [2.5, -128, -7], fov: 30}
display:
  output: j_x
  labels: {j_d: "Lower pin, moved to and fro (driver)", j_x: "Bar, traversing in its guides a, a", j_l: Slotted lever}

