Among the many dreams that I had in childhood, I remember that I always wanted to be able to implement a robot that "had its own life", that is, that could walk through the rooms of my house without having to push or move it with a remote control.
Since in my childhood I did not have the knowledge or the necessary savings to be able to assemble a robot of these characteristics, it is that now as an adult I embarked on carrying out this project together with my son Diego, who is currently 5 years old and shares with me the curiosity of wanting to know how things work :)
This is how the "Giorbo" project was born, which consists of a robot car that is capable of moving on the ground autonomously, looking around and avoiding the obstacles it encounters on its way.
This is how the "Giorbo" project was born, which consists of a robot car that is capable of moving on the ground autonomously, looking around and avoiding the obstacles it encounters on its way.
Here's a picture of what Giorbo looks like without its bodywork on:
One of the challenges of this project was being able to implement this robot using low-cost parts, since generally the educational robotics kits that exist today tend to be expensive (on average they exceed USD 100), and many of them must handle abroad.
Another of the challenges of this project was to be able to give our robot "intelligence", so that it could move using its wheels and make movement decisions when facing walls, chairs, and anything that was put in front of it.
Here you can see my son releasing Giorno on the terrace of our home:
Video 1: Giorbo in action
Carrying out this project with my son was an unforgettable experience, and I recommend doing this activity to parents, educators and anyone who wants to learn how to "create artificial life", or who simply wants to discover and apply knowledge of robotics, electronics and design, among other disciplines.
1) PARTS USED TO ASSEMBLE THE ROBOT
Nombre de Pieza | Chilean price $ | USD price |
1 Arduino UNO R3 Board
|
8.800
|
12.9
|
1 Tower Pro Sg90 Servo Motor
|
2.180
|
3.2
|
1 Ultrasonic Sensor HC-SR04
|
2.480
|
3.6
|
1 Battery holder 4 AA
|
330
|
0.5
|
1 Alkaline battery 9 volts Great Value
|
2.690
|
4
|
4 AA alkaline batteries 1.5 volts Great Value
|
980
|
1.4
|
2 Gearmotors from 3.5 to 6 volts with wheel
|
11.980
|
17.6
|
1 Integrated Circuit L293D Motor Driver
|
2.400
|
3.5
|
1 Swivel wheel 40 mm.
|
1.350
|
2
|
1 Pack 40 male-male cables for breadboard
|
2.650
|
3.9
|
1 Plug connector (2.1mm) for 9 volt battery
|
690
|
1
|
1 Breadboard of 170 points
|
1.880
|
2.8
|
1 Double contact tape
|
980
|
1.4
|
1 Duct tape
|
340
|
0.5
|
TOTAL: | 39.730 | 58.3 |
Table 1: list of robot car parts with reference price
The brain of the robot is made up of the legendary board Arduino UNO, which is one of the most currently used by the "Maker" and "DIY (Do-it-yourself) movements to make amateur electronic prototypes. In turn, the robot's head is made up of a model ultrasonic sensor HC-SR04, which acts as a "pair of eyes" and allows you to measure the distance with the closest object in front of it.Along with this, the head makes use of a model servo motor Sg90, which acts as a neck that allows the robot to turn its eyes to the left and right, thus giving it a total visibility range of 180 degrees.
Fig.3: Arduino board, servo motor and ultrasonic sensor
To mobilize the robot, a pair of geared motors is used, which correspond to small motors with gears inside. Each gearmotor must be connected to a tire with a rubber coating or other rough material, so that there can be friction between it and the surface of movement (that is, the ground), so that the robot can move forward, backward and turn. .
Fig.4: Two geared motors with their wheels
To give stability to the movement of the robot, a rotating wheel can be mounted (also known as "idle wheel") in the front part of the vehicle, which does not need to be connected to a motor, and will be used so that the robot can rotate freely in different directions.
Fig.5: Swivel wheel with base, bolts and nuts
To deliver energy to our robot, two power sources are used: a 9-volt alkaline battery that feeds the Arduino board and the ultrasonic sensor, and 4 AA 1.5-volt alkaline batteries in charge of delivering energy to drive the geared motors ( movement of the wheels) and the servo motor (movement of the "neck" of the robot). In order for the 4 batteries to deliver the voltage required by the motors (a range of 3.5 to 6 volts) they must be connected in series, so that the sum of their individual voltages allows them to reach 6 volts (that is, 4 batteries x 1.5 volts each = 6 volts). For this, a battery holder is used that allows the 4 AA type batteries to be firmly placed, and that also provides the output cables to be able to connect them.
Fig.6: 9 volt alkaline battery, battery holder and 4 AA alkaline batteries
In order for the 9-volt battery to be connected to the Arduino board, a plug-type connector can be used, which is cylinder-shaped at one end (to plug it into the board), and on the other it has a connector to connect it to the back of the board. top of the stack.
Fig.7: Plug type connector for 9 volt battery
In order to integrate all the devices that we have mentioned, we need to build the "nervous system" of our robot, so so that it allows us to orchestrate the signals that are being received from the environment (eg: there is an object ahead that is close) and allows us to make decisions to move the wheels of the car, in order to avoid obstacles and move freely. To do this, we will use a breadboard that allows us to make the appropriate connections between the pieces, using for this, a handful of male-male type cables (that is, they have a protruding tip at both ends).
Fig.8: Mini breadboard with 170 contacts, and pack of male-male cables
Unlike the vehicles that people use daily to get around, our robot only has three wheels (two rear and one front), so we cannot rotate to the left or right based on the movement of the wheels. front (we only have one, and it rotates freely without being connected to anything). To make up for the deficit of the front wheels we will use a technique known as "differential traction", which allows a vehicle to move and rotate using only two wheels based on the independent movement of each of them forwards and backwards.
To achieve this effect, we need to be able to control the direction of rotation of the geared motors, which can be achieved by reversing the polarity of the current that we apply to them. Although this can be done by manually changing the order of the cables that we connect from the batteries to each motor, the idea is that the robot can move autonomously, without external intervention. To do this, we need an electronic part called L293D, which corresponds to an integrated circuit that implements a "H-bridge" and allows to control up to two motors to make them turn in the direction you want.
Fig.9: Integrated circuit L293D with 16 pins
Along with this, our robot must have a chasis or skeleton that allows it to hold and give rigidity to all the parts that make up the vehicle. For this, it is important that this component has enough space to be able to locate all the contemplated parts, either above or below it. Also, it is required that it be made of some material that allows it to resist the weight of the pieces that are placed on top of it, and that it be as light as possible, so as not to make the complete structure of the vehicle heavier. In the case of our robot, we built the chassis using a plastic lid from an ice cream box, but we could have used acrylic, aluminum, wood or another material.
Fig.10: 800ml ice cream box lid
To be able to join different parts of the robot without having to drill and screw them, you can use a double-sided tape, which has glue on both sides and is easy to handle (it can be cut with scissors and peeled off with your hands). And of course, in order to cover the electrical cables that are exposed to the air, and also to "tie" some parts of our robot, we can use the practical and inevitable insulating tape :)
Fig.11: Double contact tape and insulating tape
2) ASSEMBLY OF THE ROBOT PARTS
Initially, the two gearmotors must be connected to their respective wheels, checking that the joint between them is firm and does not slip (if not, the wheel will not have the strength to move the robot). To validate that the assembly has been correct, the battery holder (with the 4 batteries inserted) can be connected to each of the geared motors, in order to observe if their tires rotate correctly.
Fig.12: Wheel rotation test with assembled gearmotor
Generally, geared motors do not come with built-in cables to be able to connect them to the current, so two cables must be soldered to them at the top (where there are two circular-shaped perforated metal connectors). To do this, you must use a soldering iron with soldering paste, in order to solder a cable in each of the connectors (if you have not previously soldered, this is a very good time to learn how to do it :)
Fig.13: Cables soldered to the two connectors of a geared motor
Subsequently, a strip of double contact tape must be placed on one of the faces of each gearmotor, with the aim of being able to glue it later to our chassis (the second contact surface must not yet be detached).
Fig.14: Gearmotor with double-contact tape attached on one side
In order to create the robot's head, the first thing is to join the servo motor (the "neck") with the ultrasonic sensor (the "eyes"). For this, a simple alternative is to cut and paste two pieces of double contact tape on the propeller of the servo motor, in order to later glue the ultrasonic sensor on it.
Fig.15: Servo motor with double contact tape on its propeller
At the time of gluing the ultrasonic sensor, make sure that its cables are pointing upwards; otherwise they may collide with the servo motor or other parts.
Fig.16: Ultrasonic sensor stuck on the propeller of the servo motor
The next step is to make the necessary cable connections so that all the parts of the robot can communicate electrically. These connections must be made on the breadboard, and will allow the Arduino board to give the orders to control the servo motor, the ultrasonic sensor and the L293D integrated circuit, which in turn will regulate the rotation of the geared motors to make the vehicle move forward, backward or rotate.
To carry out this step it is very important that the batteries are not yet connected to the circuit that is being formed, since a short circuit can be caused by having incomplete connections (the batteries must be inserted completely only when all parts of the robot are assembled).
Fig.17: Visual representation of connections between components
Once the indicated connections have been made (if you deem it convenient, you can modify the location of the cables respecting the electrical circuit), your components should be interconnected more or less in this way:
Fig.18: Electrical connection circuit between the components
Subsequently, the preparation of the chassis must be carried out. For this, it is important to validate that the Arduino board, the breadboard, the servo motor (with the ultrasonic sensor attached) and the batteries can be placed on top of the chassis surface, trying to make their weight distribution as homogeneous as possible. in order to avoid making one side of the vehicle much heavier than the other. One possible layout is to place the servo motor in the middle of the front of the chassis, further back in the center the Arduino board and on top of it the breadboard. The battery holder can be placed on one side (eg, in the middle on the right side), and the 9 volt battery in the middle on the other side. To fix the components it is possible to use double contact tape and/or insulating tape.
Fig.19: Example of distribution of components on the chassis
Once the position where each component will go has been validated, a hole must be made in the area that will correspond to the front part of the chassis, in order to make two (or four holes if desired) to install the front swivel wheel. The ideal is to first make a mark in the position to be drilled, and then go through them with a screwdriver or other equivalent tool. Having done this, the screws must be passed through the holes that the rotating wheel has through the chassis, and then secure them with nuts at the other end. Afterwards, the two gearmotors must be glued to the left and right side of the chassis, using the double contact tape that each one has.
Fig.20: Installation of rotating wheel and gearmotors in the lower part of the chassis
Once all the necessary components have been installed, the robot car should look similar to this:
Fig.21: Front view of the robot car
Fig.22: Diagonal view of the robot car
Fig.23: Rear view of the robot car
Optionally, it is possible to add a body to the robot to hide and protect all the robot circuitry, so it is up to your creativity to choose the materials and make a design to your liking to implement this part. :)
3) CODING THE INTELLIGENCE OF THE ROBOT
For the robot car to have artificial intelligence it first needs to design the logic of the behavior that it will have , so that it can make decisions autonomously, without human intervention. Here you can see a possible algorithm, modeled as a flowchart:
Fig.24: Flowchart describing the behavior of the robot
Having defined the behavior, the programming of the robot must be carried out. To do this, it is necessary to use a computer that has the "Arduino IDE" tool installed, which works on Windows, Linux or Mac operating systems. It can be downloaded from here: https://www.arduino.cc/en/Main/Software
Once this tool is installed, the source code of our robot must be edited in it, which will contain the instructions required to control the sensors, motors and other components. The program used for the Giorbo auto-robot can be found in the following repository on the GitHub site (use the file "roboCar.ino"): https://github.com/mmadaria/arduino-robot-car
This source code makes use of two helper libraries: "Servo.h" and "NewPing.h". The first is used to control the servo motor, and is included as part of the Arduino IDE standard library. The second one is used to control the ultrasonic sensor, and must be downloaded and installed manually from the following website ("NewPing_v1.7.zip" file): https://bitbucket.org/teckel12/arduino-new-ping/downloads .If you want to learn how to install libraries you can see the following guide: https://www.arduino.cc/en/Guide/Libraries
If you want to configure the behavior parameters of the auto robot to your liking, you can modify the values of the parameters that are defined at the beginning of the file and whose lines begin with the text "#define". For example, the line that says "#define MIN_OBSTACLE_DISTANCE_THRESOLD 28" indicates that the minimum distance in which the robot must stop to avoid colliding with an object is 28cms. Note that in the source code you can find the description of each of these parameters, so that you can understand what they are for.
This source code makes use of two helper libraries: "Servo.h" and "NewPing.h". The first is used to control the servo motor, and is included as part of the Arduino IDE standard library. The second one is used to control the ultrasonic sensor, and must be downloaded and installed manually from the following website ("NewPing_v1.7.zip" file): https://bitbucket.org/teckel12/arduino-new-ping/downloads .If you want to learn how to install libraries you can see the following guide: https://www.arduino.cc/en/Guide/Libraries
If you want to configure the behavior parameters of the auto robot to your liking, you can modify the values of the parameters that are defined at the beginning of the file and whose lines begin with the text "#define". For example, the line that says "#define MIN_OBSTACLE_DISTANCE_THRESOLD 28" indicates that the minimum distance in which the robot must stop to avoid colliding with an object is 28cms. Note that in the source code you can find the description of each of these parameters, so that you can understand what they are for.
Once you have the source code and libraries ready in the IDE, you must connect a cable to the Arduino board USB type B male (on the back), and the other end of the cable must be plugged into the computer. Once this is done, you must press the "Upload" button in the IDE, which will allow compile and upload the program to the robot's Arduino board.
Fig.25: Arduino IDE compiling the program for the Arduino UNO board
Once the program is loaded on the board, you must unplug the USB cable from the robot. It should be noted that the program is not deleted from the board when it is without power, since it is stored in an internal memory called Flash Memory, which is non-volatile.
To make the robot run the program that we uploaded, the 9 volt battery must be plugged into the back of the Arduino board, specifically into the plug-type connector. Once this is done, the robot will start executing the program and start spinning its tires to move forward, so you can put it on the ground to make it move. To turn off the robot, all you have to do is disconnect the cable from the board.
If you wish, you can add an on/off switch (two positions) to the robot to turn it on and off. To do this, an alternative is to connect the switch to the cables of the 9 volt battery, in order to allow or block the flow of current from that battery to the Arduino board.
Well, I hope you liked this tutorial as much as I liked writing it, and if you have any questions or comments you can write to me at "mmadaria@gmail.com".
To make the robot run the program that we uploaded, the 9 volt battery must be plugged into the back of the Arduino board, specifically into the plug-type connector. Once this is done, the robot will start executing the program and start spinning its tires to move forward, so you can put it on the ground to make it move. To turn off the robot, all you have to do is disconnect the cable from the board.
Video 2: Robot car finished and moving
If you wish, you can add an on/off switch (two positions) to the robot to turn it on and off. To do this, an alternative is to connect the switch to the cables of the 9 volt battery, in order to allow or block the flow of current from that battery to the Arduino board.
Fig.26: two-position switch
Well, I hope you liked this tutorial as much as I liked writing it, and if you have any questions or comments you can write to me at "mmadaria@gmail.com".