HockeyBot – Trike Based IR Seeker Robot

This HiTechnic Trike based project uses the HiTechnic IR Seeker V2 together with the IR Ball to make a Hockey Bot. (Or call it a Soccer bot if you prefer, but as I write this we are in the middle of the 2010 Winter Olympics so I have Hockey on my mind). This robot uses the IR Seeker to locate the IR Ball and drive towards it. When the Ultrasonic sensor detects the ball right in front of it, then it gives it a good slap shot (or kick if like soccer).

Building Instructions for the HiTechnic Trike Base
View Instructions for adding sensors and motor to make the HockeyBot
NXT-G HockeyBot Program for LEGO Mindstorms 1.1
NXT-G HockeyBot Program for LEGO Mindstorms 2.0

The IR Seeker V2

The HiTechnic IR Seeker V2 Sensor is designed to determine the approximate direction of an IR source such as the IR Ball or IR Beacon. I have also heard of people using the IR Seeker to locate things like flashlights but that will only work if the flash lights happens to also give out a significant amount of infrared light.

The IR Seeker can operate in two different modes known as AC or DC. If you are using something like the current HiTechnic IR Ball, then you should select AC mode. Also make sure the IR Ball is set to mode D which will modulate at 1200Hz. If you are using an older IR Ball, or something like a flashlight, which does not modulate the IR light, then select DC mode.

If you have the older IR Seeker, known as the IR Seeker V1, then you can still build this robot using that sensor but you will need to change the IR Seeker Sensor block in the program to use the V1 sensor block. If you are uncertain which sensor you have, you can look at the shape of the end-cap.

The IR Seeker V1:

The IR Seeker V2:

The IR Seeker sensor gives a direction value based on this chart:

In addition to a value form 1 to 9 for the direction to the IR source, the direction value can also be zero if no significant IR source is detected.

Note: That in order to use the IR Seeker V2 in the LEGO Mindstorms software, you must first download and install the block from the downloads page. Here is a direct link to download for the block if you need it:
HiTechnic IRSeekerV2 Sensor Block for Mindstorms NXT Software

click on enlarge

The HockeyBot Robot

This robot is based on the HiTechnic Trike so the first thing you need to do is build this robot base. Note that this robot base can be built with either the LEGO Mindstorms 1.0 or 2.0 sets. The instructions show this robot with the 2.0 part colors and tires, but you can build this just as well with the 1.0 kits using the part colors and tires from that kit.

Next you need to add the IR Seeker, Ultrasonic sensor and the extra motor. Here are the instructions to add these to the robot base.

Attach the extra motor to port A, the Ultrasonic sensor to port 4, and the IR Seeker to port 3. The left motor should be on Port C and the right motor should be on Port B.

In this model the IR Seeker sensor is mounted high enough to get a good view around the robot to see the IR Ball.

The program

The goal with this robot is to turn and drive towards the IR source. To do that the direction value from the IR Seeker Sensor is used to adjust the motor power so that the robot will turn and drive towards the IR source.

Let’s take a look at the program:

The first thing that happens is that the variable Power is set to 50. This power is used later in the program as the base power used by the drive motors. In the video I demonstrate the robot turning in place to turn towards the IR Ball, I did this by modifying this block and setting the power to 0 instead of 50.

Next the A motor, the Hockey stick motor, is run forwards at low power for half a second. Since the program does not know for sure what the position of the stick is when it starts, this will ensure that the stick is in the retracted position.

Then comes the main control loop of the program. Here you will see that the IR Seeker block reads the sensor and sends the direction value, which will be in the 0 to 9 range, to the first math block, subtract by 5. Then value is then passed on to the multiply block to scale it up. The value range will now be -150 to 120.

Note that this range is asymmetrical since 0 is straight ahead. Remember, if no IR is detected, the direction value is 0, after the math this will turn into -150. What will basically happen is that if no IR is detected the robot will simply spin in place looking for the IR signal.

