# No. 277 (Brown 1868): "Col. Colt’s invention for obtaining the movement of the cylinder of a revolving fire-arm by the act of cocking the hammer. As the hammer is drawn back to cock it, the dog, a, attached to the tumbler, acts on the ratchet, b, on the back of the cylinder. The dog is held up to the ratchet by a spring, c."
#
# Model (cm, gravity on): the cylinder turns on its axis along x; on its back face, the ratchet b: 6 teeth (one a chamber) standing 0.6 out of the face, each a steep
# face and a ramp. The hammer turns on a pin along y behind the cylinder, the one driven joint: drawn back and let forward 0.42 rad each way, 0.5 times a second.
# On its tumbler, 1.5 forward of the pivot and 1.0 to the side of the cylinder's axis, the dog a hangs on a pin; a spring c on that pin (a joint spring) holds its tip
# forward onto the ratchet. Cocking lifts the dog's tip, which lifts the steep face of the tooth over it and turns the cylinder a sixth of a turn; letting the hammer
# down, the tip rides down the next ramp against the spring and drops in behind the next tooth. A little friction on the cylinder's axis holds it between strokes.
# A light bolt under the cylinder (a slide with a spring) rides a six-notched star on the cylinder's front. Only the dog's contact with the ratchet turns the cylinder. Generator: opencode-runs/batch12/gen277.py.
number: 277
slug: colt-revolver-cylinder
name: "Colt's revolver: the cylinder turned by cocking the hammer"
brown: "Col. Colt’s invention for obtaining the movement of the cylinder of a revolving fire-arm by the act of cocking the hammer. As the hammer is drawn back to cock it, the dog, a, attached to the tumbler, acts on the ratchet, b, on the back of the cylinder. The dog is held up to the ratchet by a spring, c."
units: cm
sim:
  timestep: 0.0002
  integrator: implicitfast
  iterations: 100
  solver: CG
  multiccd: true
  duration_s: 12
  floor: false
