IK Drawing Robot

GOALS: Design a robot that can draw a shape using inverse kinematics
SKILLS: CAD, Kinematics, MATLAB, MicroPython, ESP32

This was a 2-week long project for my Introductory Robotics class. The requirements for this project were just to create a 2-degree-of-freedom arm that uses inverse kinematics (IK) to control the end effector to draw a shape.

Kinematics Theory

Here's the IK I used to correlate an end effector point to servo angles. It's essentially just a bit of trigonometry.

Using Pythagorean Theorem, Arctan, and a simplified Law of Cosines:

c = x2 + y2
e = (dx) 2 + y2
b₁ = atan2(y,x)
a₁ = atan2(y,dx)
b₂ = acos ( c 2L )
a₂ = acos ( e 2L )

MATLAB Simulation


Before going straight to incorporating the kinematics with the mechanical system, I wanted to simulate everything in MATLAB to make sure that my logic was sound. So I made a MATLAB script that models the linkage system, and you can input an array of points and it will draw it out! Let it be known that this was programmed by hand, and the only time AI was used was to generate the array of points for the star shape.


MATLAB code! MicroPython code!

Hardware

Mechanical Debugging

This first prototype of the arm linkages I designed. The issue
here was that it didn't have as big a range of motion as I
would have liked. I fixed this by giving more space between
the linkage and the bearings, and also offsetting the bearing
from the arm of the linkage

Also, I originally planned on using the encoders mounted to the mirrored side with the black linkages, but due to the nature of a 2-week long project, I found it more worthwhile to spend my time making sure the kinematics of the robot worked.

that one issue that drove me crazy

Ok do you see how the star is warped? Like its kind of squished in the Y axis? I spent SO LONG trying to figure out why this was happening. The MATLAB simulation helped me prove it wasn't a code issue, and when I was looking at the mechanical system I realized that I think this five-bar linkage setup is a little fundamentally flawed. Especially compared to the X-axis, the Y-axis is controlled by such minute changes in servo angles that it makes it really hard to accurately control - especially given the generic servo motors that I had. I think if I had all the time in the world I would experiment with better servo motors with higher step resolution, or potentially switching to motors and trying to do some fancy gear ratio stuff.