# No. 376 (Brown 1868): "Tread-wheel horse-power turned by the weight of an animal attempting to walk up one side of its interior; has been used for driving the paddle-wheels of ferry-boats and other purposes by horses. The turn-spit dog used also to be employed in such a wheel in ancient times for turning meat while roasting on a spit."
#
# Reading of the figure (cm, gravity on; Brown's face view): the tread-wheel (14 cm to its tread) turns on its axle against the
# load it drives (the paddle-wheels: 1 N m per rad/s). The horse (2 kg) stands free on the tread on
# the left, low in the wheel. Its walking is the one driven joint: a roller under its hind hooves, turned at a set speed against the tread; its fore hooves ride on a free roller.
# The horse climbs until its weight, standing out to the side of the axle, balances the load, and stays there while the wheel goes
# round under it: the weight of the animal drives the wheel. The bars across the wheel's face are drawn only.
# Generator: opencode-runs/batch12/gen376.py.
number: 376
slug: tread-wheel-horse-power
name: Tread-wheel horse-power
brown: "Tread-wheel horse-power turned by the weight of an animal attempting to walk up one side of its interior; has been used for driving the paddle-wheels of ferry-boats and other purposes by horses. The turn-spit dog used also to be employed in such a wheel in ancient times for turning meat while roasting on a spit."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  solver: PGS
  multiccd: true
  duration_s: 12
  floor: false
