ME 445 Final Project Report Sumo Battle Bot -...

14
ME 445 Final Project Report Sumo Battle Bot Chris Carrero Tyler Holp Lauren Williams Submitted: May 2, 2013

Transcript of ME 445 Final Project Report Sumo Battle Bot -...

Page 1: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

ME 445 Final Project Report Sumo Battle Bot

Chris Carrero Tyler Holp Lauren Williams

Submitted: May 2, 2013

Page 2: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 2

Table of Contents Project Overview ...................................................................................................................................... 3

Retrofitting and Customization ............................................................................................................. 4

Additional Sensors ............................................................................................................................... 5

Defensive and Offensive Design ..................................................................................................... 5

Coding .......................................................................................................................................................... 6

Results and Discussion ............................................................................................................................ 6

Conclusion .................................................................................................................................................. 7

Bibliography ............................................................................................................................................... 7

Appendicies ................................................................................................................................................ 8

Appendix A – Arduino Code ........................................................................................................... 8

Appendix B – Digital Sensor Data ............................................................................................. 13

Page 3: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 3

Project Overview

Our choice for the final project in ME 445, Microcomputer Interfacing, was to

retrofit a stock sumo-bot with the goal of winning a battle-bot competition against other

groups. As a novice group in the knowledge of electronics and mechatronics, we knew

this would be a challenging project to overcome.

The foundation for the project was Pololu’s Ardunio-controlled Zumo Robot

(Zumo), which was given to all three groups to retrofit and customize. Each group could

use servos, sensors, or any mechatronic design with the stipulation that it did not

permanently damage the Zumo.

Following testing and tweaking of each design, the groups battled off in a closed-

arena to see which design was victorious. The competition was set up so each will fight

the other bots individually for 3 minutes; with a championship match for 5 minutes. The

scoring of the competition for each of the matches was as follows: 3 points for flipping

the other robot over, 1 point if the other robot stands back up within 10 seconds, 1 point

for pushing the other robot into the wall, and -1 point for running into the wall.

Page 4: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 4

Retrofitting and Customization

As mentioned before the foundation for the project was Pololu’s Zumo. The

Zumo is a robot specifically designed to work in conjunction with the Arduino interfaces.

Engineering into the Zumo are many different tools such as accelerometers, buzzers, and

a compass that can be utilized for any design. The Zumo is equipped with four 2200 mAh

Nickel-metal hydride batteries that power the micro-gear motors, Arduino, and any other

electrical devices.

The Arduino we used for our project was the class standard Arduino UNO. As

can be seen in Figure 1, the Zumo is equipped with SIP Headers which matches with the

Uno sockets. This enables the Arduino to control the Zumo but also expand the terminals,

giving the possibility of more connections.

As part of the competition, each group was given a Pololu Infrared Beacon

Transceiver seen in Figure 2. This IR beacon allows each Zumo to locate one-another by

transmitting infrared light to and receiving infrared light from the other bot. Each beacon

is equipped with four IR receivers which are denoted

North, East, South, and West. When the sensor detects

the direction of the other Zumo it illuminates an LED

in the direction where it thinks it is. To ensure

uniformity, an agreed design requirement for all of the

groups was to mount this sensor 4 inches above the

Zumo. While this given sensors was very helpful to

our project, we decided to buy a few more sensors to

give our bot the competitive edge.

Figure 1 - Pololu Zumo Robot

Figure 2 - Pololu IR Beacon Transceiver

Page 5: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 5

Additional Sensors In considering the design of the Zumo we wanted to make sure it could effectively

overcome any task at hand. We knew that we had to have an offensive weapon to use

against the other robots yet we needed to ensure we did not run into walls. Since we were

on a budget of $100 dollars we looked into using sensors for multiple tasks. In order to

roughly locate an opponent or a wall on all four sides we used the Sharp GP2Y0A21

Analog Distance Sensor. Seen in Figure 3, this sensor has a range of 4 to 32 inches and

sends an output voltage related to the distance of an object in front of the sensor. These

sensors could easily detect a wall in the arena or an opponent depending on the coding