bodies:
  - id: cylinder
    shape: part
    pos: [0, 0, 0]
    mass: 0.1
    friction: 0.15
    color: "#c9c2b2"
    pieces:
      - {kind: rod, from: [-10, 0, 0], to: [-4.0, 0, 0], radius: 2.6, collide: 0}   # the cylinder
      - {kind: rod, from: [-11, 0, 0], to: [-10, 0, 0], radius: 0.5, collide: 0, color: "#8f8a80"}   # its arbor
      - {kind: rod, from: [-10.02, 1.2366, 1.0924], to: [-9.98, 1.2366, 1.0924], radius: 0.6, collide: 0, color: "#3b3833"}   # a chamber's mouth
      - {kind: rod, from: [-10.02, -0.3278, 1.6171], to: [-9.98, -0.3278, 1.6171], radius: 0.6, collide: 0, color: "#3b3833"}   # a chamber's mouth
      - {kind: rod, from: [-10.02, -1.5644, 0.5247], to: [-9.98, -1.5644, 0.5247], radius: 0.6, collide: 0, color: "#3b3833"}   # a chamber's mouth
      - {kind: rod, from: [-10.02, -1.2366, -1.0924], to: [-9.98, -1.2366, -1.0924], radius: 0.6, collide: 0, color: "#3b3833"}   # a chamber's mouth
      - {kind: rod, from: [-10.02, 0.3278, -1.6171], to: [-9.98, 0.3278, -1.6171], radius: 0.6, collide: 0, color: "#3b3833"}   # a chamber's mouth
      - {kind: rod, from: [-10.02, 1.5644, -0.5247], to: [-9.98, 1.5644, -0.5247], radius: 0.6, collide: 0, color: "#3b3833"}   # a chamber's mouth
      - {kind: loft, a: [[-4.0, 0.539, 0.1093], [-4.0, 1.4211, 0.2881], [-3.4, 1.4211, 0.2881], [-3.4, 0.539, 0.1093]], b: [[-4.0, 0.1749, 0.5215], [-4.0, 0.4611, 1.3747], [-3.94, 0.4611, 1.3747], [-3.94, 0.1749, 0.5215]], collide: 1}
      - {kind: loft, a: [[-4.0, 0.1749, 0.5215], [-4.0, 0.4611, 1.3747], [-3.4, 0.4611, 1.3747], [-3.4, 0.1749, 0.5215]], b: [[-4.0, -0.3641, 0.4122], [-4.0, -0.96, 1.0867], [-3.94, -0.96, 1.0867], [-3.94, -0.3641, 0.4122]], collide: 1}
      - {kind: loft, a: [[-4.0, -0.3641, 0.4122], [-4.0, -0.96, 1.0867], [-3.4, -0.96, 1.0867], [-3.4, -0.3641, 0.4122]], b: [[-4.0, -0.539, -0.1093], [-4.0, -1.4211, -0.2881], [-3.94, -1.4211, -0.2881], [-3.94, -0.539, -0.1093]], collide: 1}
      - {kind: loft, a: [[-4.0, -0.539, -0.1093], [-4.0, -1.4211, -0.2881], [-3.4, -1.4211, -0.2881], [-3.4, -0.539, -0.1093]], b: [[-4.0, -0.1749, -0.5215], [-4.0, -0.4611, -1.3747], [-3.94, -0.4611, -1.3747], [-3.94, -0.1749, -0.5215]], collide: 1}
      - {kind: loft, a: [[-4.0, -0.1749, -0.5215], [-4.0, -0.4611, -1.3747], [-3.4, -0.4611, -1.3747], [-3.4, -0.1749, -0.5215]], b: [[-4.0, 0.3641, -0.4122], [-4.0, 0.96, -1.0867], [-3.94, 0.96, -1.0867], [-3.94, 0.3641, -0.4122]], collide: 1}
      - {kind: loft, a: [[-4.0, 0.3641, -0.4122], [-4.0, 0.96, -1.0867], [-3.4, 0.96, -1.0867], [-3.4, 0.3641, -0.4122]], b: [[-4.0, 0.539, 0.1093], [-4.0, 1.4211, 0.2881], [-3.94, 1.4211, 0.2881], [-3.94, 0.539, 0.1093]], collide: 1}
      - {kind: loft, a: [[-9.6, 0.0, -2.2], [-9.6, 0.0, -2.5], [-9.6, 1.4, -2.4249], [-9.6, 2.1651, -1.25], [-9.6, 1.9053, -1.1]], b: [[-8.9, 0.0, -2.2], [-8.9, 0.0, -2.5], [-8.9, 1.4, -2.4249], [-8.9, 2.1651, -1.25], [-8.9, 1.9053, -1.1]], collide: 1}   # the bolt's star: a V notch for each chamber
      - {kind: loft, a: [[-9.6, 1.9053, -1.1], [-9.6, 2.1651, -1.25], [-9.6, 2.8, -0.0], [-9.6, 2.1651, 1.25], [-9.6, 1.9053, 1.1]], b: [[-8.9, 1.9053, -1.1], [-8.9, 2.1651, -1.25], [-8.9, 2.8, -0.0], [-8.9, 2.1651, 1.25], [-8.9, 1.9053, 1.1]], collide: 1}
      - {kind: loft, a: [[-9.6, 1.9053, 1.1], [-9.6, 2.1651, 1.25], [-9.6, 1.4, 2.4249], [-9.6, 0.0, 2.5], [-9.6, 0.0, 2.2]], b: [[-8.9, 1.9053, 1.1], [-8.9, 2.1651, 1.25], [-8.9, 1.4, 2.4249], [-8.9, 0.0, 2.5], [-8.9, 0.0, 2.2]], collide: 1}
      - {kind: loft, a: [[-9.6, 0.0, 2.2], [-9.6, 0.0, 2.5], [-9.6, -1.4, 2.4249], [-9.6, -2.1651, 1.25], [-9.6, -1.9053, 1.1]], b: [[-8.9, 0.0, 2.2], [-8.9, 0.0, 2.5], [-8.9, -1.4, 2.4249], [-8.9, -2.1651, 1.25], [-8.9, -1.9053, 1.1]], collide: 1}
      - {kind: loft, a: [[-9.6, -1.9053, 1.1], [-9.6, -2.1651, 1.25], [-9.6, -2.8, 0.0], [-9.6, -2.1651, -1.25], [-9.6, -1.9053, -1.1]], b: [[-8.9, -1.9053, 1.1], [-8.9, -2.1651, 1.25], [-8.9, -2.8, 0.0], [-8.9, -2.1651, -1.25], [-8.9, -1.9053, -1.1]], collide: 1}
      - {kind: loft, a: [[-9.6, -1.9053, -1.1], [-9.6, -2.1651, -1.25], [-9.6, -1.4, -2.4249], [-9.6, 0.0, -2.5], [-9.6, 0.0, -2.2]], b: [[-8.9, -1.9053, -1.1], [-8.9, -2.1651, -1.25], [-8.9, -1.4, -2.4249], [-8.9, 0.0, -2.5], [-8.9, 0.0, -2.2]], collide: 1}
  - id: bolt
    shape: part
    pos: [-9.25, 0, -2.65]
    mass: 0.01
    friction: 0.1
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [-9.549999999999999, 0, -2.65], to: [-8.950000000000001, 0, -2.65], radius: 0.15, capsule: true, collide: 2}   # the bolt's tip
      - {kind: rod, from: [-9.25, 0, -2.65], to: [-9.25, 0, -4.2], radius: 0.12, collide: 0}   # its stem
  - id: hammer
    shape: part
    pos: [-2.1, 0, -2.6]
    density: 1000.0
    color: "#d9cdb0"
    pieces:
      - {kind: poly, points: [[-0.2, -2.6], [-0.8, -4.1], [-2.1, -4.6], [-3.4, -4.2], [-4.0, -3.2], [-3.7, -1.7], [-2.7, -0.2], [-1.9, 2.0], [-1.1, 3.4], [0.5, 3.8], [0.1, 2.6], [-0.6, 1.0], [-0.5, -1.0]], y: [-0.4, 0.4], collide: 0}   # the hammer and its tumbler
      - {kind: rod, from: [-3.6, -0.4, -2.6], to: [-3.6, 1.2, -2.6], radius: 0.18, collide: 0, color: "#8f8a80"}   # the dog's pin
  - id: dog
    shape: part
    pos: [-3.6, 1.0, -2.6]
    mount: hammer
    mass: 0.02
    friction: 0.15
    color: "#efe6d2"
    pieces:
      - {kind: poly, points: [[-3.8, -2.6], [-3.4, -2.6], [-3.5119, -0.1], [-3.7919, -0.1]], y: [0.85, 1.15], collide: 0}   # the dog a
      - {kind: rod, from: [-3.6919, 0.9, 0.0], to: [-3.6919, 1.1, 0.0], radius: 0.12, capsule: true, collide: 2}   # its tip
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [-2.1, -0.9, -2.6], to: [-2.1, 0.9, -2.6], radius: 0.35, collide: 0}   # the hammer's pivot
      - {kind: rod, from: [-12, 0, 0], to: [-11, 0, 0], radius: 0.7, collide: 0}   # the cylinder's arbor in the frame
