# No. 250 (Brown 1868): "Anti-friction bearing. Instead of a shaft revolving in an ordinary bearing it is sometimes supported on the
# circumference of wheels. The friction is thus reduced to the least amount."
#
# Model (cm, gravity on): the shaft (journal radius 1.2) lies by its weight in the crotch of two overlapping friction wheels (radius 7, centres
# 12 apart) at each end, four wheels in all, each free on its own fixed axle. The shaft has no bearing of its own: it is on free carriages across
# (x) and up and down (z), so the wheels' rims alone carry it. The shaft is turned at 30 rpm (the one driven joint); the wheels are turned only
# by rolling contact with it, the other way at r/R = 0.1714 of its speed. Generator: opencode-runs/batch11/gen250.py.
number: 250
slug: anti-friction-bearing
name: Anti-friction bearing
brown: "Anti-friction bearing. Instead of a shaft revolving in an ordinary bearing it is sometimes supported on the circumference of wheels. The friction is thus reduced to the least amount."
units: cm
sim: {timestep: 0.001, integrator: implicitfast, iterations: 50, duration_s: 8, floor: false}
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#a39a88"
    pieces:
      - {kind: rod, from: [-6, -5.15, 0], to: [-6, -6.6, 0], radius: 0.6, collide: 0}   # an axle
      - {kind: poly, points: [[-7.4, -9.5], [-4.6, -9.5], [-5.0, 0], [-7.0, 0]], y: [-6.6, -5.8], collide: 0}   # its standard
      - {kind: rod, from: [6, -3.65, 0], to: [6, -5.1, 0], radius: 0.6, collide: 0}   # an axle
      - {kind: poly, points: [[4.6, -9.5], [7.4, -9.5], [7.0, 0], [5.0, 0]], y: [-5.1, -4.3], collide: 0}   # its standard
      - {kind: rod, from: [-6, 4.55, 0], to: [-6, 6.0, 0], radius: 0.6, collide: 0}   # an axle
      - {kind: poly, points: [[-7.4, -9.5], [-4.6, -9.5], [-5.0, 0], [-7.0, 0]], y: [5.2, 6.0], collide: 0}   # its standard
      - {kind: rod, from: [6, 6.05, 0], to: [6, 7.5, 0], radius: 0.6, collide: 0}   # an axle
      - {kind: poly, points: [[4.6, -9.5], [7.4, -9.5], [7.0, 0], [5.0, 0]], y: [6.7, 7.5], collide: 0}   # its standard
      - {kind: poly, points: [[-9, -10.3], [9, -10.3], [9, -9.5], [-9, -9.5]], y: [-8, 8], collide: 0}   # the bed
  - id: wheel_fl
    shape: part
    pos: [-6, 0, 0]
    mass: 0.6
    friction: 0.9
    color: "#c9bfa9"
    pieces:
      - {kind: rod, from: [-6, -5.6, 0], to: [-6, -4.7, 0], radius: 7, collide: 2, capsule: true}   # the rim (its circumference carries the shaft)
      - {kind: rod, from: [-6, -6.0, 0], to: [-6, -4.3, 0], radius: 0.8, collide: 0}   # the boss
      - {kind: rod, from: [-6, -5.75, 0], to: [-1.4038, -5.75, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [-6, -5.75, 0], to: [-10.5962, -5.75, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [-6, -5.75, 0], to: [-10.5962, -5.75, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [-6, -5.75, 0], to: [-1.4038, -5.75, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
  - id: wheel_fr
    shape: part
    pos: [6, 0, 0]
    mass: 0.6
    friction: 0.9
    color: "#c9bfa9"
    pieces:
      - {kind: rod, from: [6, -4.1, 0], to: [6, -3.2, 0], radius: 7, collide: 2, capsule: true}   # the rim (its circumference carries the shaft)
      - {kind: rod, from: [6, -4.5, 0], to: [6, -2.8, 0], radius: 0.8, collide: 0}   # the boss
      - {kind: rod, from: [6, -4.25, 0], to: [10.5962, -4.25, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [6, -4.25, 0], to: [1.4038, -4.25, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [6, -4.25, 0], to: [1.4038, -4.25, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [6, -4.25, 0], to: [10.5962, -4.25, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
  - id: wheel_bl
    shape: part
    pos: [-6, 0, 0]
    mass: 0.6
    friction: 0.9
    color: "#c9bfa9"
    pieces:
      - {kind: rod, from: [-6, 4.1, 0], to: [-6, 5.0, 0], radius: 7, collide: 2, capsule: true}   # the rim (its circumference carries the shaft)
      - {kind: rod, from: [-6, 3.7, 0], to: [-6, 5.4, 0], radius: 0.8, collide: 0}   # the boss
      - {kind: rod, from: [-6, 3.95, 0], to: [-1.4038, 3.95, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [-6, 3.95, 0], to: [-10.5962, 3.95, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [-6, 3.95, 0], to: [-10.5962, 3.95, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [-6, 3.95, 0], to: [-1.4038, 3.95, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
  - id: wheel_br
    shape: part
    pos: [6, 0, 0]
    mass: 0.6
    friction: 0.9
    color: "#c9bfa9"
    pieces:
      - {kind: rod, from: [6, 5.6, 0], to: [6, 6.5, 0], radius: 7, collide: 2, capsule: true}   # the rim (its circumference carries the shaft)
      - {kind: rod, from: [6, 5.2, 0], to: [6, 6.9, 0], radius: 0.8, collide: 0}   # the boss
      - {kind: rod, from: [6, 5.45, 0], to: [10.5962, 5.45, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [6, 5.45, 0], to: [1.4038, 5.45, 4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [6, 5.45, 0], to: [1.4038, 5.45, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
      - {kind: rod, from: [6, 5.45, 0], to: [10.5962, 5.45, -4.5962], radius: 0.3, collide: 0, color: "#6e6656"}   # a spoke on its face
  - id: way_x
    shape: part
    pos: [0, 0, 5.5893]
    mass: 0.05
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [0, 0, 5.5893], to: [0, 0, 5.6393], radius: 0.05}
  - id: way_z
    shape: part
    pos: [0, 0, 5.5893]
    mount: way_x
    mass: 0.05
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [0, 0, 5.5893], to: [0, 0, 5.6393], radius: 0.05}
  - id: shaft
    shape: part
    pos: [0, 0, 5.5893]
    mount: way_z
    mass: 2
    friction: 0.9
    color: "#d9cfba"
    pieces:
      - {kind: rod, from: [0, -7.5, 5.5893], to: [0, 7.5, 5.5893], radius: 1.2, collide: 1, capsule: true}   # the shaft's journals
      - {kind: disc, center: [0, 5.5893], radius: 5.5, inner: 4.6, y: [-0.6, 0.6], collide: 0}   # its pulley (rim)
      - {kind: disc, center: [0, 5.5893], radius: 2.0, inner: 1.2, y: [-0.9, 0.9], collide: 0}   # its boss
      - {kind: rod, from: [0, 0, 7.4893], to: [0, 0, 10.2893], radius: 0.35, collide: 0}   # its arms
      - {kind: rod, from: [0, 0, 3.6893], to: [0, 0, 0.8893], radius: 0.35, collide: 0}
      - {kind: rod, from: [1.9, 0, 5.5893], to: [4.7, 0, 5.5893], radius: 0.35, collide: 0}
      - {kind: rod, from: [-1.9, 0, 5.5893], to: [-4.7, 0, 5.5893], radius: 0.35, collide: 0}
joints:
  - {id: j_fl, type: hinge, body: wheel_fl, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_fr, type: hinge, body: wheel_fr, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_bl, type: hinge, body: wheel_bl, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_br, type: hinge, body: wheel_br, axis: [0, 1, 0], damping: 0.0005}
  - {id: j_x, type: slide, body: way_x, axis: [1, 0, 0], damping: 0.5}   # the shaft free across
  - {id: j_z, type: slide, body: way_z, axis: [0, 0, 1], damping: 0.5}   # and up and down: only the wheels' rims carry it
  - {id: j_shaft, type: hinge, body: shaft, axis: [0, 1, 0], damping: 0.001}   # the one driven joint
contact: {solref: [0.004, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_shaft, kind: velocity, rpm: 30, kv: 5, max_torque: 2}
checks:
  - {type: ratio, out: j_fl, in: j_shaft, expect: -0.1714, tol: 0.005, settle_s: 1, window_s: 6.5}   # rolled by the shaft, the other way at r/R
  - {type: ratio, out: j_fr, in: j_shaft, expect: -0.1714, tol: 0.005, settle_s: 1, window_s: 6.5}   # rolled by the shaft, the other way at r/R
  - {type: ratio, out: j_bl, in: j_shaft, expect: -0.1714, tol: 0.005, settle_s: 1, window_s: 6.5}   # rolled by the shaft, the other way at r/R
  - {type: ratio, out: j_br, in: j_shaft, expect: -0.1714, tol: 0.005, settle_s: 1, window_s: 6.5}   # rolled by the shaft, the other way at r/R
  - {type: position, joint: j_x, min: -0.05, max: 0.05, settle_s: 0.5, window_s: 7}   # the shaft stays in the crotch
  - {type: position, joint: j_z, min: -0.1, max: 0.05, settle_s: 0.5, window_s: 7}   # carried on the rims
  - {type: penetration, max: 0.002, settle_s: 0.5}
camera: {target: [0, 0, 0], position: [22, -75, 18], fov: 30}
display:
  output: j_fl
  labels: {j_shaft: "Shaft (driver)", j_fl: "Front left wheel", j_fr: "Front right wheel", j_z: "Shaft up/down"}

