# No. 377 (Brown 1868): "The tread-mill employed in jails in some countries for exercising criminals condemned to labor, and employed in grinding grain, etc.; turns by weight of persons stepping on tread-boards on periphery. This is supposed to be a Chinese invention, and it is still used in China for raising water for irrigation."
#
# Reading of the figure (cm, gravity on; Brown's view from the near side, past the spur-wheel on the drum's end): the drum
# (14 cm to its tread-boards) turns on its axle against the work it drives through the spur-wheel (1 N m per rad/s).
# The man (2 kg) stands on the boards on the near side, 70 degrees round from the top, free to move up and
# down and to and fro; his hands grip the fixed hand-rail in front of him, which keeps him from falling off backwards.
# His stepping is the one driven joint: a roller under his feet, turned at a set speed against the boards. His weight,
# standing out to the side of the axle, carries the boards down under him and turns the drum.
# The boards, the spur-wheel, the bearings and the frame's post are drawn only.
# Generator: opencode-runs/batch12/gen377.py.
number: 377
slug: tread-mill
name: Tread-mill
brown: "The tread-mill employed in jails in some countries for exercising criminals condemned to labor, and employed in grinding grain, etc.; turns by weight of persons stepping on tread-boards on periphery. This is supposed to be a Chinese invention, and it is still used in China for raising water for irrigation."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 80
  solver: PGS
  multiccd: true
  duration_s: 12
  floor: false
