# No. 130 (Brown 1868): "Shears for cutting iron plates, etc. The jaws are opened by the weight of the long arm of the upper one, and closed by the rotation of the cam."
#
# Model (cm, gravity on): the upper jaw is a lever pivoted on a post, its long arm reaching 23 cm to the left over a round disc cam, its jaw 10.5 cm to the right over the fixed lower jaw. The cam is a disc of 3.5 cm radius turning on a shaft 1.35 cm off its centre, and is the one driven joint
# (12 rpm). The long arm rests on the cam by its own weight: as the cam turns it lifts the arm 2.7 cm (0.169 rad) at the cam, the jaw falls and closes on the lower one; as the cam comes round the weight of the long arm carries the lever back and the jaws open.
# A stop under the tip of the long arm holds the jaws open when the cam is away. Generator: opencode-runs/batch10/gen130.py.
number: 130
slug: shears-cam
name: Shears opened by a weight and closed by a cam
brown: "Shears for cutting iron plates, etc. The jaws are opened by the weight of the long arm of the upper one, and closed by the rotation of the cam."
units: cm
sim: {timestep: 0.0002, integrator: implicitfast, iterations: 60, duration_s: 12.0, floor: false}
bodies:
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-30, -3], [14, -3], [14, 0], [-30, 0]], y: [-4, 4], collide: 0, color: "#b9b09c"}
      - {kind: poly, points: [[-3, 0], [-3, 5.0], [0.5, 6.6], [11, 6.6], [11, 0]], y: [-1.4, 1.4], collide: 0, color: "#a8a398"}   # the lower jaw
      - {kind: poly, points: [[-2.2, 0], [2.2, 0], [1.6, 11.6], [-1.6, 11.6]], y: [1.2, 2.6], collide: 0}   # the post behind the pivot
      - {kind: poly, points: [[-17.3, 0], [-14.7, 0], [-15.2, 6.849999999999999], [-16.8, 6.849999999999999]], y: [1.8, 3.0], collide: 0}   # the cam's standard
      - {kind: poly, points: [[-22.5, 0], [-19.5, 0], [-19.5, 8.17], [-22.5, 8.17]], y: [-1, 1], collide: 1, color: "#a8a398"}   # the stop under the long arm's tip
  - id: arm
    shape: part
    pos: [0, 0, 10.0]
    mass: 1.2
    friction: 0.2
    color: "#8f8a80"
    pieces:
      - {kind: poly, points: [[-23, 8.2], [-23, 9.5], [-2, 12.5], [-2, 8.2]], y: [-1, 1], collide: 2}   # the long arm
      - {kind: poly, points: [[-2, 8.2], [10.3, 8.7], [11.2, 10.1], [6, 13.6], [-2, 12.5]], y: [-1, 1], collide: 0}   # the jaw and its shoulder
      - {kind: rod, from: [0, -1.4, 10.0], to: [0, 2.6, 10.0], radius: 0.4, collide: 0, color: "#6f6a60"}
  - id: cam
    shape: part
    pos: [-16.0, 0, 6.049999999999999]
    mass: 1.0
    friction: 0.2
    color: "#d9cfb6"
    pieces:
      - {kind: poly, points: [[-12.5, 4.7], [-12.5169, 5.0431], [-12.5673, 5.3828], [-12.6507, 5.716], [-12.7664, 6.0394], [-12.9133, 6.3499], [-13.0899, 6.6445], [-13.2945, 6.9204], [-13.5251, 7.1749], [-13.7796, 7.4055], [-14.0555, 7.6101], [-14.3501, 7.7867], [-14.6606, 7.9336], [-14.984, 8.0493], [-15.3172, 8.1327], [-15.6569, 8.1831], [-16.0, 8.2], [-16.3431, 8.1831], [-16.6828, 8.1327], [-17.016, 8.0493], [-17.3394, 7.9336], [-17.6499, 7.7867], [-17.9445, 7.6101], [-18.2204, 7.4055], [-18.4749, 7.1749], [-18.7055, 6.9204], [-18.9101, 6.6445], [-19.0867, 6.3499], [-19.2336, 6.0394], [-19.3493, 5.716], [-19.4327, 5.3828], [-19.4831, 5.0431], [-19.5, 4.7], [-19.4831, 4.3569], [-19.4327, 4.0172], [-19.3493, 3.684], [-19.2336, 3.3606], [-19.0867, 3.0501], [-18.9101, 2.7555], [-18.7055, 2.4796], [-18.4749, 2.2251], [-18.2204, 1.9945], [-17.9445, 1.7899], [-17.6499, 1.6133], [-17.3394, 1.4664], [-17.016, 1.3507], [-16.6828, 1.2673], [-16.3431, 1.2169], [-16.0, 1.2], [-15.6569, 1.2169], [-15.3172, 1.2673], [-14.984, 1.3507], [-14.6606, 1.4664], [-14.3501, 1.6133], [-14.0555, 1.7899], [-13.7796, 1.9945], [-13.5251, 2.2251], [-13.2945, 2.4796], [-13.0899, 2.7555], [-12.9133, 3.0501], [-12.7664, 3.3606], [-12.6507, 3.684], [-12.5673, 4.0172], [-12.5169, 4.3569]], y: [-1.4, 1.4], collide: 1}   # the disc, its centre 1.35 cm below the shaft at the start
      - {kind: rod, from: [-16.0, -1.8, 6.049999999999999], to: [-16.0, 3.0, 6.049999999999999], radius: 0.45, collide: 0, color: "#6f6a60"}
joints:
  - {id: j_arm, type: hinge, body: arm, axis: [0, 1, 0], damping: 0.02}   # the upper jaw; + : clockwise, the jaw closing
  - {id: j_cam, type: hinge, body: cam, axis: [0, 1, 0], damping: 0.002}   # the one driven joint
driver: {joint: j_cam, kind: velocity, rpm: 12.0, kv: 20.0, max_torque: 20}
checks:
  - {type: follow, out: j_arm, in: j_cam, expect: 0.0776, tol: 0.009, min_r2: 0.98, settle_s: 0.9, window_s: 0.9}   # closing: the jaw turns (e/16) sin(phi) a radian of cam, about 0.077 over the middle of the lift
  - {type: follow, out: j_arm, in: j_cam, expect: -0.0827, tol: 0.012, min_r2: 0.98, settle_s: 3.4, window_s: 1.0}   # and opening again under the long arm's weight
  - {type: amplitude, joint: j_arm, min: 0.080, max: 0.093, settle_s: 1, window_s: 10}
  - {type: position, joint: j_arm, min: -0.02, max: 0.22, settle_s: 0.0, window_s: 12}
camera: {target: [-6, 0, 8], position: [-6, -78, 8], fov: 34}
display:
  output: j_arm
  labels: {j_cam: "Cam (driver)", j_arm: "Upper jaw"}
  proof: {label: "Cam away", sub: "the cam turns but the jaws stay open"}

