 # Kinematics: Output is different than Calculations

Hello! I don't know if this is the right forum to ask this question, but I am currently working on inverse kinematics for a quadruped. I am using servo motors and I am using the law of cosines in order to find the initial angles for the legs. I have attached my code and output below. My problem is that when I enter the height (angleVal) the output is spitting out wildly different numbers than expected.

The height is set to 189, the thigh and legs are set to 133.9. When I enter this into a calculator it gives me the correct initial angles which are 45 degrees for the shoulder and 90 degrees for the knee. I don't know why my output looks like this please help!

`````` int angleVal[]={0,0,189.3};

}

}
Serial.print("X1:  ");
Serial.print(angleVal);
Serial.print(" || Y1:  ");
Serial.print(angleVal);
Serial.print(" || counter:  ");
Serial.print(angleVal);

//kinematics(angleVal, angleVal, angleVal);

float shoulder1 = sq(thigh) + sq(angleVal) - sq(leg);
float shoulder2 = 2 * thigh * angleVal;
float shoulder3 = shoulder1/shoulder2;

float shoulder = shoulderRad * (180/PI);
float knee = kneeRad * (180/PI);

Serial.print(" || shoulderAngle:  ");
Serial.print(shoulder);
Serial.print(" || knee:  ");
Serial.println(knee);
`````` An int can never be initialized to 189.3. 'int' means "integer".

1 Like

Thank you so much, I didn't even realize this! perfect fix.