# No. 134 (Brown 1868): "Uniform circular motion into rectilinear by means of a rope or band, which is wound once or more times around the drum."
#
# Model (cm, gravity on): a four-spoked drum of 10 cm radius is turned by hand (the one driven joint, swung 1.0 rad each way). A rope tied to the drum at 70 degrees from the top is wound round it (250 degrees, counter-clockwise from the lashing)
# and leaves at the bottom along the rail to a carriage that slides on it: the carriage runs 0.1040 m per radian to the left as the drum turns clockwise. A light spring (the plate has none) draws the carriage back out, keeping the rope taut as it pays out.
# Generator: opencode-runs/batch10/gen134.py.
number: 134
slug: rope-wound-on-drum
name: A rope wound round a drum dragging a carriage
brown: "Uniform circular motion into rectilinear by means of a rope or band, which is wound once or more times around the drum."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 80, duration_s: 16.0, floor: false}
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-16, -1.6], [39.0, -1.6], [39.0, -0.4], [-16, -0.4]], y: [-4, 4], collide: 0, color: "#b9b09c"}   # the rail the rope leaves along
      - {kind: poly, points: [[-2.4, -0.4], [2.4, -0.4], [1.4, 11.0], [-1.4, 11.0]], y: [2.4, 3.8], collide: 0, color: "#bdb4a0"}   # the drum's standard behind
  - {id: drum, shape: assembly, pos: [0, 0, 11.0], color: "#e6dcc6"}
  - id: carriage
    shape: part
    pos: [27.0, 0, 0.6]
    mass: 0.8
    friction: 0.1
    color: "#b8ac92"
    pieces:
      - {kind: poly, points: [[24.0, -0.4], [30.0, -0.4], [30.0, 2.4], [24.0, 2.4]], y: [-2.4, 2.4], collide: 0}
joints:
  - {id: j_d, type: hinge, body: drum, axis: [0, 1, 0], damping: 0.01}   # the drum, turned by hand: the one driven joint; + : clockwise
  - {id: j_c, type: slide, body: carriage, axis: [1, 0, 0], damping: 0.4, range: [-14, 14], stiffness: 40.0, springref: 20.0}   # + : to the right, away from the drum; the spring draws it out
wheels:
  - {id: drm, body: drum, pos: [0, 0, 0], radius: 10.0, width: 3.0, rim_width: 2.4, mass: 2.0, spokes: 4, hub: 2.6, flange: 0.8}
shafts:
  - {id: axle, body: drum, from: [0, -3.2, 0], to: [0, 4.4, 0], radius: 0.8}
cords:
  - id: rope
    from: {body: drum, at: [10.0547, 0, 14.6596]}
    to: {body: carriage, at: [24.0, 0, 0.6]}
    over: [drm]
    under: [drm]
    links: 50
    thickness: 0.8
    density: 1400
    stiffness: 40000
    pretension: 5.0
    damping: 12
    friction: 0.5
contact: {solref: [0.0006, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_d, kind: velocity, rpm: 0, swing: {amplitude: 1.0, hz: 0.2}, kv: 300.0, max_torque: 50}
checks:
  - {type: follow, out: j_c, in: j_d, expect: -0.104, tol: 0.0042, min_r2: 0.995, settle_s: 1.0, window_s: 14}   # the carriage runs a radius to the radian, toward the drum as it turns clockwise
  - {type: position, joint: j_c, min: -11.2, max: 11.2, settle_s: 0.0, window_s: 16}
camera: {target: [9, 0, 8], position: [9, -100.0, 8], fov: 34}
display:
  output: j_c
  labels: {j_d: "Drum (driver)", j_c: "Carriage"}
  proof: {label: "Rope cut", sub: "the drum turns but the carriage stands"}

