ProposalBot/Spring/2020

Proposal Bot and Processing

Author/s: Haydon Chiu

Table of Contents

V2 Code

Due to the COVID-19 conditions, it was necessary to find other ways that would allow for our group to not physically meet up in order to accomplish what we can of the ProposalBot project. To do so, the ProposalBot team thought that it would be best to create a simulation of the end goal of our project using Processing.

What is processing and how was it implemented in our project?

Processing can be seen as a flexible software sketchbook and a coding language used for aspects relating to the visual arts. The usage of Processing has varied widely in both the technological world and the artist spectrum. It, however, was utilized as an alternative for our class project and will be used as a simulation for our end project since it is deemed unsafe to work on our project physically.

Thought process of using Processing.

ProposalBot was originally imagined to move Omni-directionally. This would allow us to have a pen plotter on the bot and have it “plot” and draw the words “Marry me”. To imitate this, the code that was intended for use on the bot was translated into Processing code. Meaning the code written in Processing should simulate what the physical ProposalBot was expected to do. The code for the physical bot is shown below.

#include

#include

//SoftwareSerial Bluetooth(A8, 38); // Arduino(RX, TX) - HC-05 Bluetooth (TX, RX)

// Define the stepper motors and the pins the will use

AccelStepper LeftBackWheel(1, 42, 43); // (Type:driver, STEP, DIR) - Stepper1

AccelStepper LeftFrontWheel(1, 40, 41); // Stepper2

AccelStepper RightBackWheel(1, 44, 45); // Stepper3

AccelStepper RightFrontWheel(1, 46, 47); // Stepper4

int wheelSpeed = 1500;

void setup() {

// Set initial seed values for the steppers

LeftFrontWheel.setMaxSpeed(3000);

LeftBackWheel.setMaxSpeed(3000);

RightFrontWheel.setMaxSpeed(3000);

RightBackWheel.setMaxSpeed(3000);

delay(20);

// pinMode(led, OUTPUT);

m();

}

void loop() {

// put your main code here, to run repeatedly:

}

void moveForward() {

LeftFrontWheel.setSpeed(wheelSpeed);

LeftBackWheel.setSpeed(wheelSpeed);

RightFrontWheel.setSpeed(wheelSpeed);

RightBackWheel.setSpeed(wheelSpeed);

}

void moveBackward() {

LeftFrontWheel.setSpeed(-wheelSpeed);

LeftBackWheel.setSpeed(-wheelSpeed);

RightFrontWheel.setSpeed(-wheelSpeed);

RightBackWheel.setSpeed(-wheelSpeed);

}

void moveSidewaysRight() {

LeftFrontWheel.setSpeed(wheelSpeed);

LeftBackWheel.setSpeed(-wheelSpeed);

RightFrontWheel.setSpeed(-wheelSpeed);

RightBackWheel.setSpeed(wheelSpeed);

}

void moveSidewaysLeft() {

LeftFrontWheel.setSpeed(-wheelSpeed);

LeftBackWheel.setSpeed(wheelSpeed);

RightFrontWheel.setSpeed(wheelSpeed);

RightBackWheel.setSpeed(-wheelSpeed);

}

void rotateLeft() {

LeftFrontWheel.setSpeed(-wheelSpeed);

LeftBackWheel.setSpeed(-wheelSpeed);

RightFrontWheel.setSpeed(wheelSpeed);

RightBackWheel.setSpeed(wheelSpeed);

}

void rotateRight() {

LeftFrontWheel.setSpeed(wheelSpeed);

LeftBackWheel.setSpeed(wheelSpeed);

RightFrontWheel.setSpeed(-wheelSpeed);

RightBackWheel.setSpeed(-wheelSpeed);

}

void moveRightForward() {

LeftFrontWheel.setSpeed(wheelSpeed);

LeftBackWheel.setSpeed(0);

RightFrontWheel.setSpeed(0);

RightBackWheel.setSpeed(wheelSpeed);

}

