1 min read

SCARA (2D) Inverse Kinematics

  • robotics
  • kinematics
  • python

A 2R Actuator or SCARA Arm is a simple robotic system that controls a robotic arm similar to a human arm in 2D.

To determine the final position of the endpoint (end effector), you add the vectors of the segments in polar form. Each point (x, y) can be obtained as 2 possible sums of segment vectors. This is called “Forward Kinematics”

To do the reverse and determine possible segment vector combinations that reach an endpoint is called “Inverse Kinematics”

This has many applications in industrial robotics, especially when extended to 3D with 6-axis robots such as my Verso Robotics Arm (versorobotics.com)

This program is designed to simulate and animate the inverse kinematics of a SCARA (Selective Compliance Assembly Robot Arm) robot.

This script sets up a SCARA robot with specified link lengths, allowing a user to test different types of movements (linear angle, linear path, path following), and both simulates and animates these movements. The code demonstrates various aspects of SCARA robot control, from simple point-to-point motion to following complex paths delineated by the user.

This is a comprehensive tool for exploring and visualizing the principles of inverse kinematics in SCARA robots, showcasing how these robots can be programmed to move in precise, controlled ways.

Linear Angle IK plots for link lengths 50 and 50. Left: config space, where both joint angles change linearly over time. Right: output space, where the arm’s end point follows a curved arc between two points.

Linear Path IK plots for link lengths 50 and 50. Left: config space, where one joint angle drops sharply partway through. Right: output space, where the arm’s end point follows a straight line between two points.

Path IK plots for link lengths 50 and 50. Left: config space, where both joint angles change along smooth curves. Right: output space, where the arm’s end point follows a bell-shaped curve from left to right.

Animation titled Linear Path IK: a purple two-link arm anchored at the origin moves its end point along a straight line.

Animation titled Path IK: a purple two-link arm anchored at the origin moves its end point along a curved path.

Animation titled Linear Angle IK: a purple two-link arm anchored at the origin rotates both joints at steady rates.

Python code for the inverse kinematics: try a2_rad = math.acos((x**2 + y**2 - l1**2 - l2**2) / (2 * l1 * l2)), a1_rad = math.atan(y / x) - math.atan(l2 * math.sin(a2_rad) / (l1 + l2 * math.cos(a2_rad))), except ValueError: raise Exception(‘Position is out of reach’).

Python function path_invk(scr, path, intervals), with a docstring saying it returns a tuple of functions for the inverse kinematics of the SCARA robot moving along a given path. It samples the path at the middle of each interval, solves scr.inverse for each target, stores the two joint angles in lists, and returns functions a1 and a2 that interpolate those lists with _multi_lerp.