used in conjunction with it. With a sensor to detect an opponent we needed a way to tell

the Zumo to strike the opponent. For this task we chose another sensor, the Sharp

GP2Y0D805 Digital distance sensor pictured in Figure 4. This sensor has a range of 0.8

to 4 inches and outputs a digital voltage when it detects an object in front of it.

Defensive and Offensive Design

To ensure our Zumo survived the

competition we designed it with offensive and

defensive tactics in mind. Looking at Figure 5, we

mimicked the stock ramp seen on the front of the

Zumo at the rear as well. The tactic behind the

ramp was to decrease the time it would take for

the Zumo to attack an opponent coming from the

rear. Instead of coding the Zumo to make a 180

degree turn, we could simply program the robot to

reverse the motor direction and attack quickly. In

the event that we could not attack in time, we

manufactured a shield out of sheet metal to

protect the wires and equipment.

Furthermore we used the shield as a mount

and mounted the 7 sensors to the Arduino that

plugs into our Zumo. We accomplished this by

Figure 4- Sharp GP2Y0A21 Analog Distance Sensor Figure 3- Sharp GP2Y0D810 Digital Distance Sensor

Figure 5-Complete Zumo

Page 6: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 6

laser cutting a mounting block out of acrylic and mounting the shield to the block. Our

mounting block bolts to the Arduino through the two through holes on the Arduino. Our

shield then mounts to the mounting block through two tapped holes. We mounted the

tracking sensor on top of our shield, which is 4 inches tall. To mount the analog sensors

we bolted them right to the shield on the front, back, and both sides of the Zumo. We

then mounted the 2 Sharp digital distance sensors to the front and back of our bot.

Coding

Having the right tools to complete a job is one part, but being able to use those

tools effectively changes the industry. In deciding how to code our Zumo helped in the

overall design of the project. Below is the layout of the pin inputs and outputs we used

for the final design. The Zumo was coded using “while” loops that processed the analog

and digital input data from the sensors. Depending on the magnitude of the sensor

readings accompanied by the IR beacon, the Zumo would either turn to face an opponent

or turn to get away from a corner. The bot is coded such that it will turn towards the

other bot based on signals from the IR beacon first and then supplementary signals from

the Sharp analog sensors. The Sharp analog sensors will tell the bot to either turn its

front or back to the other Zumo and then moved towards it. Once the other Zumo is

within 4”, the code receives signal from the Sharp digital sensors, which tell our bot to

ram the competition using the front or back ramp.

Results and Discussion In the first match of our competition, we battled Group 3’s Zumo bot for 3 minutes. We

scored 2 points in the match by pushing their bot into the wall and they scored -2 points

for running into the wall on their own.

Sensor Pin

IR - North 12 IR - East 11 IR – South 6 IR – West 5 Analog – North A0 Analog – East A1 Analog - South A2 Analog – West A3 Digital – North 4 Digital – South 3 Right Motor Dir. 7 Left Motor Dir. 8 Right Motor PWM 9 Left Motor PWM 10

Page 7: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 7

In the second match of our competition, we battled Group 13’s Zumo bot. We won this

second match by a score of 6 to -2. Once again, we scored a number of points by pushing

the other team’s bot into the wall. We also sat back and let them run into the wall so they

would accumulate negative points.

In the championship match, we faced Group 3’s Zumo bot again. We lost the

championship match by a score of 3 to -1. We were unable to push their bot into the wall

because they were too heavy after some modifications that they made. If we had more

power, we would have been able to push them better and possible win the tournament.

We were able to battle effectively by coding our Zumo bot to remain patient and wait for

our opponent to come into our close range. Once the IR beacon and one of the Sharp

analog distance sensors both picked up the motion of the other bot, our Zumo bot turned

one of its ramps towards the other bot and pushed full speed forward. This technique was

effective because we were able to score our points by pushing the other bot into the wall.

Some improvements could be made to our Zumo bot to make it better for battle. After

our first match, we noticed that our Zumo bot was turning slowly to line its ramp up with

