Autonomous Functions - SuitBots/ring-it-up GitHub Wiki
For autonomous functions, you must type the following:
#include Autonomous_Base.h
void forward(short power, long distance, bool direction, char DrivL, char DrivR)
(void) Function makes motors DrivL
and DrivR
rotate so they will drive the bot a distance distance
at power power
Parameter | Explanation | Data Type |
---|---|---|
power | The amount of power put in the motor | short |
distance | the distance you want the robot to go | long |
direction | Set to true for forward and false for backward | bool |
DrivL | The left Drive motor | char |
DrivR | The right Drive motor | char |
int initial_forward = 3;
forward(100, initial_forward, true, DriveL, DriveR);
void swingTurn(short power, int degree, bool direction, char DrivL, char DrivR)
(void) Function makes motors DrivL
and DrivR
rotate so they will rotate the bot a degrees
degrees at power power
Parameter | Explanation | Data Type |
---|---|---|
power | The amount of power put in the motor | short |
distance | the distance you want the robot to go | long |
direction | Set to true for forward and false for backward | bool |
DrivL | The left Drive motor | char |
DrivR | The right Drive motor | char |
int rotate_amt = 90;
swingTurn(100, rotate_amt, true, DriveL, DriveR);
void pivotTurn(short power, int degree, bool direction, char DrivL, char DrivR)
(void) rotates bot. Note: use swingTurn()
, not this.
Parameter | Explanation | Data Type |
---|---|---|
power | The amount of power put in the motor | short |
distance | the distance you want the robot to go | long |
direction | Set to true for forward and false for backward | bool |
DrivL | The left Drive motor | char |
DrivR | The right Drive motor | char |
int rotate_amt = 90;
pivotTurn(100, rotate_amt, true, DriveL, DriveR);
int IRSensorRegion (char sensorName, bool reversed)
(int) Returns the 0-9 directional value returned by the IR sensor sensorName
Parameter | Explanation | Data Type |
---|---|---|
sensorName | The sensor you want the data from | char |
reversed | If true, instead of returning a 0-9 value, the function will return a 9-0 value | bool |
int direction = IRSensorRegion(IRLeft, false);
if (direction == 5) {
IRcolumn = MIDDLE;
}
IRmax_sig (char sensor)
(int) Returns the IR signal strength read by sensor
Parameter | Explanation | Data Type |
---|---|---|
sensor | The sensor you want the data from | char |
int strength = IRmax_sig(IRright);
if (strength < THRESHOLD) {
dead_reckoning_autonomous();
} else {
sensing_autonomous();
}
peg_t dondePeg(char sensor1, char sensor2)
(peg_t) Returns whether the IR beacon is on the left column, the right column, the middle column, or if it can't tell
Parameter | Explanation | Data Type |
---|---|---|
sensor1 | The left IR sensor you want the data from | char |
sensor2 | The right IR sensor you want the data from | char |
peg_t IRcolumn = dondePeg(IRleft, IRright);
switch(IRcolumn) {
case(LEFT):
execute_left_autonomous();
break;
case(RIGHT):
execute_right_autonomous();
break;
case(MIDDLE):
execute_middle_autonomous();
break;
case(NONE);
middle_dead_reckoning_autonomous();
break;
}