Once we have the scaled value, it is added to the Power variable to set the motor power on the left side and it is subtracted to set the power on the right side. And if the IR source is straight ahead, both motors will have the same Power value and the robot will go straight towards the IR source.

Note that the Motor block does not respond to negative power values. Internally it takes the absolute value of the power that is passed in and ignores the sign of the value. In order to make the motor reverse if necessary, we have to check the sign of the desired power and then set the direction value separately. In this program this is done by comparing the desired power with 0 and the results is passed to the Direction plug.

Finally at the end of the loop there is a Switch block to check the Ultrasonic sensor. If the sensor detects that there is something less than 10cm in front then it assumes the ball is right in front of the robot. It then stops the robot by using the Move command set to Stop, runs the A motor first one way at high power to hit the ball and then at lower power to reset the stick back again.


– Gus

Tags: , , ,

15 Responses to “HockeyBot – Trike Based IR Seeker Robot”

  1. [...] under: Robots, Sensors — Xander @ 21:00 Gus from HiTechnic sent me a link to a very cool hockey robot he’s built, based on the Trike-base.  I know it’s not a puck, but it’s the thought that [...]

  2. NeilG says:

    Nice work Gus !! Looks like the basis for a killer soccerbot to me.

  3. Gus says:

    Thanks. That’s the idea. A good soccerbot would also use a Compass or other means of navigation to try to get the ball in the right direction.

  4. Bill Brierly says:

    Great Robot. I have IRSeeker V1 and it works perfect. The only problem was the hockey stick that kept falling off. I reinforced it by putting a shorter beam on top of the motor and an axle to hold the two beams together. Now it doesn’t fall off. Thanks for a great Robot project.

  5. Bill Brierly says:

    I would like to use the Compass Sensor with my Hockey Bot. What would be added to the Hockey NXT-G program to use the Compass Sensor. Could I see a sample of adding the Compass Sensor?

  6. Bill Brierly says:

    I am interested in how to add into the Hockey Bot program to add the Compass Sensor. Is there somewhere where I can see how?

  7. Kaivalya says:

    Great Idea! And good explanation of the programming as well. :)

  8. Unfortunately, the signal becomes very sporadic and seems losing signal as it gets very close to the ball!!! Do I have t use an extra US or light sensor to view to check when the ball gets very close?

  9. problem with the IR ball being very close to IR sensor:

    when it gets closer than approx. 3cm to the sensor, it loses the signal … the readiing all the sudden drops. Is it possible that there is some kind time or intensitiveness adjustment causes some reading delay in the driver code???

  10. Gus says:

    This is not unexpected. For one thing the ball consists of multiple IR LEDs each one making a cone of IR light. Only beyond a certain distance do the cones overlap. Also, when the sensor is very close to the ball, the IR is so bright that the sensor elements get overwhelmed and multiple elements get significant IR readings. The sensor should be mounted so that it does not get too close to the IR ball.

  11. [...] from HiTechnic sent me a link to a very cool hockey robot he’s built, based on the Trike-base.  I know it’s not a puck, but it’s the thought that [...]

  12. Alexander La Marca says:

    I built this HockeyBot with an HiTechnic IR-Receiver to make it remote controlled and a HiTechnic Color Sensor V2 to detect the Ball (I used a tennis ball). The Color of the ball is #14 (light yellow) for the HiTechnic Color Sensor V2. The HiTechnic IR-Receiver is on the same place as the HiTechnic IR Seeker of your HockeyBot. The HiTechnic Color Sensor V2 is on the same place as the Ultrasonic Sensor of your HockeyBot. Can you build that HockeyBot like mine. and make a video and publish it on HiTechnic.

  13. Gus says:

    Wow, sounds great! I think you have made a great desciption of your version of the robot and that will be enough to inspire others to try the same. If you make a video of your robot then we would be happy to post a link to it!

  14. Chach says:

    HockeyBot it cool. But I can use Robolab 2.9 for control IR Seeker V2 .

  15. Gus says:

    I think if you install the 2.9.4C Patch then you should be able to program with the IRSeeker V2. Contact for additional ROBOLAB support.

Leave a Reply