
104 Make: Robotic Arms
WHAT ARE WE BUILDING?
Now that we understand the math involved in creating the inverse-kinematics
calculations needed for our four-link robotic arm, it’s time to once again convert our
equations into code.
STEP 1: CONVERTING OUR EQUATIONS INTO CODE
double x = 30.0;
double y = 120.0;
double linkOne = 100.0;
double linkTwo = 100.0;
double alphaOne;
double alphaTwo;
double alphaFinal;
double betaOne;
double betaTwo;
double betaFinal;
double c;
double d = 60.0;
double e;
void setup() {
Serial.begin(9600);
}
void loop()
{
c = sqrt((x*x)+(y*y));
e = sqrt(((d-x)*(d-x))+(y*y));
alphaOne = atan(y/x) * (180/PI);
alphaTwo = acos(((linkTwo*linkTwo)-(c*c)-(linkOne*linkOne)) ...