# No. 247 (Brown 1868): "A mode of releasing a sounding-weight. When the piece projecting from the bottom of the rod strikes the bottom of the sea,
# it is forced upward relatively to the rod, and withdraws the catch from under the weight, which drops off and allows the rod to be lifted without it."
#
# Model (cm, gravity on, the rod seen in section): the rod is lowered and raised by the line, the one driven joint, a slow positioned swing
# (6.2 cm down and back up past where it started). The weight (2 kg, a ball bored for the rod) rides on the catch's tooth, which comes out
# through the rod's side. The catch is hinged in the rod; the weight's load holds it out against a stop. The feeler slides in the rod's foot,
# held down by a light spring, and projects below it. When the feeler strikes the sea bottom it is pushed up relatively to the rod, lifts the catch's
# tail, and the tooth withdraws from under the weight, which drops to the bottom (slowed by the water: damping on its guide). The rod rises without it.
# Feeler on bottom, feeler on the catch's tail, tooth under the weight and weight on the bottom are all real contact. Generator: opencode-runs/batch11/gen247.py.
number: 247
slug: releasing-a-sounding-weight
name: A mode of releasing a sounding-weight
brown: "A mode of releasing a sounding-weight. When the piece projecting from the bottom of the rod strikes the bottom of the sea, it is forced upward relatively to the rod, and withdraws the catch from under the weight, which drops off and allows the rod to be lifted without it."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 60, duration_s: 8}
bodies:
  - id: rod
    shape: part
    pos: [0, 0, 0]
    mass: 1.0
    color: "#b8ad97"
    pieces:
      - {kind: poly, points: [[-1.5, 1.0], [-1.0, 1.0], [-1.0, 16], [-1.5, 16]], y: [-1.5, 1.5]}   # the rod's left wall
      - {kind: poly, points: [[1.0, 1.0], [1.5, 1.0], [1.5, 13.0], [1.0, 13.0]], y: [-1.5, 1.5]}   # its right wall below the window
      - {kind: poly, points: [[1.0, 14.8], [1.5, 14.8], [1.5, 16], [1.0, 16]], y: [-1.5, 1.5]}
      - {kind: poly, points: [[-1.5, 16], [1.5, 16], [1.5, 34], [-1.5, 34]], y: [-1.5, 1.5]}   # the solid rod above
      - {kind: poly, points: [[-1.5, 0], [0.2, 0], [0.2, 1.0], [-1.5, 1.0]], y: [-1.5, 1.5]}   # the foot, bored for the feeler
      - {kind: poly, points: [[1.0, 0], [1.5, 0], [1.5, 1.0], [1.0, 1.0]], y: [-1.5, 1.5]}
  - id: catch
    shape: part
    pos: [-0.5, 0, 10]
    mount: rod
    mass: 0.05
    friction: 0.15
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-0.8, 9.8], [-0.2, 9.8], [-0.2, 13.4], [-0.8, 13.4]], y: [-0.6, 0.6]}   # the catch's upright arm
      - {kind: poly, points: [[-0.8, 13.4], [2.2, 13.4], [2.2, 14], [-0.8, 14]], y: [-0.6, 0.6], collide: 1}   # its tooth, out through the rod's side
      - {kind: poly, points: [[-0.7, 10.1], [-0.3, 9.7], [0.85, 8.55], [0.55, 8.85]], y: [-0.6, 0.6]}   # its tail
      - {kind: disc, center: [0.7, 8.7], radius: 0.25, y: [-0.6, 0.6], collide: 1}   # the tail's end, on the feeler
      - {kind: disc, center: [-0.5, 10], radius: 0.55, y: [-0.8, 0.8], color: "#3a352c"}   # its pin
  - id: feeler
    shape: part
    pos: [0.6, 0, 0]
    mount: rod
    mass: 0.1
    friction: 0.3
    color: "#6f6a60"
    pieces:
      - {kind: poly, points: [[0.3, -1.8], [0.9, -1.8], [0.9, 8.0], [0.3, 8.0]], y: [-0.4, 0.4]}   # the feeler's stem in the rod
      - {kind: poly, points: [[0.0, 8.0], [1.0, 8.0], [1.0, 8.35], [0.0, 8.35]], y: [-0.5, 0.5], collide: 2}   # its head, under the catch's tail
      - {kind: poly, points: [[-1.2, -2.6], [1.6, -2.6], [1.6, -1.8], [-1.2, -1.8]], y: [-1.2, 1.2], collide: 2}   # its foot, below the rod
  - id: weight
    shape: part
    pos: [0, 0, 18]
    mass: 2
    friction: 0.15
    color: "#7d756a"
    pieces:
      - {kind: poly, points: [[1.8, 14.0], [3.0, 14.0], [3.6591, 14.5925], [4.2032, 15.2921], [4.6153, 16.0767], [4.8824, 16.9218], [4.996, 17.8007], [4.9527, 18.6859], [4.7538, 19.5496], [4.4056, 20.3645], [3.9189, 21.1052], [3.3091, 21.7483], [2.5953, 22.2737], [1.8, 22.6648], [1.8, 22.6648]], y: [-2.5, 2.5], collide: 2}
      - {kind: poly, points: [[-1.8, 22.6648], [-1.8, 22.6648], [-2.5953, 22.2737], [-3.3091, 21.7483], [-3.9189, 21.1052], [-4.4056, 20.3645], [-4.7538, 19.5496], [-4.9527, 18.6859], [-4.996, 17.8007], [-4.8824, 16.9218], [-4.6153, 16.0767], [-4.2032, 15.2921], [-3.6591, 14.5925], [-3.0, 14.0], [-1.8, 14.0]], y: [-2.5, 2.5], collide: 2}
  - id: sea
    shape: part
    pos: [0, 0, -7.6]
    fixed: true
    friction: 0.5
    color: "#a68a5b"
    pieces:
      - {kind: poly, points: [[-40, -9.1], [40, -9.1], [40, -7.6], [-40, -7.6]], y: [-6, 30], collide: 1}   # the sea bottom