bodies:
  - id: wheel
    shape: part
    pos: [0, 0, 0]
    mass: 4.0
    friction: 0.9
    color: "#b9ad93"
    pieces:
      - {kind: band, center: [0, 0], r: [14.0, 15.4], a: [0, 6.2832], y: [-1.6, 1.6], slices: 120, collide: 2}   # the rim and its tread
      - {kind: disc, center: [0, 0], radius: 15.4, inner: 14.0, y: [2.6, 3.2], collide: 0, color: "#a39d90"}   # the back rim
      - {kind: rod, from: [-13.7823, -2.2, -1.1661], to: [6.7402, -2.2, -12.0781], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: rod, from: [-13.1903, -2.2, 4.0687], to: [10.749, -2.2, -8.66], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: rod, from: [-10.749, -2.2, 8.66], to: [13.1903, -2.2, -4.0687], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: rod, from: [-6.7402, -2.2, 12.0781], to: [13.7823, -2.2, 1.1661], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: rod, from: [1.1661, -2.2, -13.7823], to: [12.0781, -2.2, 6.7402], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: rod, from: [-4.0687, -2.2, -13.1903], to: [8.66, -2.2, 10.749], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: rod, from: [-8.66, -2.2, -10.749], to: [4.0687, -2.2, 13.1903], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: rod, from: [-12.0781, -2.2, -6.7402], to: [-1.1661, -2.2, 13.7823], radius: 0.35, collide: 0, color: "#d8cfbd"}
      - {kind: disc, center: [14.7, 0.0], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [14.1991, 3.8046], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [12.7306, 7.35], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [10.3945, 10.3945], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [7.35, 12.7306], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [3.8046, 14.1991], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [0.0, 14.7], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-3.8046, 14.1991], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-7.35, 12.7306], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-10.3945, 10.3945], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-12.7306, 7.35], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-14.1991, 3.8046], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-14.7, 0.0], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-14.1991, -3.8046], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-12.7306, -7.35], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-10.3945, -10.3945], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-7.35, -12.7306], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-3.8046, -14.1991], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [-0.0, -14.7], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [3.8046, -14.1991], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [7.35, -12.7306], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [10.3945, -10.3945], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [12.7306, -7.35], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [14.1991, -3.8046], radius: 0.25, y: [-1.7, -1.6], collide: 0, color: "#55504a"}
      - {kind: disc, center: [0, 0], radius: 2.0, y: [-2.6, 3.2], collide: 0, color: "#8f8a80"}   # the axle's boss
  - id: hx
    shape: part
    pos: [-0.5145, 0, -12.7847]
    mass: 0.01
    pieces:
      - {kind: rod, from: [-0.5145, -0.1, -12.7847], to: [-0.5145, 0.1, -12.7847], radius: 0.05, collide: 0}
  - id: hz
    shape: part
    mount: hx
    pos: [-0.5145, 0, -12.7847]
    mass: 0.01
    pieces:
      - {kind: rod, from: [-0.5145, -0.1, -12.7847], to: [-0.5145, 0.1, -12.7847], radius: 0.05, collide: 0}
  - id: horse
    shape: part
    mount: hz
    pos: [-0.5145, 0, -12.7847]
    mass: 2
    color: "#6e5034"
    pieces:
      - {kind: poly, points: [[2.1506, -10.6404], [-7.7332, -6.6471], [-7.9182, -4.329], [-6.2211, -2.2105], [3.3242, -6.3475], [3.8478, -8.5219]], y: [-0.8, 0.8], collide: 0}   # the horse's body
      - {kind: poly, points: [[-5.359, -4.2413], [-7.9645, -3.7495], [-9.053, 2.5791], [-6.6375, 3.0053]], y: [-0.6, 0.6], collide: 0}   # its neck
      - {kind: poly, points: [[-6.2991, 3.149], [-9.5863, 1.9533], [-12.5717, 4.2812], [-11.8436, 5.3891], [-7.6432, 5.3745]], y: [-0.5, 0.5], collide: 0}   # its head
      - {kind: poly, points: [[-6.489, 4.067], [-7.1148, 4.6002], [-6.6741, 6.3851]], y: [-0.3, 0.3], collide: 0}   # its ear
      - {kind: poly, points: [[3.7553, -7.3629], [4.3811, -7.8961], [5.2285, -14.1273], [4.0695, -14.2199]], y: [-0.3, 0.3], collide: 0, color: "#5e4a36"}   # its tail
      - {kind: rod, from: [1.4323, -0.4, -8.9481], to: [-1.3485, -0.4, -14.0154], radius: 0.38, collide: 0}
      - {kind: rod, from: [0.468, -0.4, -8.5585], to: [-0.6067, -0.4, -14.3151], radius: 0.38, collide: 0}
      - {kind: rod, from: [-6.2819, -0.4, -5.8314], to: [-8.3951, -0.4, -11.1684], radius: 0.38, collide: 0}
      - {kind: rod, from: [-7.2462, -0.4, -5.4418], to: [-9.1368, -0.4, -10.8687], radius: 0.38, collide: 0}
  - id: tread
    shape: part
    mount: horse
    pos: [-0.5145, 0, -12.7847]
    mass: 1.0
    friction: 1.3
    color: "#3e342a"
    pieces:
      - {kind: disc, center: [-0.5145, -12.7847], radius: 1.2, y: [-0.6, 0.6], collide: 0}
      - {kind: rod, from: [-0.5145, -0.3, -12.7847], to: [-0.5145, 0.3, -12.7847], radius: 1.2, capsule: true, collide: 1}   # (a round contact)   # its hind hooves: the driven tread-roller
  - id: fore
    shape: part
    mount: horse
    pos: [-8.2082, 0, -9.8152]
    mass: 0.1
    friction: 1.3
    color: "#3e342a"
    pieces:
      - {kind: disc, center: [-8.2082, -9.8152], radius: 1.2, y: [-0.6, 0.6], collide: 0}
      - {kind: rod, from: [-8.2082, -0.3, -9.8152], to: [-8.2082, 0.3, -9.8152], radius: 1.2, capsule: true, collide: 1}   # (a round contact)   # its fore hooves, free
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [0, -3.0, 0], to: [0, 5.0, 0], radius: 0.9, collide: 0}   # the axle
joints:
  - {id: j_w, type: hinge, body: wheel, axis: [0, 1, 0], damping: 1}   # the wheel, against its load; + : its bottom runs to the left
  - {id: j_hx, type: slide, body: hx, axis: [1, 0, 0], damping: 0.5}   # the horse, free on the tread: along
  - {id: j_hz, type: slide, body: hz, axis: [0, 0, 1], damping: 0.5}   # up and down
  - {id: j_h, type: hinge, body: horse, axis: [0, 1, 0], range: [-0.35, 0.35], damping: 0.05}   # and pitching (it keeps its feet)
  - {id: j_f, type: hinge, body: tread, axis: [0, 1, 0], damping: 0.001}   # the horse's walking (the one driven joint)
  - {id: j_g, type: hinge, body: fore, axis: [0, 1, 0], damping: 0.001}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.001], margin: 0}
driver: {joint: j_f, kind: velocity, rpm: -110, kv: 0.08, max_torque: 5}
checks:
  - {type: ratio, out: j_w, in: j_f, expect: 0.0857, tol: 0.01, settle_s: 4, window_s: 7}   # the tread runs under the horse's hooves
  - {type: position, joint: j_h, min: -0.1, max: 0.28, settle_s: 4, window_s: 7}   # the horse keeps both feet down, off its pitch stop
  - {type: penetration, max: 0.0015, settle_s: 0.5}
camera: {target: [0, 0, -8.0], position: [0, -112.0, -5.0], fov: 34}
display:
  output: j_w
  labels: {j_f: "Horse's walking (driver)", j_w: "Tread-wheel", j_h: "Horse"}

