It is pretty much the exact code from the example from braccio library called "takethesponge", but I just added a few lines to drop and pick the sponge up again. Heres what I don't understand. If I run this code, the robot turns on, goes to a starting position, and then begins looping through the code to pick up and drop the sponge. I don't understand how the arm repeats its position every time I power up regardless of the off position. I thought maybe the program took every motor past the limit in one direction, and then returned a certain amount, but that doesn't appear to be the case either. Shouldn't it essentially assume all motors are in a certain position at startup, and then everything should be relative to that?
#include <Braccio.h>
#include <Servo.h>
Servo base;
Servo shoulder;
Servo elbow;
Servo wrist_rot;
Servo wrist_ver;
Servo gripper;
void setup() {
Braccio.begin();
}
void loop() {
//Starting position
//(step delay M1 , M2 , M3 , M4 , M5 , M6);
Braccio.ServoMovement(20, 0, 45, 180, 180, 90, 45);
//Wait 1 second
delay(1000);
//The braccio moves to the sponge. Only the M2 servo will moves
Braccio.ServoMovement(20, 0, 100, 180, 190, 90, 45);
//Close the gripper to take the sponge. Only the M6 servo will moves
Braccio.ServoMovement(20, 0, 100, 180, 190, 90, 73 );
//Brings the sponge upwards.
Braccio.ServoMovement(20, 0, 45, 180, 45, 0, 73);
//Show the sponge. Only the M1 servo will moves
Braccio.ServoMovement(20, 180, 45, 180, 45, 0, 73);
Braccio.ServoMovement(20, 180, 100, 180, 45, 0, 73);
Braccio.ServoMovement(20, 180, 100, 180, 175, 90, 73);
Braccio.ServoMovement(20, 180, 100, 180, 175, 90, 45);
Braccio.ServoMovement(20, 180, 0, 180, 175, 90, 45);
Braccio.ServoMovement(20, 180, 100, 180, 175, 90, 45);
Braccio.ServoMovement(20, 180, 100, 180, 175, 90, 73);
delay(1000);
//Show the sponge. Only the M1 servo will moves
Braccio.ServoMovement(20, 0, 45, 180, 45, 0, 73);
Braccio.ServoMovement(20, 0, 45, 180, 190, 90, 73);
//Return to the start position.
Braccio.ServoMovement(20, 0, 100, 180, 190, 90, 73);
//Open the gripper
Braccio.ServoMovement(20, 0, 100, 180, 190, 90, 45 );
}