number: 365
slug: oblique-rollers-rod
name: Rod driven along and round between oblique rollers
brown: "Cylindrical rod arranged between two rollers, the axes of which are oblique to each other. The rotation of the rollers produces both a longitudinal and a rotary motion of the rod."
units: cm
sim: {timestep: 0.0005, integrator: implicitfast, iterations: 100, solver: PGS, multiccd: false, duration_s: 8, floor: false}
bodies:
  # the lower roller, the driver
  - id: lower
    shape: part
    pos: [0, 0, -4.0]
    density: 7800
    friction: 0.9
    color: "#9c958a"
    pieces:
      - {kind: rod, from: [-7.6427, -2.3642, -4.0], to: [7.6427, 2.3642, -4.0], radius: 3.0, capsule: true, collide: 1}
      - {kind: rod, from: [-12.2283, -3.7827, -4.0], to: [12.2283, 3.7827, -4.0], radius: 0.6, collide: 0, color: "#8f8a80"}
  # the upper roller, free, pressing down by its weight
  - id: upper_guide
    shape: part
    pos: [0, 0, 4.0]
    density: 7800
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [-12.2283, 3.7827, 4.6], to: [12.2283, -3.7827, 4.6], radius: 0.3, collide: 0}
  - id: upper
    shape: part
    mount: upper_guide
    pos: [0, 0, 4.0]
    density: 7800
    friction: 0.9
    color: "#b5ae9f"
    pieces:
      - {kind: rod, from: [-7.6427, 2.3642, 4.0], to: [7.6427, -2.3642, 4.0], radius: 3.0, capsule: true, collide: 1}
      - {kind: rod, from: [-12.2283, 3.7827, 4.0], to: [12.2283, -3.7827, 4.0], radius: 0.6, collide: 0, color: "#8f8a80"}
  # the rod
  - id: rod_x
    shape: part
    pos: [-12.0, 0, 0]
    density: 1000
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [-34.1, 0, 0], to: [-34.0, 0, 0], radius: 0.2, collide: 0}
  - id: rod_z
    shape: part
    mount: rod_x
    pos: [-12.0, 0, 0]
    density: 1000
    color: "#8f8a80"
    pieces:
      - {kind: rod, from: [10.0, 0, 0], to: [10.1, 0, 0], radius: 0.2, collide: 0}
  - id: rod
    shape: part
    mount: rod_z
    pos: [-12.0, 0, 0]
    density: 7800
    friction: 0.9
    color: "#d9cfb6"
    pieces:
      - {kind: rod, from: [-34.0, 0, 0], to: [10.0, 0, 0], radius: 1.0, capsule: true, collide: 2}
      - {kind: rod, from: [-18.0, 0, 0.8], to: [-18.0, 0, 2.4], radius: 0.25, collide: 0, color: "#6f6a60"}
      - {kind: rod, from: [-18.0, 0, -0.8], to: [-18.0, 0, -2.4], radius: 0.25, collide: 0, color: "#6f6a60"}
  - id: frame
    shape: part
    pos: [0, 0, 0]
    fixed: true
    color: "#cfc6b4"
    pieces:
      - {kind: poly, points: [[-40, -16], [40, -16], [40, -15], [-40, -15]], y: [-12, 12], color: "#b9b09c"}
      - {kind: poly, points: [[-13.2283, -15], [-11.2283, -15], [-11.528300000000002, -4.0], [-12.9283, -4.0]], y: [-4.3827, -3.1827]}
      - {kind: poly, points: [[11.2283, -15], [13.2283, -15], [12.9283, -4.0], [11.528300000000002, -4.0]], y: [3.1827, 4.3827]}
      - {kind: poly, points: [[-13.2283, -15], [-11.2283, -15], [-11.528300000000002, 7.0], [-12.9283, 7.0]], y: [3.1827, 4.3827]}
      - {kind: poly, points: [[11.2283, -15], [13.2283, -15], [12.9283, 7.0], [11.528300000000002, 7.0]], y: [-4.3827, -3.1827]}
      - {kind: poly, points: [[-38, -15], [-36, -15], [-36, 1.6], [-38, 1.6]], y: [-1.5, 1.5]}
      - {kind: poly, points: [[36, -15], [38, -15], [38, 1.6], [36, 1.6]], y: [-1.5, 1.5]}
joints:
  - {id: j_r, type: hinge, body: lower, axis: [0.9553, 0.2955, 0], damping: 0.001}   # the one driven joint
  - {id: j_u, type: hinge, body: upper, axis: [0.9553, -0.2955, 0], damping: 0.0005}
  - {id: j_uz, type: slide, body: upper_guide, axis: [0, 0, 1], range: [-1, 1], damping: 2}
  - {id: j_x, type: slide, body: rod_x, axis: [1, 0, 0], range: [-10, 30], damping: 0.01}
  - {id: j_z, type: slide, body: rod_z, axis: [0, 0, 1], range: [-1, 1], damping: 0.5}
  - {id: j_t, type: hinge, body: rod, axis: [1, 0, 0], damping: 0.0005}
contact: {solref: [0.002, 1], solimp: [0.95, 0.99, 0.0005], margin: 0}
driver: {joint: j_r, kind: velocity, rpm: 10, kv: 2, max_torque: 10}
checks:
  - {type: ratio, out: j_x, in: j_r, expect: 0.0089, tol: 0.0006, settle_s: 1.0, window_s: 6}
  - {type: ratio, out: j_t, in: j_r, expect: -2.866, tol: 0.15, settle_s: 1.0, window_s: 6}
  - {type: penetration, max: 0.001, settle_s: 0.5}
camera: {target: [0, 0, -19], position: [80, -130, 60], fov: 30}
display:
  output: j_x
  labels: {j_r: "Lower roller (driver)", j_u: "Upper roller", j_x: "Rod, along", j_t: "Rod, round"}