joints:
  - {id: j_cyl, type: hinge, body: cylinder, axis: [1, 0, 0], damping: 0.0005, frictionloss: 0.003}   # + : the side by the dog turns up
  - {id: j_hammer, type: hinge, body: hammer, axis: [0, 1, 0], damping: 0.001}   # the one driven joint; + : drawn back (cocking)
  - {id: j_bolt, type: slide, body: bolt, axis: [0, 0, 1], range: [-0.8, 0.05], stiffness: 30.0, springref: 0.3, damping: 0.05}   # the bolt's spring presses it up into the star
  - {id: j_dog, type: hinge, body: dog, axis: [0, 1, 0], stiffness: 0.003, springref: -0.8, range: [-1.2, 0.8], damping: 0.0002}   # the spring c; - : the tip forward
contact: {solref: [0.001, 1.0], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_hammer, kind: velocity, rpm: 0, swing: {amplitude: 0.42, hz: 0.5}, kv: 3.0, max_torque: 5}
checks:
  - {type: advance, joint: j_cyl, beat: j_hammer, expect: 0.5236, tol: 0.04, settle_s: 2.2, window_s: 9.5}   # a sixth of a turn each cocking: half of it a beat
  - {type: penetration, max: 0.0008, settle_s: 0.5}
camera: {target: [-1.3, 0.6, -0.8], position: [6.4, -25.5, 3.7], fov: 34}
display:
  output: j_cyl
  labels: {j_hammer: "Hammer (driver)", j_cyl: "Cylinder", j_dog: "Dog"}
  proof: {label: "Colt's revolver", sub: "cocking the hammer turns the cylinder a chamber"}