the other bot. To remedy this problem, we increased the turning speed of our Zumo bot

in our code. We also noticed that our bot would jump back and forth if the other bot was

in between two of our four Sharp analog sensors. We could have remedied this problem

by taking the average of the analog sensors and telling our bot to turn towards that

direction. Additionally, we noticed that our two Sharp digital sensors were pointed too

directly toward the ground right in front of the two ramps. After the first match, we

modified the angle of the digital sensors on the Zumo bot to increase the lateral detection

of the sensor. We found that the initial angle of the sensor was not registering the

competition as fast as we would have liked.

Conclusion For our final project, we were able to customize and retrofit a Pololu Zumo bot to

effectively win in battles against the other Zumo bots in our class. We added another

ramp to the back end of our bot, a protective shield, and 6 Sharp distance sensors (4

analog for long distance, 2 digital for short distances). We coded the bot to wait for its

opponent to approach before making its move. Our Zumo bot quickly turns if the sensors

on its side detect the other bot, and aligns itself so it is facing the opponent. If the sensors

on the front or back detect the other bot, our Zumo bot moves quickly straight ahead to

hopefully run the other bot into the wall. Although we did not win the competition, we

learned a created an effective Zumo bot and learned a lot about its mechatronics.

Bibliography The following data sheets can be found in Appendix B of this report.

Sharp analog sensor data sheet

Sharp digital sensor data sheet

Page 8: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 8

Appendicies

Appendix A – Arduino Code

#include <ZumoMotors.h>

ZumoMotors motors;

int compnorth = 12;

int compeast = 11;

int compsouth = 6;

int compwest = 5;

int engagefront = 4;

int engagerear = 3;

int time = 0;

int straightspeed = 300;

int turn = 250;

int hide = 2;

int cornerprox = 400;

int opponentprox = 350;

void setup() {

Serial.begin(9600);

pinMode(compnorth, INPUT);

pinMode(compeast, INPUT);

pinMode(compsouth, INPUT);

pinMode(compwest, INPUT);

pinMode(engagefront, INPUT);

pinMode(engagerear, INPUT);

}

