HiTechnic IRSeeker and Robot Soccer

In Robot Soccer it is useful for your Robot to be able to tell the direction to the soccer ball. A HiTechnic IRSeeker (Infra-Red Seeker) can help your robot do this.

What does a HiTechnic IRSeeker Sensor Do?


This is a Robot Soccer ball. It has many small infra-red emitting diodes within the transparent plastic sphere. Infra-red is invisible to human eyes, but can be detected by special infra-red detectors.

 The HiTechnic IRSeeker Sensor contains five infra-red detectors that can detect an infra-red source such as a Robot Soccer ball.

 

The five infra-red detectors are pointed in the directions show by the numbers 1, 3, 5, 7 and 9 in the diagram above. When the IRSeeker is used with LEGO’s G-code, a Robot using this sensor can tell if a Robot Soccer ball is in any of the directions 1 to 9; and with suitable programming can help the Robot turn towards the ball and find it.

Building an IRSeeker Sensor on to your Robot.

The HiTechnic IRSeeker sensor operates best in a horizontal position, so keep the sensor level so that it can read correctly.

Using the HiTechnic IRSeeker Sensor with NXT-G

To use the IRSeeker sensor from NXT-G, an additional piece of software needs to have been added to your computer. To see if your copy of the NXT-G software has been upgraded, start up NXT-G, start up a program, & check the menu. Does it contain this  option? If it does, you can use an IRSeeker with your robot. If it does not, it will be necessary for you to arrange that your software be upgraded before you can use the IRSeeker sensor. The necessary additional programming block is available for download from www.HiTechnic.com .

If your copy of NXT-G has been upgraded, construct the following program. The program aims to let you see the IRSeeker reading on your NXT’s screen.

The IRSeeker (red arrow above) control block could look like this:

The “Number to Text” control block (blue arrow above) could look like this:

The Display control block (purple arrow above) could be adjusted to look like this:

Now when you download this program to your NXT and run it, you will see a number displayed on your NXT’s small computer screen; this number (between one and nine) is the IRSeeker’s estimate of the direction of the nearest infra-red source.

Move your Robot around, and notice how the reading changes. You may notice that, as well as the ball, anything warm will give off infra-red radiation that may be noticed by your IRSeeker. Experiment and see if the reading changes when the IRSeeker sensor is tilted one way or another. Do you have to be quite careful to keep the sensor horizontal, or does this not matter? How far away from the IRSeeker can the Soccer ball be reliably detected?

Turning your Robot in the direction of the Soccer ball…

If you used the program on above, you could get an indication of the direction of the nearest source of infra-red – which hopefully will be the soccer ball. Suppose the reading given out by the IRSeeker is 3, how could we arrange to turn the Robot to face the ball?

First we would have to work out the logic of the moves we want the Robot to make. You will have to discuss this with your team, and come to an agreed solution. One approach (not necessarily the best) could be:-

If the IRSeeker reading is less than 5, then turn the Robot in an anti-clockwise direction until the IRSeeker reading equals 5

We would then have to change this logic into an NXT G-code command, so that we can teach the Robot to face the Soccer ball. Code something like this could be used:-

The control block for the IRSeeker icon could be as shown below. Note that in this case, the IRSeeker is plugged in to port 4 – the IRSeeker will work from any of the four NXT ports.

The control block for the Compare icon could be as follows.

In this case the direction number is passed from the IRSeeker icon by use of the yellow connector , which feeds the direction number (1 to 9) into the Compare icon. If the direction passed from the IRSeeker is less than 5, a “True” value is passed to the loop by the green connector line shown below.

While the Robot is inside the loop the two motor commands

 

are turning the Robot so that the IRSeeker reading is gradually increasing towards 5.

The control block for the Motor A icon could be:-

The control block for Motor C icon could be:-

When the IRSeeker reading equals 5, then the program stops. Is your Robot is now facing the Soccer Ball, or do you have to reverse the direction of the Motors to teach your Robot to turn correctly?

Soccer Strategy - 1

The program above is one way to program your soccer robot to face towards the Soccer ball. However it only works when the IRSeeker reading is less than 5. What will you teach your Robot to do if the IRSeeker reading is greater than 5? Discuss this with your group, and try out some solutions.

Soccer Strategy - 2

If you have solved the problem in Soccer strategy 1, there is still a lot for your team to do.

The next decision for your team to make is to decide what to do next. Do you want your Robot to charge towards the ball hoping to push it towards our opponent’s goal? Do you want your Robot to act as a goalkeeper to block the way between the soccer ball and our goal?

A lot of this strategy will depend on the roles you give your Robots (1 attack & 1 goalkeeper?  2 attack Robots? 2 goalkeeper Robots?)

It will also depend on how far the soccer ball is away from your Robot (would an ultrasonic sensor help?), and which direction the goals are from your Robot (a compass sensor might be handy here).

What should you do if the ball is between your robot and your opponent’s goal – charge at it? What should you do if the ball is between your robot and your own goal – should you charge at it or do something different?

Tasmania mainly uses the GEN II soccer field (see a diagram of the field by clicking here); for some more information on GEN II soccer (including videos) click here. In a 2007 GEN II soccer workshop in Tasmania, Mr. Brian Thomas gave the following hints:

Check if you are out of bounds (the mat under you is white) – if you are out of bounds try to return to the soccer field (turn around, go forward, and repeat this until the mat under you is not white and you are back in the soccer field).

Find the soccer ball (spin around until you see the soccer ball, but be careful, too fast a spin and you may miss it).

Go to a good place to kick the ball towards your opponent’s goal (if the soccer ball is between you and your own goal, travel to the other side of the soccer ball so that the soccer ball is between you and your opponent’s goal).

Go to the soccer ball (go fast towards the soccer ball, trying to reach it before your opponent’s robot)

Good luck - enjoy your Robot Soccer!

---------------------------------------------------------------------------------------------------------------

Mentor note: This is also available in a 5-page Microsoft Word 2003 document; click here.

LEGO MindStorms NXT Robot Tutorial Challenge 106 - HiTechnic IRSeeker Sensor & Robot Soccer - www.DrGraeme.net