Two-Link Inverse Kinematics Solver
DEGREE OBJECTIVE 5
Model, analyze, and design systems or processes that integrate hardware and software to control autonomous mechanical systems.
How it meets the objective: It models a robot arm mathematically, analyzes reachability, and implements the solution in embedded code — the hardware-software integration every autonomous arm depends on.
How it works
The user enters both link lengths and a target (x, y) over a serial connection. The solver first checks the workspace: the target must lie between the maximum reach (l1+l2) and the minimum reach (|l1−l2|), rejecting infeasible inputs with a clear error rather than returning garbage angles. The elbow angle comes from the law of cosines; the base angle from atan2 minus the interior angle — then the mirrored elbow-up solution is computed by flipping the sign conventions. Every solution also round-trips through forward kinematics back to the exact target coordinates.
Engineering highlights
Numerical robustness: cosine arguments are clamped to [−1, 1] before acos() so floating-point rounding at workspace boundaries can't produce NaN.
Quadrant-safe: atan2 instead of atan handles all four quadrants and avoids division by zero.
Both solutions reported: elbow-up and elbow-down configurations, matching how real arm controllers present IK results for pose selection.
A feasible solve: reachability check passes, then both configurations are reported — elbow-down and the mirrored elbow-up solution.
Workspace validation doing its job: a target far beyond maximum reach is refused with a clear error.