grabAndDrop
grabAndDrop
A complex action accomplished with simple commands. This example takes a block from the user and drops it in a bowl. Experiment by changing the robotMove values and the robotGrab values to see how it affects the robots actions. What values do you need for heavy and light items?
Commands Used
robotMove(x,y);
robotGrab(x);
delay(x);
Download GrabAndDrop.ino for Arduino
Download GrabAndDrop.abp for mimicBlock
Cut and paste code:
#include <robot.h> //Tell your arduino to go get the custom mimicArm code
void setup() {
// put your setup code here, to run once:
robotActivate(); //Tell the robot that Arduino will be sending it commands
}
void loop() {
// put your main code here, to run repeatedly:
robotMode(arduino); //Put the robot in Arduino command mode
robotMove(1,50); //move base to one side
robotMove(2,127); //Put the robots 'shoulder' in a natural position
robotMove(3,127); //Put robot 'elbow' at in a natural position
delay(1000); //wait 1 second for everything to move
//Now reach out and grab
robotMove(2,110); //reach forward slightly
robotGrab(100); //grab fairly tightly (127 is max)
delay(2000); //wait 2 seconds to grab
//now move to bucket
robotMove(3,127); //Put the robots 'shoulder' in a natural position
delay(500); //wait .5 second for everything to move
robotMove(1,200); //move robot to oposite side
delay(500); //wait .5 second for everything to move
//move to drop position
robotMove(3,110);
robotMove(2,100);
delay(500); //wait .5 seconds for everything to move
//drop block
robotGrab(-60); //light opening force on gripper
delay(3000); //wait 30 seconds before repeating
robotGrab(0); //turn off gripper to save motor
}