void moveRightBackward() {

LeftFrontWheel.setSpeed(0);

LeftBackWheel.setSpeed(-wheelSpeed);

RightFrontWheel.setSpeed(-wheelSpeed);

RightBackWheel.setSpeed(0);

}

void moveLeftForward() {

LeftFrontWheel.setSpeed(0);

LeftBackWheel.setSpeed(wheelSpeed);

RightFrontWheel.setSpeed(wheelSpeed);

RightBackWheel.setSpeed(0);

}

void moveLeftBackward() {

LeftFrontWheel.setSpeed(-wheelSpeed);

LeftBackWheel.setSpeed(0);

RightFrontWheel.setSpeed(0);

RightBackWheel.setSpeed(-wheelSpeed);

}

void stopMoving() {

LeftFrontWheel.setSpeed(0);

LeftBackWheel.setSpeed(0);

RightFrontWheel.setSpeed(0);

RightBackWheel.setSpeed(0);

}

void m(){

LeftFrontWheel.moveTo(300);

RightBackWheel.moveTo(300);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(150);

RightBackWheel.moveTo(150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

LeftBackWheel.moveTo(300);

RightFrontWheel.moveTo(300);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

}

void a(){

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(300);

RightBackWheel.moveTo(300);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(-50);

LeftBackWheel.moveTo(50);

RightFrontWheel.moveTo(50);

RightBackWheel.moveTo(-50);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(50);

LeftBackWheel.moveTo(-50);

RightFrontWheel.moveTo(-50);

RightBackWheel.moveTo(50);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

}

void r(){

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(300);

LeftBackWheel.moveTo(300);

RightFrontWheel.moveTo(300);

RightBackWheel.moveTo(300);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.setSpeed(-150);

RightBackWheel.setSpeed(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftBackWheel.moveTo(-100);

RightFrontWheel.moveTo(-100);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

}

void y(){

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(150);

LeftBackWheel.moveTo(150);

RightFrontWheel.moveTo(150);

RightBackWheel.moveTo(150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(150);

RightBackWheel.moveTo(150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(-150);

RightBackWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftBackWheel.moveTo(150);

RightFrontWheel.moveTo(150);

}

void e(){

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(150);

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

RightBackWheel.moveTo(150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(-150);

LeftBackWheel.moveTo(150);

RightFrontWheel.moveTo(150);

RightBackWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(100);

LeftBackWheel.moveTo(100);

RightFrontWheel.moveTo(100);

RightBackWheel.moveTo(100);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(150);

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

RightBackWheel.moveTo(150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(-150);

LeftBackWheel.moveTo(150);

RightFrontWheel.moveTo(150);

RightBackWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(100);

LeftBackWheel.moveTo(100);

RightFrontWheel.moveTo(100);

RightBackWheel.moveTo(100);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(150);

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

RightBackWheel.moveTo(150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(-150);

LeftBackWheel.moveTo(150);

RightFrontWheel.moveTo(150);

RightBackWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(100);

LeftBackWheel.moveTo(100);

RightFrontWheel.moveTo(100);

RightBackWheel.moveTo(100);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(150);

LeftBackWheel.moveTo(-150);

RightFrontWheel.moveTo(-150);

RightBackWheel.moveTo(150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

LeftFrontWheel.setCurrentPosition(0);

LeftBackWheel.setCurrentPosition(0);

RightFrontWheel.setCurrentPosition(0);

RightBackWheel.setCurrentPosition(0);

LeftFrontWheel.moveTo(-150);

LeftBackWheel.moveTo(150);

RightFrontWheel.moveTo(150);

RightBackWheel.moveTo(-150);

LeftFrontWheel.runSpeedToPosition();

LeftBackWheel.runSpeedToPosition();

RightFrontWheel.runSpeedToPosition();

RightBackWheel.runSpeedToPosition();

}

The code is decently long, but not to incredibly complex. Essentially, the ProposalBot was intended to go in angles so that it can easily put down the pen plotter and draw a line as it drove in a certain manner such as sideways or sideways forward or the right direction. To do so we use the moveTo() function, which would allow the bot to, in a sense, set coordinate points or a destination point (if it is the beginning it will default to 0). Next, in order to start the movement of the bot, it would be necessary to use the runSpeedToPosition() function which would allow for movement on the designated wheels. Afterwards, in order to keep track of the position, the bot will use setCurrentPosition() to set the position of the servos to 0. It is necessary to do this just because keeping track of positions can be rather confusing. For example, if we moved the servos to 300 and then to -1000 it would be necessary to do calculations to figure out the whereabouts of the servo.

Shown below is the code for Processing:

float x = 0;
 float y = 500;
 int state = 0;
 int state_a = 0;

void setup() {

size(3000, 3000);
 background(102);
 //draw();
 }

void draw()
 {

//fill(0);

rect(x,y,20,20);
 //M();
 //A();
 //M
 if (state == 0){
 //background(102);
 x = x+1;
 y = y-1;
 //line(0,500,x,y);
 if (x > 100){
 x = 100;
 y = 400;
 state = 1;
 }
 }else if (state == 1){
 x = x+1;
 y = y+1;
 if (x > 150){
 x = 150;
 y = 450;
 state = 2;
 }
 }else if (state == 2){
 x = x+1;
 y = y-1;
 if (x > 200){
 x = 200;
 y = 400;
 state = 3;
 }
 }else if (state == 3){
 x = x+1;
 y = y+1;
 if (x > 300){
 x = 300;
 y = 500;
 state = 4;
 }//A
 }else if (state == 4){
 //fill(102);
 //background(102);
 x = x+1;
 //y = y-1;
 if (x > 350){
 x = 350;
 y = 500;
 state = 5;
 }
 }else if (state == 5){
 x = x+1;
 y = y-1;
 if (x >400){
 x = 400;
 y = 450;
 state = 6;
 }
 }else if (state == 6){
 x = x+1;
 if (x > 500){
 x = 500;
 y = 450;
 state = 7;
 }
 }else if (state == 7){
 x = x-1;
 if (x == 400){
 x = 400;
 y = 450;
 state = 8;
 }
 }else if (state == 8){
 x = x+1;
 y = y-1;
 if (x > 450){
 x = 450;
 y = 400;
 state = 9;
 }
 }else if (state == 9){
 x = x+1;
 y = y+1;
 if (x > 550){
 x = 550;
 y = 500;
 state = 10;
 }//R
 }else if (state == 10){
 //background(102);
 x = x+1;
 //y = y-1;
 if (x > 600){
 x = 600;
 y = 500;
 state = 11;
 }
 }else if (state == 11){
 y = y-1;
 if (y <350){ x = 600; y = 350; state = 12; } }else if (state == 12){ x = x+1; y = y+1; if (x > 650){
 x = 650;
 y = 400;
 state = 13;
 }
 }else if (state == 13){
 x = x-1;
 y = y+1;
 if (x < 600){ x = 600; y = 450; state = 14; } }else if (state == 14){ x = x+1; y = y+1; if (x > 650){
 x = 650;
 y = 500;
 state = 15;
 }
 }//R
 else if (state == 15){
 //background(102);
 x = x+1;
 //y = y-1;
 if (x > 700){
 x = 700;
 y = 500;
 state = 16;
 }
 }else if (state == 16){
 y = y-1;
 if (y <350){ x = 700; y = 350; state = 17; } }else if (state == 17){ x = x+1; y = y+1; if (x > 750){
 x = 750;
 y = 400;
 state = 18;
 }
 }else if (state == 18){
 x = x-1;
 y = y+1;
 if (x < 700){ x = 700; y = 450; state = 19; } }else if (state == 19){ x = x+1; y = y+1; if (x > 750){
 x = 750;
 y = 500;
 state = 20;
 }//Y
 }else if (state == 20){
 //background(102);
 x = x+1;
 if (x > 850){
 x = 850;
 y = 500;
 state = 21;
 }
 }else if (state == 21){
 y = y-1;
 if (y < 450){
 x = 850;
 y = 450;
 state = 22;
 }
 }else if (state == 22){
 x = x-1;
 y = y-1;
 if (x < 800){ x = 800; y = 400; state = 23; } }else if (state == 23){ x = x+1; y = y+1; if (x > 850){
 x = 850;
 y = 450;
 state = 24;
 }
 }else if (state == 24){
 x = x+1;
 y = y-1;
 if (x > 900){
 x = 900;
 y = 400;
 state = 25;
 }
 } else if (state == 25){
 //background(102);
 x = x+1;
 if (x > 1000){
 x = 1000;
 y = 400;
 state = 26;
 }
 }else if (state == 26){
 //background(102);
 y = y+1;
 if (y > 500){
 x = 1000;
 y = 500;
 state = 27;
 }//M
 } else if (state == 27){
 x = x+1;
 y = y-1;
 if (x > 1100){
 x = 1100;
 y = 400;
 state = 28;
 }
 }else if (state == 28){
 x = x+1;
 y = y+1;
 if (x > 1150){
 x = 1150;
 y = 450;
 state = 29;
 }
 }else if (state == 29){
 x = x+1;
 y = y-1;
 if (x > 1200){
 x = 1200;
 y = 400;
 state = 30;
 }
 }else if (state == 30){
 x = x+1;
 y = y+1;
 if (x > 1300){
 x = 1300;
 y = 500;
 state = 31;
 }
 }else if (state == 31){
 //background(102);
 x = x+1;
 if (x >1350){
 x = 1350;
 y = 500;
 state = 32;
 }
 }//E
 else if(state == 32){
 x = x+1;
 if (x > 1450){
 x = 1450;
 y = 500;
 state = 33;
 }
 }else if (state == 33){
 x = x-1;
 if (x < 1350){
 x = 1350;
 y = 500;
 state = 34;
 }
 }else if (state == 34){
 y = y-1;
 if (y < 450){ x = 1350; y = 450; state = 35; } }else if (state == 35){ x = x+1; if (x > 1450){
 x = 1450;
 y = 450;
 state = 36;
 }
 }else if (state == 36){
 x = x-1;
 if (x < 1350){
 x = 1350;
 y = 450;
 state = 37;
 }
 }else if (state == 37){
 y = y-1;
 if (y < 400){ x = 1350; y = 400; state = 38; } }else if (state == 38){ x = x+1; if (x > 1450){
 x = 1450;
 y = 400;
 state = 39;
 }
 }
 }

void M(){
 if (state == 0){
 x = x+1;
 y = y-1;
 if (x > 200){
 x = 200;
 y = 300;
 state = 1;
 }
 }else if (state == 1){
 x = x+1;
 y = y+1;
 if (x > 250){
 x = 250;
 y = 350;
 state = 2;
 }
 }else if (state == 2){
 x = x+1;
 y = y-1;
 if (x > 300){
 x = 300;
 y = 400;
 state = 3;
 }
 }else if (state == 3){
 x = x+1;
 y = y+1;
 if (x > 400){
 x = 400;
 y = 500;
 state = 4;
 }
 }else if (state == 4){
 x = x+1;
 y = y-1;
 if (x > 500){
 x = 500;
 y = 550;
 }
 }
 }

void A(){
 if (state_a == 0){
 x = x+1;
 y = y-1;
 if (x > 500){
 x = 500;
 y = 550;
 state_a = 1;
 }
 }else if (state_a == 1){
 x = x+1;
 if (x >525){
 x = 525;
 state_a = 2;
 }
 }
 }

While the code for processing is basically following the same structure of the code in Arduino for ProposalBot, it is actually quite different. To simulate the bot, I decided to use the rect() function. This function basically takes in the x,y coordinates and then the sizing of the box. I would then use some if then statements and once it reached a certain point (ex. first curve of R) then it would set the state to the next number and move forward.

Virtual ProposalBot in action

What next?

Ideally, it is our hope to be able to get an actual simulation, in which the Arduino code would run the Processing bot. However, to do so, it is necessary to fall back on the Engineering Method and find the proper resources or guidance in doing so.

References/Resources

  1. https://howtomechatronics.com/projects/arduino-mecanum-wheels-robot/
  2. https://processing.org/