I have animated a leg in a 3D software and wrote out position data for my servos that are hard coded position arrays. I'm delaying by the FPS I animated at, but strangely when the loop completes there is an additional delay in the servo which is causing the motion to not be smooth. Even if I add more position data and change the FPS delay, there is still a blip in the motion. Is there anything that could be causing this?
#include <Servo.h>
Servo hips_servo;
int i = 0;
int fps = 42; // 1000 ms / 24 frames per second
int hips_pos[] = {70,65,64,64,64,64,64,64,52,42,33,25,19,15,15,15,18,23,35,52,71,93,109,120,129,136,141,144,144,143,139,134,127,119,111,101,91,80};
void setup() {
Serial.begin(9600);
hips_servo.attach(4);
}
void loop() {
// SET HIP POSITIONS
for ( i = 0; i < 38; i++ ) {
int val = hips_pos[i];
hips_servo.write(val);
delay(fps);
}
}