Tip:
Highlight text to annotate it
X
Hi everybody, my name is Massimo Banzi, and I'm one of the co-founders of Arduino.
Welcome to the second video in a series of videos about the Arduino robot.
So in this video, David Cuartielles and Xun Yang are going to show you how to run the logo example on the robot,
how to calibrate the wheels to make sure the robot goes as straight as possible,
and how to use the remote control to control the robot itself.
I hope you will enjoy it, and take it away David!
Hello, this is David. This is Xun.
We're here today to continue on the video series about the Arduino robot.
Remember that the Arduino robot is an omni-directional platform,
which means it can move in any direction; forwards and backwards and turn,
by making the wheels turn in opposite directions at the same time.
Today we're going to see how to, first, calibrate the robot to make it go in a perfect straight line,
and second, make a program that will help you program movements in the robot directly
from the keyboard on it, and third, check how to control the robot from an infrared remote control.
Xun?
Yeah.
So, let's first have a look how to calibrate the robot.
One thing that's very important about the robot is that no two models are the same,
so even if you ask this robot to go forward at the same speed for left and right, it's very likely
that it won't be going in a straight line.
This is the point where we need to do the calibration, and fortunately we have a feature on the firmware
that allows you to calibrate the robot with this potentiometer on the motor board.
You just need to change the position of the potentiometer.
In order to check whether the wheel calibration is right or wrong,
we have created a software example for you, which is example number six, called "wheel calibration"
that will let you calibrate by hand the robot's wheels, so that they move straight over a line.
So, we will interact both with the *** here by following the instructions on the screen,
as well as using a screwdriver you have to interact with the trimmer down here.
But first, let's upload the software on the robot to start interacting with it.
Xun? Yeah.
I will open the example on Arduino's ID.
It's in the folder for the robot control, here, robot control, explore, example number six: wheel calibration.
This example is very simple.
Like all the other robot examples, it first calls the Arduino robot library,
and then it calls something called the "RobotTextManager" library;
it's because we're handling a lot of different strings in the code,
and in order to show them on the screen properly, we just store them in a stream in here,
and then, in set up, we start up the robot, start up the screen, and start reading the SD card
where we store all the different images for the instructions for the robot.
In the loop you see that we do only two things:
first, we check the speed of the robot, that's taken straight from the ***,
and then we write that information to the motors, so that we see whether the robot is moving straight or not,
then we take the calibration value from the trim control that is on the bottom board
and we finally write up the value on the robot screen.
In this way, you can take notice of this value and use it for future reference
when you want to recalibrate your robot in the future.
Okay, let's first find a small screwdriver that will be necessary for calibrating the robot,
and as we have talked about before that the USB cable actually disengages the motors,
so you have to unplug it first, otherwise the motors won't run.
Okay, now let's turn on the robot.
You can see the robot is running very fast.
You can adjust the speed by turning this potentiometer.
Let's get it to slow a bit.
Then, put it on a flat surface to see if it goes in a straight line.
And you can see that it's very uneven, turning to the right direction a lot.
And you can see the value on the screen showing 15, which is the value from the trim on the bottom,
which we can use to calibrate it.
Let's get it to -5.
And also speed it up a bit.
Looks much better.
But it's still turning around a little bit.
So this time let's turn the value back.
To, say, 2.
You can further calibrate it by using a ruler to make sure that it goes in a straight line.
But, now we're going to stop here.
We'll now continue with our next example, where we're going to see how to control the robot's movements
by programming them straight from the robot's keyboard.
For doing that we're going to use an example that's called "logo".
You might remember the logo programming language from back in the days,
some of you might not even know what logo is.
The idea behind logo consists in having a virtual turtle that is on your computer screen,
and you give commands to it, like "move forward, turn to the right, turn to the left,"
and that will make the virtual turtle move, and will leave a trace on the screen.
Well, we're going to implement a real-life version of the virtual turtle using the Arduino robot,
and we'll just tell it to move forward by pressing the button forward,
turn to the right or left or backwards, and then tell it to execute the list of commands
by pressing the central button, and it will just reproduce the movements we programmed.
We have that as an example in our ID, so we turn on our computer again, and get the cable.
We will continue programming our robot now,
we'll connect the cable to the robot, and then we just open the example called logo
using our examples, robot control, explore, logo. It's the first example for the Arduino robot's library.
Here you see in every example, first of all we call the Arduino robot library,
we use an array called commands where we'll be storing all the possible commands we'll put in the robot.
It has a maximum length of 20 commands I think, it's quite a lot of commands anyway.
Then, start the robot, start the screen, start the SD card, and let's take a look at what's in the loop,
in the loop is going to be calling this function called addCommands, you can take a look at it later,
but it's just going to be reading the commands from the keyboard and storing them in the array.
So, when you press the white button, you will be calling them one by one, executing them in a row.
So, I make sure I have the right board, in the robot control, and the right serial port.
And I upload the code to the robot.
Once the robot is programmed,
I completely remove the computer from the scene.
I'll pass it over to Xun, who will explain how the program works again.
So, this time let's turn on the robot again.
And this program asks you to press buttons for up, down, left, and right a few times
to record the movements you want it to do.
Let's first start with something simple, first go forward and then turn right,
and now, if you press the middle button it's going to start moving, so let's put it on the table first.
Start.
And now it's done.
I will now send it back to Xun.
So, I'm going to tell the robot to go forward, then turn one, two, three, for times, and run.
It's going to fall off the scene. Here you go. Xun, get ready to stop it.
We're going to learn now how to use infra-red control like this one.
This one is a universal remote control to control the robot from a distance.
There is an example that you can use for working with robots using a remote control.
You should know that not all remote controls work the same way,
there is one clear thing that remote controls use a chip like this one.
This is an infrared receiver like the one you can have on you TV, your stereo, or other things controlled by infrared in your home.
And this contains both an infrared receiver and an infrared amplifier, it makes it very very easy
to connect it to the five volts microchip, the one that commands the Arduino robot, and read data from it.
So in this case, we're going to use a remote control like this one, but not all remote controls work the same.
So, we recommend you explore the Arduino expansion kit for the robot,
that will come with both a sensor like this and a remote control that are compatible with
the software that comes with the robot. You could of course enhance the robot's software,
to make it work with other infrared controllers.
So, first thing, you will need to connect it, and Xun has prepared a cable to easily connect
the infrared sensor to the robot. So, Xun. Yeah.
So, let's first connect the infrared receiver to the cable.
It's just like a normal component,
so, this platform is very extendable.
Let's just connect it to the port D2 as the sketch says.
And it's good that we tape it in a good position
so it will not move around a bit, a lot.
Okay, let's now program the robot. As usual, you plug it into the computer,
and we just look for the right example on the ID. In this case, as I said, it's the one called remote control
example number 8. You see that first it says that this example is experimental,
it's just because you might need to use a different remote control,
that's why we talk about using a universal remote control because you can program it
to operate in different ways and it will definitely work with the sensor.
So, once you've opened the example, you will see that first we are working with
a contribution by Ken Sirriff, who contributed to the Arduino code base by adding
an infrared remote control library. Xun worked trimming it down so it fits with the robot.
Then, we include the Arduino robot library and we define a series of infrared commands
this is how you read a command as a series of numbers. You see that they are slightly different
each one of them so they represent different commands on the remote control.
So we're going to be reading upwards, downwards, left, and right.
You will also see that there are a couple of places where you can change this code,
for example, "time out" is a variable that allows you to distinguish how often you are
continuing to press the button.
Then, after the classic initialisation calls like start the robot, start the TFT screen, start the SD card,
you will see that the loop is a very very small program, where we're essentially just checking whether
there's an IR remote control command received, and if it's received we'll process different commands.
The proccessResult() function is just deciding whether you're going to send the motor
forward, backward, turn left, or turn right.
This -1 and plus 1 you see here are just multiplied by the multiplication factor
so that the robot doesn't move too quick.
So this 128 setting up the speed of movement for the robot. If you want the robot to go faster,
you could change this to 255 and it will just go really really quick.
So, just program the robot with this code,
and check it out for real.
The robot's now programmed, and I pass it over to Xun who will show you how it works.
Now let's turn on the robot, and put it on a flat surface.
Now we can control it with the remote control.
So let's turn, and back, and let's go forward, and go back.
And you see the robot is moving as long as you press the button on the remote control
So, that's basically the idea. And we're quantifying the time in fourths of a second.
So each time variable in the code will make the movements last in multiple factors of 1/4 second.
It's time to go for today, but before we hand over to Massimo,
we should probably cover what we did today. Xun? Yeah.
So, in today's video, we showed you how to calibrate the robot wheels, how to run the logo example,
and how to control it with a remote control.
Okay, that's all from Sweden. Adjö!!
Okay! Thank you David, that was great.
So I hope you enjoyed the video, and please join us in the next videos in the series.
Thank you.