void loop() {

int north = digitalRead(compnorth);

Serial.print("Compass North : ");

Serial.print(north);

int east = digitalRead(compeast);

Serial.print(" Compass East : ");

Serial.print(east);

int west = digitalRead(compwest);

Serial.print(" Compass West : ");

Serial.print(west);

int south = digitalRead(compsouth);

Serial.print(" Compass South : ");

Serial.print(south);

Page 9: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 9

int front = digitalRead(engagefront);

Serial.print(" Engage Front : ");

Serial.print(front);

int rear = digitalRead(engagerear);

Serial.print("Engage Rear : ");

Serial.print(rear);

int northsens = analogRead(A0);

Serial.print(" North Sensor : ");

Serial.print(northsens);

int eastsens = analogRead(A1);

Serial.print(" East Sensor : ");

Serial.print(eastsens);

int southsens = analogRead(A2);

Serial.print(" South Sensor : ");

Serial.print(southsens);

int westsens = analogRead(A3);

Serial.print(" West Sensor : ");

Serial.println(westsens);

while(north == 0 && northsens > opponentprox){

motors.setLeftSpeed(straightspeed);

motors.setRightSpeed(straightspeed);

Serial.println("IN FRONT");

int front = digitalRead(engagefront);

while(front == 0){

motors.setLeftSpeed(400);

motors.setRightSpeed(400);

front = digitalRead(engagefront);

Serial.println("ENGAGE");

}

north = digitalRead(compnorth);

northsens = analogRead(A0);

}

motors.setLeftSpeed(0);

motors.setRightSpeed(0);

while(south == 0 && southsens >opponentprox){

motors.setLeftSpeed(-straightspeed);

motors.setRightSpeed(-straightspeed);

Serial.println("IN REAR");

int rear = digitalRead(engagerear);

while(rear == 0){

motors.setLeftSpeed(-400);

motors.setRightSpeed(-400);

rear = digitalRead(engagerear);

Page 10: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 10

Serial.println("ENGAGE");

}

south = digitalRead(compsouth);

southsens = analogRead(A2);

}

motors.setLeftSpeed(0);

motors.setRightSpeed(0);

while(east == 0 && eastsens >opponentprox){

for (int speed = 0; speed <= 400; speed+=20){

motors.setRightSpeed(-speed);

motors.setLeftSpeed(speed);

Serial.println("TURN EAST");

delay(5);

}

for (int speed = 400; speed >= 0; speed-=20){

motors.setRightSpeed(-speed);

motors.setLeftSpeed(speed);

Serial.println("TURN EAST");

}

east = digitalRead(compeast);

eastsens = analogRead(A1);

}

while(west == 0 && westsens >opponentprox){

for (int speed = 0; speed <= 400; speed+=20){

motors.setRightSpeed(speed);

motors.setLeftSpeed(-speed);

Serial.println("TURN WEST");

delay(5);

}

for (int speed = 400; speed >= 0; speed-=20){

motors.setRightSpeed(speed);

motors.setLeftSpeed(-speed);

Serial.println("TURN WEST");

}

west = digitalRead(compwest);

westsens = analogRead(A3);

}

while(northsens>cornerprox && eastsens>cornerprox && north!=0 && east!=0){

digitalWrite(2, LOW);

for (int speed = 0; speed <= 400; speed+=20){

motors.setRightSpeed(speed);

motors.setLeftSpeed(-speed);

Page 11: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 11

Serial.println("CORNER AT NE");

delay(5);

}

for (int speed = 400; speed >= 0; speed-=20){

motors.setRightSpeed(speed);

motors.setLeftSpeed(-speed);

Serial.println("CORNER AT NE");

}

northsens = analogRead(A0);

eastsens = analogRead(A1);

north = digitalRead(compnorth);

east = digitalRead(compeast);

}

while(southsens>cornerprox && westsens>cornerprox && south!=0 && west!=0){

for (int speed = 0; speed <= 400; speed+=20){

motors.setRightSpeed(speed);

motors.setLeftSpeed(-speed);

Serial.println("CORNER AT SW");

delay(5);

}

for (int speed = 400; speed >= 0; speed-=20){

motors.setRightSpeed(speed);

motors.setLeftSpeed(-speed);

Serial.println("CORNER AT SW");

}

southsens = analogRead(A2);

westsens = analogRead(A3);

south = digitalRead(compsouth);

west = digitalRead(compwest);

}

while(northsens>cornerprox && westsens>cornerprox && north!=0 && west!=0){

for (int speed = 0; speed <= 400; speed+=20){

motors.setRightSpeed(-speed);

motors.setLeftSpeed(speed);

Serial.println("CORNER AT NW");

delay(5);

}

for (int speed = 400; speed >= 0; speed-=20){

motors.setRightSpeed(-speed);

motors.setLeftSpeed(speed);

Serial.println("CORNER AT NW");

}

northsens = analogRead(A0);

Page 12: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 12

westsens = analogRead(A3);

north = digitalRead(compnorth);

west = digitalRead(compwest);

}

while(southsens>cornerprox && eastsens>cornerprox && south!=0 && east!=0){

for (int speed = 0; speed <= 400; speed+=20){

motors.setRightSpeed(-speed);

motors.setLeftSpeed(speed);

Serial.println("CORNER AT SE");

delay(5);

}

for (int speed = 400; speed >= 0; speed-=20){

motors.setRightSpeed(-speed);

motors.setLeftSpeed(speed);

Serial.println("CORNER AT SE");

}

southsens = analogRead(A2);

eastsens = analogRead(A1);

south = digitalRead(compsouth);

east = digitalRead(compeast);

}

}

Page 13: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 13

Appendix B – Digital Sensor Data

Page 14: ME 445 Final Project Report Sumo Battle Bot - Weeblyccarrero.weebly.com/uploads/2/3/9/8/23984934/me445_final_report.pdf · ME 445 Final Project Report Sumo Battle Bot ... retrofit

Carrero, Holp, Williams

ME 445 - Final Project Report Page 14