Problem 240644 · easy · Robotics · Level 02 Motion

Which Wells Can the Pipette Reach?

workspace · distance · annulus · boundary cases

A lab robot pipettes liquid into wells on a plate. Seen from above it is a planar two-link arm: its shoulder at the origin, a first link of length l1, an elbow, and a second link of length l2 ending in the pipette tip. Both joints can turn all the way round.

Such an arm can put its tip on exactly the points whose distance r from the base satisfies

|l_1 - l_2| \le r \le l_1 + l_2

a ring (an annulus) around the base. Both edges belong to it: on the outer circle the arm is stretched straight, on the inner circle it is folded back on itself (when l1 == l2 the inner circle is just the base, which the folded arm can reach).

Write reach_status(l1, l2, targets) that returns, for each target (x, y) in order, one string:

  • "reach" if the tip can get there;
  • "too far" if the target lies outside the outer circle;
  • "too close" if it lies inside the inner circle.

All lengths and coordinates are whole numbers of millimetres.

Examples

Input:  l1 = 30, l2 = 20, targets = [(40, 30), (3, 4), (8, 6), (60, 10)]
Output: ["reach", "too close", "reach", "too far"]
Explanation: (40, 30) is at distance 50 = 30 + 20, on the outer edge;
(3, 4) is at distance 5 < 10; (8, 6) is at distance 10 = 30 - 20, on the inner
edge; (60, 10) is at distance 60.8 > 50.

Input:  l1 = 25, l2 = 25, targets = [(0, 0), (-35, 0)]
Output: ["reach", "reach"]

Goals

  • Describe the workspace of a two-link arm as a ring around the base
  • Classify a target by its distance from the base
  • Treat both edges of the ring as reachable, exactly
Starting Python…