Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 114 additions & 35 deletions GARY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const int backRightWheel = 0;

// Arm
const int hingeServo = 0; // high values is pi radians, low values pi 3 radians
const int topServo = 1; // 0 is down 45 degrees, 2000 is 60 degrees in the unit circle
const int topServo = 2; // 0 is down 45 degrees, 2000 is 60 degrees in the unit circle

// Sensors
const int frontLeftTape = 1;
Expand All @@ -22,51 +22,130 @@ const int backRightButton = 2;

const int whiteTapeValue = 3500; // HIGHER IS DARKER

void closeClaw();
void openClaw();
void calibration();
void resetMotors();
void measureDistances();
void yIncrease(int distance);
void xIncrease(int distance);
void yDecrease(int distance);
void xDecrease(int distance);
void rotateLeft();
void rotateRight();
void rotateLeft(int time);
void rotateRight(int time);
void calibrateTape();
void startArm();
void upArm();

int main()
{
yDecrease(10);
xIncrease(500);
xDecrease(5);

xIncrease(5);
yIncrease(10);
xDecrease(15);
// Yeah top right board
startArm(); // set values future me btw
set_servo_position(hingeServo, 1730);
set_servo_position(topServo, 1300);

msleep(500);
// yDecrease(10);
xIncrease(450);
set_servo_position(hingeServo, 1870);
msleep(1000);
set_servo_position(topServo, 200);
upArm();
msleep(500);
xDecrease(150);
yDecrease(400);
xDecrease(60);
motor(frontLeftWheel, -15);
motor(backRightWheel, -15);
motor(frontRightWheel, -15);
motor(backLeftWheel, -15);
msleep(500);
// first stove
xIncrease(50);
yIncrease(400);
xIncrease(150);
// seasoning
yDecrease(140);
yIncrease(10);
set_servo_position(hingeServo, 1750);
msleep(20);
set_servo_position(hingeServo, 1700);
msleep(20);
set_servo_position(hingeServo, 1650);
msleep(20);
set_servo_position(hingeServo, 1600);
msleep(20);
set_servo_position(hingeServo, 1550);
msleep(1550);
set_servo_position(hingeServo, 1450);
ao();
msleep(300);
set_servo_position(hingeServo, 1300);
msleep(300);
xDecrease(150);
yDecrease(580);
xDecrease(70);
rotateLeft(1650);
xIncrease(100);
msleep(300);
yDecrease(380);
msleep(50);
ao();
set_servo_position(hingeServo, 1400);
msleep(500);
// stove
xIncrease(50);
yIncrease(600);

set_servo_position(topServo, 1300);
msleep(500);
printf("cooking");
msleep(3000);
set_servo_position(topServo, 1800);
msleep(500);
set_servo_position(hingeServo, 1730)
msleep(300);
ao();
yIncrease(380);
msleep(300);
xDecrease(100);
rotateRight(1650);
yDecrease(100);
msleep(500);
xIncrease(30);
set_servo_position(hingeServo, 1300);
msleep(500);
set_servo_position(topServo, 200);
upArm();
msleep(500);
motor(frontLeftWheel, -15);
motor(backRightWheel, -15);
motor(frontRightWheel, -15);
motor(backLeftWheel, -15);
msleep(500);
set_servo_position(hingeServo, 1750);
msleep(20);
set_servo_position(hingeServo, 1700);
msleep(20);
set_servo_position(hingeServo, 1650);
msleep(20);
set_servo_position(hingeServo, 1600);
msleep(20);
set_servo_position(hingeServo, 1550);
msleep(1550);
set_servo_position(hingeServo, 1450);
ao();
msleep(300);
set_servo_position(hingeServo, 1300);
msleep(5000);
// first stove

}


void closeClaw() {
set_servo_position(topServo, 350);
msleep(1500);
}

void openClaw() {
set_servo_position(topServo, 1300);
msleep(1500);
}

void startArm() {
enable_servos();
set_servo_position(hingeServo, 1800);
set_servo_position(topServo, 1300);
}

void upArm() {
set_servo_position(hingeServo, 1300);

}

void calibration() {
resetMotors();
Expand Down Expand Up @@ -137,21 +216,21 @@ void xDecrease(int distance) {
msleep(300);
}

void rotateLeft() {
motor(frontLeftWheel, -100);
motor(backRightWheel, 100);
void rotateLeft(int time) {
motor(frontLeftWheel, 0);
motor(backRightWheel, 0);
motor(frontRightWheel, 100);
motor(backLeftWheel, -100);
msleep(1000);
msleep(time);
ao();
}

void rotateRight() {
motor(frontLeftWheel, 100);
motor(backRightWheel, -100);
void rotateRight(int time) {
motor(frontLeftWheel, 0);
motor(backRightWheel, 0);
motor(frontRightWheel, -100);
motor(backLeftWheel, 100);
msleep(1000);
msleep(time);
ao();
}

Expand Down