bodies:
  - id: drum
    shape: part
    pos: [0, 0, 0]
    mass: 6.0
    friction: 0.9
    color: "#c4b08a"
    pieces:
      - {kind: band, center: [0, 0], r: [12.8, 14.0], a: [0, 6.2832], y: [-12.0, 12.0], slices: 120, collide: 2}   # the drum and its tread
      - {kind: rod, from: [13.8, -12.0, 0.0], to: [13.8, 12.0, 0.0], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [13.6301, -12.0, 2.1588], to: [13.6301, 12.0, 2.1588], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [13.1246, -12.0, 4.2644], to: [13.1246, 12.0, 4.2644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [12.2959, -12.0, 6.2651], to: [12.2959, 12.0, 6.2651], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [11.1644, -12.0, 8.1114], to: [11.1644, 12.0, 8.1114], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [9.7581, -12.0, 9.7581], to: [9.7581, 12.0, 9.7581], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [8.1114, -12.0, 11.1644], to: [8.1114, 12.0, 11.1644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [6.2651, -12.0, 12.2959], to: [6.2651, 12.0, 12.2959], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [4.2644, -12.0, 13.1246], to: [4.2644, 12.0, 13.1246], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [2.1588, -12.0, 13.6301], to: [2.1588, 12.0, 13.6301], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [0.0, -12.0, 13.8], to: [0.0, 12.0, 13.8], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-2.1588, -12.0, 13.6301], to: [-2.1588, 12.0, 13.6301], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-4.2644, -12.0, 13.1246], to: [-4.2644, 12.0, 13.1246], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-6.2651, -12.0, 12.2959], to: [-6.2651, 12.0, 12.2959], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-8.1114, -12.0, 11.1644], to: [-8.1114, 12.0, 11.1644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-9.7581, -12.0, 9.7581], to: [-9.7581, 12.0, 9.7581], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-11.1644, -12.0, 8.1114], to: [-11.1644, 12.0, 8.1114], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-12.2959, -12.0, 6.2651], to: [-12.2959, 12.0, 6.2651], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-13.1246, -12.0, 4.2644], to: [-13.1246, 12.0, 4.2644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-13.6301, -12.0, 2.1588], to: [-13.6301, 12.0, 2.1588], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-13.8, -12.0, 0.0], to: [-13.8, 12.0, 0.0], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-13.6301, -12.0, -2.1588], to: [-13.6301, 12.0, -2.1588], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-13.1246, -12.0, -4.2644], to: [-13.1246, 12.0, -4.2644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-12.2959, -12.0, -6.2651], to: [-12.2959, 12.0, -6.2651], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-11.1644, -12.0, -8.1114], to: [-11.1644, 12.0, -8.1114], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-9.7581, -12.0, -9.7581], to: [-9.7581, 12.0, -9.7581], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-8.1114, -12.0, -11.1644], to: [-8.1114, 12.0, -11.1644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-6.2651, -12.0, -12.2959], to: [-6.2651, 12.0, -12.2959], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-4.2644, -12.0, -13.1246], to: [-4.2644, 12.0, -13.1246], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-2.1588, -12.0, -13.6301], to: [-2.1588, 12.0, -13.6301], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [-0.0, -12.0, -13.8], to: [-0.0, 12.0, -13.8], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [2.1588, -12.0, -13.6301], to: [2.1588, 12.0, -13.6301], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [4.2644, -12.0, -13.1246], to: [4.2644, 12.0, -13.1246], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [6.2651, -12.0, -12.2959], to: [6.2651, 12.0, -12.2959], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [8.1114, -12.0, -11.1644], to: [8.1114, 12.0, -11.1644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [9.7581, -12.0, -9.7581], to: [9.7581, 12.0, -9.7581], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [11.1644, -12.0, -8.1114], to: [11.1644, 12.0, -8.1114], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [12.2959, -12.0, -6.2651], to: [12.2959, 12.0, -6.2651], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [13.1246, -12.0, -4.2644], to: [13.1246, 12.0, -4.2644], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: rod, from: [13.6301, -12.0, -2.1588], to: [13.6301, 12.0, -2.1588], radius: 0.33, collide: 0, color: "#8a7552"}
      - {kind: disc, center: [0, 0], radius: 14.0, y: [11.6, 12.0], collide: 0, color: "#a39478"}   # its ends
      - {kind: disc, center: [0, 0], radius: 14.0, y: [-12.0, -11.6], collide: 0, color: "#a39478"}
      - {kind: disc, center: [0, 0], radius: 12.2, inner: 10.8, y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}   # the spur-wheel on the drum's end
      - {kind: poly, points: [[11.8653, -1.7933], [14.3417, -1.2943], [14.3417, 1.2943], [11.8653, 1.7933]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[11.6483, 2.8839], [13.7453, 4.2926], [12.7547, 6.6841], [10.2758, 6.1974]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[9.658, 7.122], [11.0563, 9.226], [9.226, 11.0563], [7.122, 9.658]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[6.1974, 10.2758], [6.6841, 12.7547], [4.2926, 13.7453], [2.8839, 11.6483]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[1.7933, 11.8653], [1.2943, 14.3417], [-1.2943, 14.3417], [-1.7933, 11.8653]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-2.8839, 11.6483], [-4.2926, 13.7453], [-6.6841, 12.7547], [-6.1974, 10.2758]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-7.122, 9.658], [-9.226, 11.0563], [-11.0563, 9.226], [-9.658, 7.122]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-10.2758, 6.1974], [-12.7547, 6.6841], [-13.7453, 4.2926], [-11.6483, 2.8839]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-11.8653, 1.7933], [-14.3417, 1.2943], [-14.3417, -1.2943], [-11.8653, -1.7933]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-11.6483, -2.8839], [-13.7453, -4.2926], [-12.7547, -6.6841], [-10.2758, -6.1974]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-9.658, -7.122], [-11.0563, -9.226], [-9.226, -11.0563], [-7.122, -9.658]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-6.1974, -10.2758], [-6.6841, -12.7547], [-4.2926, -13.7453], [-2.8839, -11.6483]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[-1.7933, -11.8653], [-1.2943, -14.3417], [1.2943, -14.3417], [1.7933, -11.8653]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[2.8839, -11.6483], [4.2926, -13.7453], [6.6841, -12.7547], [6.1974, -10.2758]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[7.122, -9.658], [9.226, -11.0563], [11.0563, -9.226], [9.658, -7.122]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: poly, points: [[10.2758, -6.1974], [12.7547, -6.6841], [13.7453, -4.2926], [11.6483, -2.8839]], y: [13.2, 14.8], collide: 0, color: "#bdb4a2"}
      - {kind: rod, from: [-11.0, 14, 0], to: [11.0, 14, 0], radius: 0.55, collide: 0, color: "#bdb4a2"}   # its arms
      - {kind: rod, from: [0, 14, -11.0], to: [0, 14, 11.0], radius: 0.55, collide: 0, color: "#bdb4a2"}
      - {kind: disc, center: [0, 0], radius: 2.0, y: [12.0, 16.0], collide: 0, color: "#8f8a80"}   # its boss
  - id: hx
    shape: part
    pos: [-14.2786, 1.0, 5.197]
    mass: 0.01
    pieces:
      - {kind: rod, from: [-14.2786, 0.9, 5.197], to: [-14.2786, 1.1, 5.197], radius: 0.05, collide: 0}
  - id: man
    shape: part
    mount: hx
    pos: [-14.2786, 1.0, 5.197]
    mass: 2
    friction: 0.6
    color: "#ece6d8"
    pieces:
      - {kind: rod, from: [-14.1386, 1.98, 5.897], to: [-14.8386, 1.77, 12.547], radius: 0.7, collide: 0, color: "#6f675d"}   # his standing leg
      - {kind: rod, from: [-14.6986, 0.23, 12.547], to: [-12.3186, -0.05, 10.097], radius: 0.7, collide: 0, color: "#6f675d"}   # the other, stepping up
      - {kind: rod, from: [-12.3186, -0.05, 10.097], to: [-12.5986, -0.05, 7.017], radius: 0.595, collide: 0, color: "#6f675d"}
      - {kind: poly, points: [[-15.9586, 12.057], [-13.5786, 12.057], [-12.9486, 14.717], [-15.3286, 14.857]], y: [-0.19, 2.19], collide: 0, color: "#ece6d8"}   # his body
      - {kind: poly, points: [[-15.3986, 14.577], [-13.0186, 14.437], [-12.1786, 17.517], [-14.6986, 17.937]], y: [-0.68, 2.68], collide: 0, color: "#ece6d8"}
      - {kind: rod, from: [-13.5786, 1.0, 17.657], to: [-13.3686, 1.0, 18.357], radius: 0.49, collide: 0, color: "#c9a27e"}   # his neck
      - {kind: rod, from: [-13.2986, 0.79, 19.127], to: [-13.2986, 1.21, 19.127], radius: 1.05, collide: 0, color: "#c9a27e"}   # his head
      - {kind: rod, from: [-13.5086, 0.72, 19.687], to: [-13.5086, 1.28, 19.687], radius: 0.875, collide: 0, color: "#3b3733"}   # his cap
      - {kind: rod, from: [-13.0186, -0.47, 17.237], to: [-8.9586, -0.19, 19.897], radius: 0.49, collide: 0, color: "#ece6d8"}   # his arms, up to the rail
      - {kind: rod, from: [-13.0186, 2.47, 17.237], to: [-8.9586, 2.19, 19.897], radius: 0.49, collide: 0, color: "#ece6d8"}
      - {kind: rod, from: [-8.6236, -0.54, 19.897], to: [-8.6236, 0.09, 19.897], radius: 0.5, capsule: true, collide: 1, color: "#c9a27e"}   # his hands, gripping the rail
      - {kind: rod, from: [-8.6236, 1.91, 19.897], to: [-8.6236, 2.54, 19.897], radius: 0.5, capsule: true, collide: 1, color: "#c9a27e"}
      - {kind: rod, from: [-10.8336, -0.54, 19.897], to: [-10.8336, 0.09, 19.897], radius: 0.5, capsule: true, collide: 1, color: "#c9a27e"}
      - {kind: rod, from: [-10.8336, 1.91, 19.897], to: [-10.8336, 2.54, 19.897], radius: 0.5, capsule: true, collide: 1, color: "#c9a27e"}
  - id: feet
    shape: part
    mount: man
    pos: [-14.2786, 1.0, 5.197]
    mass: 1.0
    friction: 1.3
    color: "#3e342a"
    pieces:
      - {kind: rod, from: [-14.2786, -0.3, 5.197], to: [-14.2786, 2.3, 5.197], radius: 1.2, capsule: true, collide: 1}   # his feet: the driven tread-roller (a round contact)
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8a7f6e"
    pieces:
      - {kind: rod, from: [0, -18.0, 0], to: [0, 19.0, 0], radius: 0.9, collide: 0, color: "#8f8a80"}   # the axle
      - {kind: poly, points: [[-2.4, 1.6], [2.4, 1.6], [5.5, -15.0], [-5.5, -15.0]], y: [16.5, 19.0], collide: 0}   # its bearings' pedestals
      - {kind: poly, points: [[-3.0, -1.6], [3.0, -1.6], [3.0, 2.6], [-3.0, 2.6]], y: [16.2, 19.3], collide: 0}
      - {kind: poly, points: [[-2.4, 1.6], [2.4, 1.6], [5.5, -15.0], [-5.5, -15.0]], y: [-18.0, -15.5], collide: 0}
      - {kind: poly, points: [[-10.0, -15.0], [10.0, -15.0], [10.0, -16.5], [-10.0, -16.5]], y: [13.0, 22.0], collide: 0}   # its sill
      - {kind: rod, from: [-9.7286, -12.0, 19.897], to: [-9.7286, 10.0, 19.897], radius: 0.6, capsule: true, collide: 2}   # the hand-rail
      - {kind: rod, from: [-26.0, 10.0, -16.0], to: [-10.2286, 10.0, 22.897], radius: 0.8, collide: 0, color: "#b5a98f"}   # the post that carries it
joints:
  - {id: j_d, type: hinge, body: drum, axis: [0, 1, 0], damping: 1}   # the drum, against its work; - : its near side runs down
  - {id: j_hx, type: slide, body: hx, axis: [1, 0, 0], damping: 0.5}   # the man, free on the boards: to and fro
  - {id: j_hz, type: slide, body: man, axis: [0, 0, 1], damping: 0.5}   # up and down
  - {id: j_f, type: hinge, body: feet, axis: [0, 1, 0], damping: 0.001}   # his stepping (the one driven joint)
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_d, in: j_f, expect: -0.0857, tol: 0.01, settle_s: 4, window_s: 7}   # the boards run down under his feet
  - {type: penetration, max: 0.0015, settle_s: 0.5}
camera: {target: [-5.0, -2.0, -8.0], position: [-85.0, 116.0, -4.0], fov: 34}
display:
  output: j_d
  labels: {j_f: "Man's stepping (driver)", j_d: "Tread-mill drum"}

