January 2, 2016
(Photo credits: HackWestern II photography team)
Delta robots are commonly used for pick-and-place machines and 3D printers. The nice thing about these designs is that we don’t need to move the actuators themselves. That means simpler wiring, faster motion, and better efficiency.
LightPainter is a delta-style robot. It rapidly moves the LED on its tip, animating the color and intensity to draw 3D shapes on long-exposure photographs:
Let’s take a look at the robotics design and construction.
LightPainter isn’t strictly a delta robot, since it doesn’t keep the end effector (the RGB LED) at a fixed angle with respect to the base. It also uses a somewhat unusual actuator arrangement, which results in a smaller footprint without reducing the robot’s reach and simpler math for controlling the arms.
Delta robot kinematics are relatively well-studied. However, most papers (like this one) leave out a lot of detail, such as choosing knee orientations, edge cases and singularities, and so on. Here, we will do a more comprehensive analysis and use it to write more robust inverse kinematics routines.
Typical delta robots have this configuration:
The red actuators move the green actuator arms, which move the blue end arms to position the yellow end effector. The animation armature is highlighted in orange, while the path of the end effector is visible as a black line. Note that each arm pivots at different points on the base. By moving the actuators off to one side, we can have the same pivot point for all three actuator arms:
Let’s solve the inverse kinematics for the latter system. First, we’ll define some variables of interest:
So represents the XYZ-coordinate (in meters) of the robot’s end effector, represents the length of the actuator arm (from the origin to the end of the arm), represents the length of end arm, and represent the actuator angles for arms 1 through 3, respectively. Finally, we define a coordinate system where the origin is the pivot point for all three actuators, and actuator 1 points toward the positive Y axis. All three actuators are 120 degrees apart from each other,
Note that on the diagram, the imaginary black lines going from the origin to the joints are the actuator arms, rather than the green pieces that the robot would actually have connected to the actuators in real life. This is done to more easily define the actuator angles and simplify the math a bit later on.
Solving the inverse kinematics means that we determine a function that finds given . That means that given a position, we can compute the necessary actuator positions that move the end effector to that position.
We first observe that the joint between an actuator arm and an end arm is always on a 3D circle around its corresponding actuator’s axis of rotation. This is because its position is determined purely by the actuator’s rotation and the length of the actuator arm:
Let be the angle of the actuator arm (for example, for arm 2). Above, this is the angle between the black line and the horizontal plane. At , the actuator arm is fully horizontal; at the actuator arm should be pointing straight upward, and at , straight downward. To ensure we always get a unique solution, we will constrain the actuator angles to between -90 and 90 degrees.
We can write a function for the position of a joint given its corresponding actuator angle, by modifying the parametric formula for a 3D circle, .
- is the center point of the circle.
- Clearly, this is since we previously defined the common center of rotation as the origin.
- is the circle’s normal (a unit vector that is perpendicular to the surface of the circle).
- This is different for each circle because they’re all facing different directions (see diagram below).
- The normals can be found using trigonometry - simply use the special right triangles to determine the corresponding vector for each white line.
- A circle has two possible normals, one for each side. goes clockwise as increases (viewed with the normal facing away from you), so we choose the normal that makes the arm move upward as increases to make our math simpler.
- The normal for arm 1 is , the positive X axis.
- The normal for arm 2 is , 30 degrees clockwise of the negative Y axis.
- The normal for arm 3 is , 30 degrees counterclockwise of the positive Y axis.
- is any vector that’s perpendicular to the normal.
- Since the actuator axes are all horizontal (all of the actuators are on their side), the positive Z axis vector is always perpendicular to the normals as required.
- is the radius of the circle.
- Clearly, this is simply , since the radius of the circle is the shortest distance to the axis of rotation.
- Substitute variables in : .
- Simplify: .
- Add vectors and simplify: .
While this is a valid equation for positions given an angle, it’s not the same angle we defined earlier on the diagram. As-is, at , is a vector pointing directly up, which means . So , and the position of the joint given is actually .
Using the trigonometric identities and , this becomes .
Basically, is an equation for the circle traced by a joint as the corresponding actuator turns. For each actuator angle from -90 to 90 degrees, will return the joint’s position.
Now we observe that the distance between joints and the end effector must be , since they are connected by end arms of length . So , since is the end effector position and is a joint position. In effect, the joint position must lie on a sphere of radius centred on the end effector. Since the joint also lies on one of the circles we calculated earlier, we can determine a joint position by intersecting the joint’s circle and the sphere around the end effector.
With this, we should now be able to solve for (WARNING: LOTS OF MATH AHEAD):
- Expand vector magnitude operator: .
- Note that is the only unknown here - we are given all the other values.
- Square both sides: .
- In general, when we square both sides of an equation, the solutions to the squared equation is the union of the solutions to the original equation and the solutions to the original equation with one side negated. Suppose we have , so . Clearly, the values of are the union of the solutions to and .
- Clearly, the left side of the equation at step 1 is positive since it is the end arm length, and the right side is non-negative since it is a square root.
- So there is no possible solution for (the equation at step 2 with one side inverted).
- Therefore, the set of solutions (values of ) to the equation at step 2 is the same as that for the equation at step 1.
- Expand dot product: .
- Expand and simplify: .
- Simplify: .
- is a normal vector, so it has magnitude 1. Since the normals are all horizontal, the Z axis component is 0 and .
- The Pythagorean trigonometric identity says that .
- Rearrange: .
- Let .
- Change variables: .
- Substitute trigonometric identity and rearrange: .
- The Pythagorean trigonometric identity says that .
- For , since .
- Square both sides: (and later, pick solutions that also satisfy equations from before step 10).
- As mentioned in step 2, the set of solutions to an equation with both sides squared is a superset of the set of solutions to the original, non-squared equation.
- That means later on, we can simply find all solutions to the squared equation, and then test each one to see if it is also a solution to the non-squared equation to solve the non-squared equation.
- Simplify and rearrange: .
- Let .
- Change variables: .
- Solve for : .
- The quadratic formula can be used to solve any quadratic equation.
- Note that the denominator could be 0, giving an undefined result. This means that the end effector position doesn’t have a unique solution.
- For example, if (actuator arms and end arms have same length), and the end effector is moved to (by setting ), then the actuators can be moved arbitrarily while the end effector stays in place - the end effector can get stuck if we move it to the origin.
- We’ll simply check if the denominator is 0, and disallow moving the end effector to that position to prevent it from getting stuck.
- Expand and simplify: .
- This gives us 2 possible values of due to the .
- Choose the value of that also satisfies equations from before step 10.
- For each of the two values of , substitute it into the equation for step 9, , and check if it is the solution. is the value that is a solution.
- Isolate : .
- For , .
- Note that when , can be a solution for the equation at step 9 while not being a solution for the equation at step 8 - when the angle isn’t between -90 and 90 degrees, from step 9 doesn’t always hold. So when the end effector is in a position where one of the actuators needs to turn outside of that range, there could be incorrect results.
- We can detect this by explicitly checking if is a solution to an equation from step 8 or earlier. If it isn’t, then and there is no solution.
This is quite straightforward to implement in code. Here, I’m using Python 3 to demonstrate the concepts, but this can trivially be translated into a lower level language:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 def inverse_kinematics(end_position, actuator_arm_length, end_arm_length): """Computes the angles of the three actuators in a delta robot given the end effector position `end_position`, actuator arm length `actuator_arm_length`, and end arm length `end_arm_length`.""" # check inputs assert len(end_position) == 3, "End effector position must be a 3-tuple of numbers" float(end_position), float(end_position), float(end_position) assert actuator_arm_length > 0, "Actuator arm length must be a positive number" assert end_arm_length > 0, "End arm length must be a positive number" arm_1 = inverse_solve_actuator(end_position, (1, 0, 0), actuator_arm_length, end_arm_length) if arm_1 is None: return None arm_2 = inverse_solve_actuator(end_position, (-1 / 2, -math.sqrt(3) / 2, 0), actuator_arm_length, end_arm_length) if arm_2 is None: return None arm_3 = inverse_solve_actuator(end_position, (-1 / 2, math.sqrt(3) / 2, 0), actuator_arm_length, end_arm_length) if arm_3 is None: return None return (arm_1, arm_2, arm_3) def inverse_solve_actuator(end_position, actuator_normal, actuator_arm_length, end_arm_length): # compute constants x = (end_arm_length ** 2 - actuator_arm_length ** 2 - end_position ** 2 - end_position ** 2 - end_position ** 2) / (2 * actuator_arm_length) y = actuator_normal * end_position - actuator_normal * end_position z = end_position # solve for possible values of sine theta determinant = y ** 2 * (y ** 2 + z ** 2 - x ** 2) if determinant < 0: # no solution exists return None denominator = y ** 2 + z ** 2 if denominator == 0: # arm lock, don't allow moving here to avoid getting stuck return None sin_theta_A = (-x * z + math.sqrt(determinant)) / denominator sin_theta_B = (-x * z - math.sqrt(determinant)) / denominator # choose the value that is a solution # since we're using floats, we choose the sine theta value with the smaller error error_sin_theta_A = abs(x + z * sin_theta_A - y * math.sqrt(1 - sin_theta_A ** 2)) error_sin_theta_B = abs(x + z * sin_theta_B - y * math.sqrt(1 - sin_theta_B ** 2)) theta = math.asin(sin_theta_A if error_sin_theta_A < error_sin_theta_B else sin_theta_B) epsilon = 1e-10 if abs(y * math.cos(theta) - z * math.sin(theta) - x) > epsilon: return None return theta
The design was pretty much made up as we went along, based on what materials could be scavenged. For example, the base and arms were all made out of empty Mountain Dew cans and assorted litter found around the room. The bottom of a soda can became the base for the arms:
Since we didn’t have any universal joints, actuator arms and end arms were joined together by gluing them to flexible strips cut from ziplock bags. This actually behaves a lot like a universal joint, if you don’t think about it too much. The arm actuators are SG90 servos (nylon-geared analog micro servos, generally about $3 each).
On top you can see the robot’s end effector, an RGB LED. This was given to us by a generous fellow participant, and appropriately covered in hot glue to diffuse the light. We didn’t have a soldering iron, so electrical connections were made using alligator clips and female/female jumpers. An Arduino Nano acts as the controller. With 6 PWM outputs, there were exactly enough pins to control the 3 servos and fade the 3 channels of the RGB LED. Overall, the circuitry and code was pretty straightforward:
Despite our best efforts, the robot actually worked!
With better motion control, the movements can be made a lot smoother, increasing the quality of the resulting photo - perhaps a good project for another time. For now, LightPainter sits on my desk, occasionally flashing and spinning around.
Project files and links:
- The Blender file used to render the graphics in this document.
- The full source code for the inverse kinematics routines.
- The controller code running on the Arduino.
- The DevPost submission for LightPainter.
And one more photo, for good measure: