Soccer Tactics 2 - Find the Ball!

The second thing we want our robot to do is to find the ball.

If our robot is built according to the 2011 World Robot Olympiad rules, the 2011 New Zealand RoboCup Junior Soccer Rules and the 2011 Australian RoboCup Junior Robot Soccer Rules Open League, it can be equipped with a HiTechnic Seeker V2 sensor. If it is built according to the 2011 Australian RoboCup Junior Robot Soccer Rules Novice League, this HiTechnic Sensor is not allowed, and a Lego Light sensor should be used. The discussion on this web page is about using the HiTechnic sensor. HiTechnic offers a "Football Kit" that includes a ball, seeker V2 and compass sensor; click here to see the reduced price.

When the HiTechnic NXT IR Seeker V2 sensor is mounted on a robot, the sensor will detect the direction of the Soccer ball, and indicate that direction by a number. If sensor is mounted on a robot with the sensor's mounting holes below the sensor, the direction numbers are as shown in the diagram below:-

HiTechnic infra-red Seeker V2 Robot Soccer Lego mindStorms free tutorial Robot Soccer HiTechnic Seeker V2 Free Tutorial

If  the sensor is mounted on a robot with the sensor's mounting holes above the sensor, the direction numbers are reversed, as shown below:-

HiTechnic Infra-red seeker V2 recognition pattern sensor reversed Lego NXT mindstorms free tutorial Robot Soccer HiTechnic Seeker Sensor V2 Lego NXT MindStorms free tutorial

If the Soccer Ball is straight ahead, the HiTechnic Seeker Sensor will give a direction number = 5. This will be the same if the sensor is mounted "upside down", "right way up", or "sideways". So, to find the ball, let us make our robot spin around until the sensor sees the Robot Soccer ball straight ahead (seeker direction number = 5).

Robot Soccer Program part 1

Robot Soccer Program Part 1a

The circled command above will make motor A go forwards.

Robot Soccer Program part 2

Robot Soccer Program part 2a

The circled command above will make motor C go backwards. Motors A & C working together will cause our robot to spin on the spot, looking for the Soccer ball.

Robot Soccer program part 3

Note that my HiTechnic Seeker V2 sensor is plugged into computer brick socket 2. If your robot has your seeker sensor plugged in to a different socket, you will have to change this code.

Robot Soccer program part 3a

The program above brings the HiTechnic Seeker V2 sensor into our program. But how do we know when it produces a direction number = 5?

Robot Soccer program part 4

Robot Soccer program part 4

In the code above, we have added a mathematics block. We have changed the sensor's command block to detect when the direction number "Equals 5". Note that we have connected the two blocks by a yellow wire. This allows the direction number to go from the Seeker block through the yellow wire to the Mathematics block. If you forget to do this, the program will refuse to work!

Next we want to make the robot continue to spin around until it sees the Soccer ball (when it sees a direction number = 5). To do this we need a loop.

Robot Soccer program part 5

Robot Soccer Program part 5a

In the code above, the mathematics block is connected to the loop with a green wire. When the mathematics block gets a direction number = 5 from the seeker block, it passes a "stop" signal through the green wire to the loop; this tells the loop to stop repeating. This code will allow your robot to leave the loop and obey the next command following the loop. We haven't put that next command in yet, but will soon.

Our Robot has Found the Ball - Now What?

There are lots of things we can tell our robot to do after it finds the ball. However, just so we can test that our code works, let us tell our robot to go forward one rotation each time the ball is seen.

Robot Soccer program part 6

Robot Soccer Program part 6

The code above causes motors A and C to turn one rotation, causing the robot to go a short way forwards.

Robot Soccer program turn 6

Robot Soccer program part 7a

The loop in the code above causes the whole code to keep repeating forever, or until we turn our robot off.

This complete program causes the Robot to keep finding the Soccer ball, and following it - which is what we wanted.

Download this program to your robot, and test it to see that your robot does what you want it to do.

If there are problems, carefully check the diagrams above to make sure you have understood the method we have outlined above.

When everything is good, go on to the next step to find out how to tell your robot which is your opponent's goal!

DrGraeme.net - Family Fun With Robotics - Lego NXT MindStorms - NXT-G - Robot Gen II Soccer  step 5