-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
examples/GLC_GripAndMoveSomething/GLC_GripAndMoveSomething.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* 12/24/2016 | ||
* | ||
* Using the Gobbit robot with line sensor and gripper on pin A0, this program will... | ||
* | ||
* 1) Drive Forward along a line | ||
* 2) Stop at the end of the line (or any found intersection) | ||
* 3) Close the gripper to grab something that was placed there | ||
* 4) Turn around and drive the other direction | ||
* 5) Stop at the end of the line (or any found intersection) | ||
* 6) Open the gripper to release the something | ||
* 7) Backup a little away from the something | ||
* 8) Wait there forever | ||
* | ||
*/ | ||
|
||
// If the Adafruit motor shield v2.3 is to be used... | ||
// M1 and M2 terminals will be used. Right motor on M1, Left on M2. | ||
// UnComment the next line if you are using the Adafruit shield | ||
//#define ADAFRUIT_MS | ||
|
||
#include <GobbitLineCommand.h> | ||
|
||
GobbitLineCommand MyBot; | ||
|
||
void setup() { | ||
|
||
// attaches the servo on pin 14 which is A0 and sets the angles for Open and Closed Postions | ||
MyBot.setGripPinOpenClosed(A0,180,70); | ||
|
||
// initialize the robot | ||
MyBot.beginGobbit(); | ||
|
||
// open gripper | ||
MyBot.gripOpen(); | ||
|
||
// calibrate the line sensor on the line | ||
MyBot.calibrateLineSensor(0); | ||
|
||
} | ||
|
||
void loop() { | ||
|
||
// Drive Forward | ||
MyBot.drive('F'); | ||
|
||
// Stop at next end or intersection | ||
MyBot.drive('S'); | ||
|
||
// close gripper | ||
MyBot.gripClose(); | ||
|
||
// Make a U-Turn and drive the other direction | ||
MyBot.drive('U'); | ||
|
||
// Stop at next end or intersection | ||
MyBot.drive('S'); | ||
|
||
// open gripper | ||
MyBot.gripOpen(); | ||
|
||
// backup a little (speed 0-100, milliseconds to drive before stopping) | ||
MyBot.backup(65,300); | ||
|
||
// wait forever | ||
while(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* 12/24/2016 | ||
* | ||
* Using the Gobbit robot with line sensor and gripper on pin A0, | ||
* on a simple line course with a 90 degree X where an object is at | ||
* the end of three of the line ends, and the robot is at the other | ||
* facing the middle of the X, this program will perpetually shift | ||
* the objects around the X. | ||
* | ||
* The program will... | ||
* | ||
* One time in setup: | ||
* 1) Drive Forward along a line | ||
* 2) Turn right at the intersection and continue driving | ||
* 3) Stop at the end of the line (or any found intersection) | ||
* 4) Close the gripper to grab something that was placed there | ||
* 5) Turn around and drive the other direction | ||
* 6) Turn left at the intersection and continue driving | ||
* 7) Stop at the end of the line (or any found intersection) | ||
* 8) Open the gripper to release the something | ||
* 9) Backup a little away from the something | ||
* | ||
* Then do this over and over: | ||
* 1) Turn around and drive the other direction | ||
* 2) Drive Forward at the next intersection along the line | ||
* 3) Stop at the end of the line (or any found intersection) | ||
* 4) Close the gripper to grab something that was placed there | ||
* 5) Turn around and drive the other direction | ||
* 6) Turn left at the intersection and continue driving | ||
* 7) Stop at the end of the line (or any found intersection) | ||
* 8) Open the gripper to release the something | ||
* 9) Backup a little away from the something | ||
* | ||
*/ | ||
|
||
// If the Adafruit motor shield v2.3 is to be used... | ||
// M1 and M2 terminals will be used. Right motor on M1, Left on M2. | ||
// UnComment the next line if you are using the Adafruit shield | ||
//#define ADAFRUIT_MS | ||
|
||
|
||
#include <GobbitLineCommand.h> | ||
|
||
GobbitLineCommand MyBot; | ||
|
||
void setup() { | ||
|
||
// attaches the servo on pin 14 which is A0 and sets the angles for Open and Closed Postions | ||
MyBot.setGripPinOpenClosed(A0,180,70); | ||
|
||
// initialize the robot | ||
MyBot.beginGobbit(); | ||
|
||
// open gripper | ||
MyBot.gripOpen(); | ||
|
||
// calibrate the line sensor on the line | ||
MyBot.calibrateLineSensor(0); | ||
|
||
// Start move begins from the leg of X with no object, | ||
// with the robot facing middle of X. | ||
// This will get and move the first something into a sequence | ||
// for the main loop to repeat. | ||
|
||
MyBot.drive('F'); | ||
MyBot.drive('R'); | ||
MyBot.drive('S'); | ||
MyBot.gripClose(); | ||
MyBot.drive('U'); | ||
MyBot.drive('L'); | ||
MyBot.drive('S'); | ||
MyBot.gripOpen(); | ||
MyBot.backup(65,300); | ||
|
||
} | ||
|
||
void loop() { | ||
|
||
// This will repeat forever, just moving the three objects | ||
// one by one around the legs of the X perpetually. | ||
|
||
MyBot.drive('U'); | ||
MyBot.drive('F'); | ||
MyBot.drive('S'); | ||
MyBot.gripClose(); | ||
MyBot.drive('U'); | ||
MyBot.drive('L'); | ||
MyBot.drive('S'); | ||
MyBot.gripOpen(); | ||
MyBot.backup(65,300); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* 12/24/2016 | ||
* | ||
* This program will help you setup and test the gripper with the Gobbit robot. | ||
* We will use the GobbitLineCommand library, but you can also directly | ||
* use the gripper with the standard servo library. | ||
* | ||
* When this runs, the gripper should | ||
* | ||
* Open | ||
* Close a little bit | ||
* Close all the way | ||
* Open a little bit | ||
* Repeat | ||
* | ||
* Read the comments at each step below to determine if your gripper is properly setup. | ||
* | ||
*/ | ||
|
||
#include <GobbitLineCommand.h> | ||
|
||
// Declare an object name for your robot. Here we are calling ours MyBot. | ||
GobbitLineCommand MyBot; | ||
|
||
void setup() { | ||
|
||
// Setup the gripper. | ||
// The first variable is the pin the servo is attached (we are using A0 here), | ||
// the next variable is the angle for the Open position (start with 180), | ||
// then the angle for the Closed Postion (start around 85). | ||
// The Closed position may vary between about 70 and 85, depending on where you set | ||
// the drving gripper arm. | ||
MyBot.setGripPinOpenClosed(A0,180,85); | ||
|
||
} | ||
|
||
void loop() { | ||
|
||
// Open gripper. | ||
MyBot.gripOpen(); | ||
|
||
// Wait 1.5 seconds (1500 milliseconds) | ||
delay(1500); | ||
|
||
// Set the gripper to 98% open to see if the chosen degree for the open position is good. | ||
// If it is, the gripper should just barely close a little. | ||
// If not, you need to make the open angle you set with MyBot.setGripPinOpenClosed smaller. | ||
MyBot.gripPercentOpen(98); | ||
|
||
// Wait 1 second (1000 milliseconds) | ||
delay(1000); | ||
|
||
// Close gripper. | ||
// If the gripper is not all the way closed, you will need | ||
// to make the close angle you set with MyBot.setGripPinOpenClosed smaller. | ||
MyBot.gripClose(); | ||
|
||
// Wait 1.5 seconds (1500 milliseconds) | ||
delay(1500); | ||
|
||
// Set the gripper 2% open to see if the chosen degree for the closed position is good. | ||
// If it is, the gripper should just barely open a little. | ||
// If not, you need to make the close angle you set with MyBot.setGripPinOpenClosed bigger. | ||
MyBot.gripPercentOpen(2); | ||
|
||
// Wait 1 second (1000 milliseconds) | ||
delay(1000); | ||
|
||
} |