# No. 95 (Brown 1868): "On rotating the upright shaft, reciprocating rectilinear motion is imparted by the oblique disk to
# the upright rod resting upon its surface."
#
# Model (cm): the upright shaft and its oblique disk (9 cm across, set 15 deg out of square to the shaft) are one body,
# the one driven joint (20 turns a minute). The upright rod rests by its rounded foot on the disk's face, 6 cm from the
# shaft, held only by its own weight in its collar (it slides: its joint). As the disk turns, its face under the foot
# rises and falls by r tan(a) cos(t): the rod moves harmonically, 3.22 cm to and fro. Generator: opencode-runs/batch9/gen095.py.
number: 95
slug: oblique-disk-upright-rod
name: A rod worked by an oblique disk on an upright shaft
brown: "On rotating the upright shaft, reciprocating rectilinear motion is imparted by the oblique disk to the upright rod resting upon its surface."
units: cm
sim:
  timestep: 0.0005
  integrator: implicitfast
  iterations: 50
  solver: PGS
  duration_s: 10
  floor: false
bodies:
  - id: disk
    shape: part
    pos: [0, 0, 0]
    mass: 2.0
    friction: 0.05
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [0, 0, -15], to: [0, 0, 0.5], radius: 0.9, color: "#8f8a80"}   # the upright shaft
      - {kind: loft, a: [[8.538, 0.0, 2.9089], [8.371, 1.7558, 2.8642], [7.8763, 3.4442, 2.7316], [7.073, 5.0001, 2.5164], [5.9918, 6.364, 2.2267], [4.6745, 7.4832, 1.8737], [3.1715, 8.3149, 1.471], [1.5407, 8.8271, 1.034], [-0.1553, 9.0, 0.5796], [-1.8513, 8.8271, 0.1251], [-3.4821, 8.3149, -0.3119], [-4.985, 7.4832, -0.7146], [-6.3024, 6.364, -1.0676], [-7.3835, 5.0001, -1.3572], [-8.1869, 3.4442, -1.5725], [-8.6816, 1.7558, -1.7051], [-8.8486, 0.0, -1.7498], [-8.6816, -1.7558, -1.7051], [-8.1869, -3.4442, -1.5725], [-7.3835, -5.0001, -1.3572], [-6.3024, -6.364, -1.0676], [-4.985, -7.4832, -0.7146], [-3.4821, -8.3149, -0.3119], [-1.8513, -8.8271, 0.1251], [-0.1553, -9.0, 0.5796], [1.5407, -8.8271, 1.034], [3.1715, -8.3149, 1.471], [4.6745, -7.4832, 1.8737], [5.9918, -6.364, 2.2267], [7.073, -5.0001, 2.5164], [7.8763, -3.4442, 2.7316], [8.371, -1.7558, 2.8642]], b: [[8.8486, 0.0, 1.7498], [8.6816, 1.7558, 1.7051], [8.1869, 3.4442, 1.5725], [7.3835, 5.0001, 1.3572], [6.3024, 6.364, 1.0676], [4.985, 7.4832, 0.7146], [3.4821, 8.3149, 0.3119], [1.8513, 8.8271, -0.1251], [0.1553, 9.0, -0.5796], [-1.5407, 8.8271, -1.034], [-3.1715, 8.3149, -1.471], [-4.6745, 7.4832, -1.8737], [-5.9918, 6.364, -2.2267], [-7.073, 5.0001, -2.5164], [-7.8763, 3.4442, -2.7316], [-8.371, 1.7558, -2.8642], [-8.538, 0.0, -2.9089], [-8.371, -1.7558, -2.8642], [-7.8763, -3.4442, -2.7316], [-7.073, -5.0001, -2.5164], [-5.9918, -6.364, -2.2267], [-4.6745, -7.4832, -1.8737], [-3.1715, -8.3149, -1.471], [-1.5407, -8.8271, -1.034], [0.1553, -9.0, -0.5796], [1.8513, -8.8271, -0.1251], [3.4821, -8.3149, 0.3119], [4.985, -7.4832, 0.7146], [6.3024, -6.364, 1.0676], [7.3835, -5.0001, 1.3572], [8.1869, -3.4442, 1.5725], [8.6816, -1.7558, 1.7051]], collide: 1}   # the oblique disk
      - {kind: loft, a: [[6.2308, -1.6451, 2.239], [6.2308, 1.6451, 2.239], [7.9179, -2.0805, 2.691], [7.9179, 2.0805, 2.691]], b: [[6.1273, -1.6451, 2.6253], [6.1273, 1.6451, 2.6253], [7.8143, -2.0805, 3.0774], [7.8143, 2.0805, 3.0774]], color: "#8f8a80"}   # a lug on its face, to show the turning
  - id: rod
    shape: part
    pos: [6.0, 0, 2.7565]
    mass: 0.3
    friction: 0.05
    color: "#b8ad97"
    pieces:
      - {kind: rod, from: [6.0, 0, 2.7565], to: [6.0, 0, 21.7565], radius: 0.5, collide: 2, capsule: true}   # the upright rod, rounded foot
      - {kind: disc, center: [6.0, 21.7565], radius: 0.9, y: [-0.5, 0.5], color: "#8f8a80"}   # its head
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-1.4, -17], [1.4, -17], [1.0, -2], [-1.0, -2]], y: [1.8, 2.8]}   # the shaft's standard, behind
      - {kind: poly, points: [[9.4, -17], [11.0, -17], [11.0, 23.7565], [9.4, 23.7565]], y: [1.4, 2.8]}   # the rod's standard
      - {kind: poly, points: [[6.9, 17.7565], [11.0, 17.7565], [11.0, 19.7565], [6.9, 19.7565]], y: [0.7, 2.1]}   # the collar's upper arm
      - {kind: poly, points: [[6.9, 9.7565], [11.0, 9.7565], [11.0, 11.7565], [6.9, 11.7565]], y: [0.7, 2.1]}   # the lower arm
      - {kind: poly, points: [[-10, -18], [16.0, -18], [16.0, -17], [-10, -17]], y: [-3, 3], color: "#b9b09c"}
joints:
  - {id: j_s, type: hinge, body: disk, axis: [0, 0, 1], damping: 0.002}   # the one driven joint
  - {id: j_z, type: slide, body: rod, axis: [0, 0, 1], damping: 0.05, range: [-4.7154, 0.5]}   # the rod in its collars; + : up
driver: {joint: j_s, kind: velocity, rpm: 20.0, kv: 20.0, max_torque: 20}
checks:
  - {type: follow, out: j_z, in: j_s, expect: -0.01606, tol: 0.00048, min_r2: 0.995, settle_s: 3.7083, window_s: 0.0833}   # mid-fall: -A a radian
  - {type: follow, out: j_z, in: j_s, expect: -0.01135, tol: 0.00034, min_r2: 0.995, settle_s: 3.3333, window_s: 0.0833}
  - {type: follow, out: j_z, in: j_s, expect: 0.01606, tol: 0.00048, min_r2: 0.995, settle_s: 5.2083, window_s: 0.0833}   # mid-rise
  - {type: position, joint: j_z, min: -3.2654, max: 0.05, settle_s: 0.5, window_s: 9}   # the stroke: 2 r tan(a)
camera: {target: [4.0, 0, 2.3782], position: [4.0, -95, 31.3782], fov: 34}
display:
  output: j_z
  labels: {j_s: "Upright shaft and oblique disk (driver)", j_z: "Rod"}
  proof: {label: "Disk out of contact", sub: "the shaft turns but the rod stands"}

