This is a beginner guide of Ikedo Mini Sumo Robot Starter Kit that jointly developed by Cytron Technologies and Team Ikedo Kogeki.
After the post Building a Sumo Robot, we received many messages from the teachers and parents telling us their problem in following our tutorial. Although we tried very hard to explain every single step in details but they are still very challenging for them who do not have any skills in soldering and wiring to follow. The 3D printing steps also one of the obstacles that stop them from moving forward.
Hence we collaborate with Team Ikedo who has tonne of experience in Sumo Robot competition to develop a kid's friendly Sumo Robot construction kit with the intention to bring down the barrier for beginners to get started.
This is a construction kit where you have to assemble the robot by yourself. But don't worry, we will guide you step by step in this post.
Step 1: Insert the opponent sensors into the 3 front slots.
When you insert the opponent sensors, they will be a little bit tight to slot it. You need to push the sensor with some strength to get through.
For the middle sensor, you need to push it to the front until it reaches the stopper.
However, for both right and left sensors, they need to be pushed to the back until they reach the back's stopper.
Step 2: Get ready the wire with a black connector at both ends.
Step 3: Bend the wire into half, cut it into half so that we can get 2 wires with the same length.
Step 4: Separate the wires so that easier for you to work on it in the following steps.
Step 5: Strip the wire isolator (about 5mm) using a proper wire stripper or a pair of scissors.
This is the end result we want. Repeat for another wire.
Step 6: Connect the wire to the edge sensor. Make sure you are connecting them at the correct side. Gnd --> black, VCC --> red, Out --> white
Step 7: Install the edge sensors at the underneath of the robot base using the black color self-tapping screw.
Step 8: The following steps will be more tricky for the first time user. We want to align and connect the 3 sets of male-header of the opponent sensors to the 3 sets of female-header on the main controller as shown in the images below.
And at the same time, bring up the 2 wires of the edge sensors from the bottom. They need to connect to the small green connectors afterward.
It is easier to align from the back of the robot. We need to ensure all 3 sets of connectors are connected. You may need to take some time to complete this step. But don't worry, just take your time until you get it.
This is what we want to achieve.
Step 9: Tighten the board in place with 4 black self-tapping screws.
Step 10: Get ready the motor bracket, bolts and nuts. Insert the nuts into the designated hexagon holes on the bracket.
Step 11: Fasten the bolts from the bottom but don't tighten them. Just ensure the bolts are engaged with the nuts. We will only tighten them when the motor comes in later.
Please ensure that you secure the motor bracket at the correct orientation. The flat side on the edge of the base.
Step 12: Slide in the motor through the motor bracket. Push in from the wheel side.
Step 13: Push in the motor until the black casing of the motor exceeded the motor bracket as shown in the image below. You can tighten the motor bracket now once the motor position is aligned.
Step 14: Repeat the same thing for another side.
Step 15: Connect the power (the wire with red connector) to the power port (the bigger size green color terminal block).
Make sure the polarity is correct. VB+ --> red, VB- --> black.
Try to pull the cable after you tightened to ensure it is securely tightened.
Step 16: Slot the connector into the battery compartment.
Step 17: Connect the battery to the power cable. Make sure the polarity is correct.
Step 18: Power on the board by turning on the power switch. You should hear a melody and the power LED will be on. If it no power, please check the polarity on the power cable and the battery before we proceed to the next step.
Step 19: We need to keep the battery inside the small compartment before we put on the bottom cover.
You need to ensure the battery charging port is hanging out when you insert the battery from the underneath. This is to ensure we can charge the battery without removing the bottom cover.
Step 20: Install the bottom cover with the 2pcs of black self-tapping screws provided.
Step 21: Connect the motor's wires to the black connector. Typically the red wire to MRA (on the left) and black wire to MRB (on the right).
Step 22: Power on the board, press the right button of the right motor. The motor should spin counterclockwise.
When you press the left button, the motor should spin clockwise.
If your motor is not spinning in the correct direction as mentioned, you need to swap the black and red wire so that you can achieve the same motor rotation.
Step 23: Repeat step 21 & 22 for the left motor.
Step 24: Now we will connect the edge sensor wire to the green terminal block. By default, all the terminal is already tightened up. Please loosen it before inserting the wire.
Step 25: Then we can Connect the edge sensor wire to the green color terminal block. (the first one from the right).
Please make sure the polarity is correct. - --> black, + --> red, S --> white
Step 26: Repeat step 24 for the other side and you are almost done!
Step 27: Before we proceed to the software part, it is good to know how to charge the battery at this stage.
You need to get a proper LiPo balance charger. It is not included in the package. If you do not have one, you can get it here.
Step 28: We need to connect the battery charging port to the 2-cells ports at the charger.
The LED for 1S and 2S will turn red when it is charging, turn green when the battery is fully charged. If the LEDs are blinking means the battery is spoil and needs to be replaced.
Caution: You need to charge the battery regularly to avoid battery over drained which may spoil the battery.
In this part, we are going to show you how to install Arduino IDE (a software to write your coding) and the USB driver. You can skip it if you already have Arduino IDE installed on your PC.
Step 1: Log on to https://www.arduino.cc/en/main/software.
Step 2: Choose your OS to proceed.
Step 3: Arduino IDE is an open source software that allows you to download and use it for free.
However, you are encouraged to make a monetary contribution to help them to continue to fund their development. Anyway, you are free to click “JUST DOWNLOAD”.
Step 4: Double click on the downloaded file to proceed.
Step 5: Once installation is completed, the Arduino’s icon will appear. Double click the icon to launch the Arduino IDE.
Step 6: Next, we are going to install the USB driver for the robot controller.
First of all, please connect your robot to your PC with a micro USB cable. (The micro USB cable is not included in the package)
Step7A:For Windows users:
1. Download the driver here: https://cdn.cytron.io/makeruno/CH341SER.EXE
2. Double click the “CH341SER” file to begin the installation
3. Click “INSTALL”.
4. Click "OK".
5. Go to window search, search for “device manager”.
6. Expand the “Ports (COM & LPT)”. Check which port the CH340 driver is being assigned to. Remember the com number. (For this example, the com number is com 5)
7. Launch Arduino IDE. Select the right com port. Tools >Ports >COM X (select the COM port that we checked at the previous step)
Note: Please ensure the robot is connected to your PC.
Step7B:For Mac users:
1. Download the driver here: https://cdn.cytron.io/makeruno/CH341SER_MAC.ZIP
2. Double click the zip file, open the unzip folder then double click the pkg file.
3. Click “Continue” to begin the installation.
4. Once done, click “Restart” to restart your Mac.
5. After you have restarted your Mac, launch Arduino IDE. Choose the driver at Tools > Port > /dev/cu.wchusbserial1410
Note: Please ensure the robot is connected to your PC.
Congratulation! You have successfully setting up the USB driver. You may start writing your first program to your robot now.
Basic Robot NavigationBefore we can program our robot to fight, there are a few basic robot navigations that we need to familiar with at this stage.
1. Moving Forward And Backward
Step 1: First of all, launch the Arduino IDE that you have just installed. Copy & paste this code into your Arduino IDE.
#include "CytronMakerSumo.h"
void setup() {
MakerSumo.begin();
}
void loop() {
MakerSumo.setMotorSpeed(MOTOR_L, 50); // Left motor forward at speed 50.
MakerSumo.setMotorSpeed(MOTOR_R, 50); // Right motor forward at speed 50.
delay(3000); // Delay for 3 seconds.
MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).
MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, -50); // Left motor backward at speed 50.
MakerSumo.setMotorSpeed(MOTOR_R, -50); // Right motor backward at speed 50.
delay(3000); // Delay for 3 seconds.
MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).
MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.
}
Step 2: To include Cytron Maker Sumo Library. Go to Tools > Manage Libraries...
Step 3: Search for "maker sumo", then click 'Install".
Step 4: Before we upload the program to your robot, it is a good practice to save all our program files. Go to File > Save As
Step 5: Create a new folder called "Sumo Robot". (you are free to decide where to save the folder)
Step 6: Name the program you want to save as "Basic Navigation".
So you have saved your first program as "Basic Navigation" under the folder of "Sumo Robot". When you create your next program later, you can name it anything you want but save it under the same Sumo Robot folder.
Step 7: Now, you can upload the program to your robot. Click the "upload" button located at the top bar of the Arduino IDE.
Make sure you have connected the USB cable on the PC and your board. You will see "Done uploading" appear at the bottom when it is done.
Step 8: Unplug the USB cable from your robot. Then turn on the power, your robot should be moving forward for 3 seconds before it stops for 1 second then it will move backward for 3 seconds. And it will keep repeating if you don't turn it off.
Step 9: Try to change the speed of your motor to 150 and reduce the delay to 1000. Then upload it to your robot again.
#include "CytronMakerSumo.h"
void setup() {
MakerSumo.begin();
}
void loop() {
MakerSumo.setMotorSpeed(MOTOR_L, 150); // Left motor forward at speed 150.
MakerSumo.setMotorSpeed(MOTOR_R, 150); // Right motor forward at speed 150.
delay(1000); // Delay for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).
MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, -150); // Left motor backward at speed 150.
MakerSumo.setMotorSpeed(MOTOR_R, -150); // Right motor backward at speed 150.
delay(1000); // Delay for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0); // Left motor forward at speed 0 (stop).
MakerSumo.setMotorSpeed(MOTOR_R, 0); // Right motor forward at speed 0 (stop).
delay(1000); // Delay for 1 second.
}
Step 10: Unplug the USB cable and turn on your robot.
You may notice now that your robot isn't running forward/ backward in a straight line. Don't worry, it is completely normal that your robot is not moving straight or behaves differently from mine or from your friends because every robot is unique just like you and me.
We will discuss this issue later but we want to bring your attention to these 2 parameters: speed and delay. From the 2 programs we made earlier, you should realize that in order to change the robot speed, you can change the second value inside function:
MakerSumo.setMotorSpeed(MOTOR_L, 150);
Where 0 is stop, 255 is maximum speed and negative value is reverse.
To control how long you want a certain command to execute, you can change the value in function:
delay(1000);
The delay is in millisecond. 1000 millisecond = 1 second.
Why doesn'tmy robot moves straight?
There are several reasons led to this problem:
1. The floor or the map is not flat. This will cause one of the wheels not touching the ground and spinning.
2. The mounting of the motors is not straight or not aligned. You can realign the motors by loosening the motor bracket.
3. The weight distribution of the robot does not balance mainly caused by the battery. So you can consider to stick the battery at the center position or add some weight on the motor which the wheel is spinning.
4. The internal resistance of the motor is not consistent so even if you apply the same speed to 2 different motors, they won't be running at the same speed. To solve this problem, you can slightly adjust the speed in your program for an individual motor. E.g.: If your robot always runs toward the right side, you can either reduce the speed of the left motor or increase the speed of the right motor until they are running straight.
MakerSumo.setMotorSpeed(MOTOR_L, 130);
MakerSumo.setMotorSpeed(MOTOR_R, 150);
or
MakerSumo.setMotorSpeed(MOTOR_L, 150);
MakerSumo.setMotorSpeed(MOTOR_R, 180);
2. To Make A Turn
Step 1: Copy and paste the code below to your Arduino IDE, then upload it to your robot.
#include "CytronMakerSumo.h"
void setup() {
MakerSumo.begin();
}
void loop() {
// Turn left for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 50);
delay(1000);
// Stop for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(1000);
// Turn back to original position.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, -50);
delay(1000);
// Stop for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(1000);
// Turn right for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 50);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(1000);
// Stop for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(1000);
// Turn back to original position.
MakerSumo.setMotorSpeed(MOTOR_L, -50);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(1000);
// Stop for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(1000);
}
Step 2: Unplug the cable and turn on your robot.
There are so many turning patterns that you can use. If you want to explore more, please follow this post: Building a Low-cost Line Following Robot.
3. To Read TheEdgeSensors
Step 1: Go to Arduino IDE. Open an example from File > Examples > Cytron Maker Sumo Library > TestInputs.
Step 2: Upload the sample program to your robot.
Step 3: Once done uploading, click serial monitor's icon located at the right corner of the top bar.
Step 4: You will see a new window pop up. Change the baud rate to 115200.
Step 4: Then you suppose to see a set of readable data from the serial monitor's window. Observe the reading for EDGE_L and EDGE_R. (for my case it is 449 and 316. Your's might be different)
Step 5: Place the robot's edge sensors on top of the white surface and black surface. Read and record the reading for EDGE_L and EDGE_R. For my case, the reading for white surface is 449 and 316; while the reading for the black surface is 992 and 961.
With these values, we are able to set the threshold for our edge sensors at around 720 and 638. Take the median value for the white and black surface.
So the left edge sensor will recognize a surface as white color when the value is lesser than 720 and vice versa.
Step 6: Copy & paste the codes below to Arduino IDE then upload it to your robot. You need to fill up your own threshold value for EDGE_L and EDGE_R.
#include "CytronMakerSumo.h"
void setup() {
MakerSumo.begin();
}
void loop() {
// If both left and right edge sensors are on black surface...
if ( (analogRead(EDGE_L) > 720) && (analogRead(EDGE_R) > 638) ) {
// Move forward.
MakerSumo.setMotorSpeed(MOTOR_L, 50);
MakerSumo.setMotorSpeed(MOTOR_R, 50);
}
// If either one of the edge sensors is on white surface...
else {
// Stop for 0.5 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(500);
// Move backward for 2 seconds.
MakerSumo.setMotorSpeed(MOTOR_L, -50);
MakerSumo.setMotorSpeed(MOTOR_R, -50);
delay(2000);
// Stop for 1 second.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(1000);
}
}
Step 7: Test to run your robot on a black surface with a white line in the middle. (the actual sumo robot ring is black in color and white line at the edge)
Now you know how to read the signals from the edge sensors
4. To Read the Opponent Sensors
Step 1: Copy & paste the codes below to Arduino IDE then upload it to your robot.
#include "CytronMakerSumo.h"
void setup() {
MakerSumo.begin();
}
void loop() {
// If object is detected by all 3 opponent sensors...
if ( (digitalRead(OPP_FL) == LOW) &&
(digitalRead(OPP_FC) == LOW) &&
(digitalRead(OPP_FR) == LOW) ) {
// Move forward at high speed.
MakerSumo.setMotorSpeed(MOTOR_L, 80);
MakerSumo.setMotorSpeed(MOTOR_R, 80);
}
// If object is not detected...
else {
// Move forward at low speed.
MakerSumo.setMotorSpeed(MOTOR_L, 30);
MakerSumo.setMotorSpeed(MOTOR_R, 30);
}
}
Step 2: Test run your robot by placing an object in front of the robot. Observe how the robot response to the object.
Note:
1. The Maker Mini Sumo controller comes with an on-board LED indicator for each opponent sensor. When a sensor detects an object, the LED will light up.
2. The default sensing range for the opponent sensor is around 25cm. If you need to increase the sensing distance, you can adjust the potentiometer through the tiny hole on the object sensor.
Congratulations and well done that you're following us until this stage! In the last part, we will be discussing the game strategy and the sample program.
Game StrategiesThe program of a sumo robot basically can be divided into 4 parts:
- Start
- Search
- Attack
- Back Off
However, these programs cannot work independently and all parts must be combined together in the main program loop.
1. Start
Start routine is the first movement of the robot after the game start.
The strategy for start routine is highly depending on the local rules of the sumo robot competition. Some rules require that the robot only can start moving after 5 seconds, some are 1 second.
Some rules allow the robot to be placed anywhere on the ring in any direction. Some require the robot to facing sideway in a predefined "start zone".
So, please plan your strategy accordingly. You can even use different strategies from match to match so that your opponent could not pre-program a counter-attack.
In this example, we programmed the robot to go to one side and attack the opponent from side way once the game starts.
This is the sample code for Start:
void startRoutine() {
// Start delay.
delay(1000);
// Turn right around 45 degrees.
MakerSumo.setMotorSpeed(MOTOR_L, 50);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(500);
// Go straight.
MakerSumo.setMotorSpeed(MOTOR_L, 80);
MakerSumo.setMotorSpeed(MOTOR_R, 80);
delay(1500);
// Turn left until opponent is detected.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 50);
unsigned long startTimestamp = millis();
while (digitalRead(OPP_FC)) {
// Quit if opponent is not found after timeout.
if (millis() - startTimestamp > 1000) {
break;
}
}
}
2. Search
As its name suggests, searching is to look for the opponent. In case of the start routine failed to attack the opponent, the robot will go around the ring in circular motion to look for the opponent. Once the opponent robot is detected, this program will be terminated and the robot will get into attack mode.
Sample code for Search:
void search(int dir) {
// Move in circular motion.
if (dir == LEFT) {
MakerSumo.setMotorSpeed(MOTOR_L, 60);
MakerSumo.setMotorSpeed(MOTOR_R, 80);
} else {
MakerSumo.setMotorSpeed(MOTOR_L, 80);
MakerSumo.setMotorSpeed(MOTOR_R, 60);
}
}
3.Attack
The only way to win the game is to push the opponent robot out of the ring. Once the opponent robot is detected by any of the 3 opponent sensors, the robot will turn into that direction and launch an attack in full speed.
The accuracy of the attack depends on how good your robot can track the opponent robot while moving forward in full speed. If the opponent manages to escape, the program will resume in searching mode.
void attack() {
// Opponent in front center.
// Go straight in full speed.
if (digitalRead(OPP_FC) == LOW) {
MakerSumo.setMotorSpeed(MOTOR_L, 255);
MakerSumo.setMotorSpeed(MOTOR_R, 255);
}
// Opponent in front left.
// Turn left.
else if (digitalRead(OPP_FL) == LOW) {
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 255);
}
// Opponent in front right.
// Turn right.
else if (digitalRead(OPP_FR) == LOW) {
MakerSumo.setMotorSpeed(MOTOR_L, 255);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
}
}
4. Back Off
Whenever any of the edge sensors senses the white line, the robot needs to back off and make a U-Turn. While rotating, the robot will also try to search for the opponent. If the opponent is in its view, it will attack in that direction.
void backoff(int dir) {
// Reverse
MakerSumo.setMotorSpeed(MOTOR_L, -50);
MakerSumo.setMotorSpeed(MOTOR_R, -50);
delay(300);
// Rotate..
if (dir == LEFT) {
// Rotate left backward.
MakerSumo.setMotorSpeed(MOTOR_L, -50);
MakerSumo.setMotorSpeed(MOTOR_R, 50);
} else {
// Rotate right backward.
MakerSumo.setMotorSpeed(MOTOR_L, 50);
MakerSumo.setMotorSpeed(MOTOR_R, -50);
}
delay(600);
// Stop the motors.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
delay(50);
}
Let's FightingTo make your life easier, we've combined all the 4 programs into one and all the 4 programs (functions) is implemented as non-blocking function and will get called repeatedly from the main loop.
void loop() {
// Edge is detected on the left.
if (analogRead(EDGE_L) < EDGE_L_THRESHOLD) {
// Back off and make a U-Turn to the right.
backoff(RIGHT);
// Toggle the search direction.
searchDir ^= 1;
}
// Edge is detected on the right.
else if (analogRead(EDGE_R) < EDGE_R_THRESHOLD) {
// Back off and make a U-Turn to the left.
backoff(LEFT);
// Toggle the search direction.
searchDir ^= 1;
}
// Edge is not detected.
else {
// Keep searching if opponent is not detected.
if ( (digitalRead(OPP_FC) == HIGH) &&
(digitalRead(OPP_FL) == HIGH) &&
(digitalRead(OPP_FR) == HIGH) ) {
search(searchDir);
}
// Attack if opponent is in view.
else {
attack();
}
}
// Stop the robot if the button is pressed.
if (digitalRead(START) == 0) {
// Stop the motors.
MakerSumo.setMotorSpeed(MOTOR_L, 0);
MakerSumo.setMotorSpeed(MOTOR_R, 0);
// Loop forever here.
while (1);
}
}
You can open the full sample program from Arduino IDE. File > Examples > Cytron Maker Sumo Library > AutoSumo
Note: You need to press the Start button and the robot will start after 1s. To reset the program, you can press the Reset button instead of turning off and on again the power switch.
Let's watch the robot in action now!
Comments