voiceWaveOnHello
didIGetIt?
Using gripperPosition we can determine if mimicArm has grabbed a block or not. A gripper position value high enough indicates that mimicArm has a block, so it will move the block to the bucket. This example illustrates simple decisions without external sensors.
Commands Used
robotGrab(x);
gripperMove(x);
gripperPosition();
robotMove(x,y);
if(conditional)
else delay(x);
Download didIGetIt.ino for Arduino
Download didIGetIt.abp for mimicBlock
Cut and paste code:
#include <robot.h>
void setup() {
// put your setup code here, to run once:
robotActivate();
delay(2000);
}
void loop() {
gripperMove(100); //set the gripper to slightly opened
robotMove(1, 127); //move to start postiion
robotMove(2, 127); //move to start position
robotMove(3, 150); //move to start position
robotGrab(0); //turn off gripper motor
robotGrab(-75); //open the gripper some
delay(500); //wait for gripper to open
robotGrab(100); //grab the block
delay(2000); //wait for gripper to move
if (gripperPosition() < 30) { //if gripper position is below 30 it didn't get the block. Start over.
robotGrab(0);
gripperMove(100);
delay(2000);
}
else { //We got the block, now move it to the bucket.
robotMove(2, 127);
delay(100);
robotMove(1, 255);
delay(1000);
delay(1000);
robotGrab(0);
gripperMove(100);
delay(2000);
robotMove(2, 127);
delay(1000);
}
}