joints:
  - {id: j_rod, type: slide, body: rod, axis: [0, 0, -1], damping: 0}   # the one driven joint: the line lowering and raising the rod (+: down)
  - {id: j_catch, type: hinge, body: catch, axis: [0, -1, 0], range: [0, 0.8], stiffness: 0.5, springref: -0.2, damping: 0.002}   # the catch (+: tooth withdrawn)
  - {id: j_feel, type: slide, body: feeler, axis: [0, 0, 1], range: [0, 0.7], stiffness: 300, springref: -1, damping: 1}   # the feeler in the rod's foot (+: pushed up)
  - {id: j_w, type: slide, body: weight, axis: [0, 0, -1], damping: 40}   # the weight on its guide (+: down); the water slows it
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_rod, kind: velocity, swing: {amplitude: 0.062, hz: 0.1}, kv: 20000, max_torque: 400}
checks:
  - {type: follow, out: j_w, in: j_rod, expect: 1, tol: 0.02, min_r2: 0.999, settle_s: 0.2, window_s: 1.0}   # the weight goes down on the catch
  - {type: position, joint: j_catch, min: -0.01, max: 0.03, settle_s: 0.2, window_s: 1.0}   # the catch held out under the weight
  - {type: position, joint: j_w, min: 21.3, max: 21.8, settle_s: 5, window_s: 2.9}   # dropped: on the sea bottom
  - {type: position, joint: j_rod, min: -7, max: -6.3, settle_s: 7.2, window_s: 0.6}   # the rod lifted without it
  - {type: penetration, max: 0.002, settle_s: 0.3}
camera: {target: [0, 0, 0], position: [0, -120, 2], fov: 30}
display:
  output: j_w
  labels: {j_rod: "Rod lowered and raised by the line (driver)", j_w: "Weight", j_feel: "Feeler", j_catch: "Catch"}

