Lab Session 3

Introduction

Last week, you programmed your robot to detect collisions with walls, and to detect white lines on the table, and take some action in each case.  This week, you will program your robot to follow a white line on the table.  You will then use a beacon receiver to detect the beacon signals on the table, and program your robot to drive towards one of them.

Line following

We discussed algorithms for following a line in the lecture this week.  For this exercise, you may use one or two optical sensors - you may build more sensors later, if you need them for your competition robot.

Task 1

Write a program to make your robot drive along a white line on the table, using information from one or two optical sensors.  It should continue until it hits an obstacle - you can use the switches already on your robot to detect this.

As a minimum, your robot should be able to follow a straight white line, but a robot which is able to drive straight anyway could do this without looking at the line!  To check that your robot is actually able to follow a line, you should test it on a line with corners, or on a curved line.  If it can follow a curved line, then it should be able to survive unexpected events in the competition, such as being knocked off course by the other robot.

Beacons

The beacons are mounted at each end of the table, as shown.  They transmit pulses of infra-red light at regular intervals - about 5ms at one end, about 12ms at the other.

A beacon receiver on your robot can detect these pulses, and we provide software to measure the time interval.

Full details are available on the beacon page.

 

Beacon software

If you are using a fixed computer, the beacon software should be installed already.  If you are using a laptop, you should download the beacon receiver software.  The easiest way is to right-click on that link, select "Save Target as..."  and save the file with the filename  beacons.icb  in the  lib\handyboard  folder under Interactive C, or else in the folder where your programs are saved.  For the file type, select "All Files", to make sure that Windows does not change the name of the file.  

If the beacon software file is not in one of the two places specified, the Interactive C compiler will not be able to find it.  Also, if Windows has changed the filename (it often adds ".txt" to the end), then Interactive C will not be able to find it.

See the beacon page or the lecture notes for details of the software and how to use it.

Task 2

The first step is to get your beacon receiver working.  You can use the receiver on the Handyboard, but only if it is high enough - it needs to be about 160mm above the table surface.  It will also be easier to use if it is facing towards the front of your robot.  Otherwise, you should add an external beacon receiver to your robot.  You can find this in Bag Z.  You should mount it at least 160mm above the table, facing towards the front of your robot.  You must connect it to port 8 on your Handyboard.

Download the example program, beacon-test.ic.  This will show you which beacon signal is being received, if any.  As given, it uses the internal beacon receiver on the Handyboard - you can modify it to use the external beacon receiver by changing the relevant #define.  Use this program to test your beacon receiver.  It should "see" a 5ms signal from the beacon at one end of the table, and a 12ms signal from the other beacon.

The signals are quite strong - your receiver should be able to receive the beacon signal anywhere on the table, as long as there is no obstruction between the beacon and the receiver.  If it receives signals from both beacons at the same time, it will probably get a confused signal and report that it is seeing no beacon at all.

Shielding

You may have noticed that the beacon receiver accepts signals over a wide range of angles - even from behind, if the signal is strong!  This is no use if you are trying to figure out which way your robot is facing, or where the beacon is.  You need to put a shield around your receiver, so that it only receives light from a small range of angles.  

WARNING:  The infra-red receiver is delicate!  Take great care in fitting a shield over it, so that you do not break it off the Handyboard or the external circuit board! 

You will find some shielding parts in Bag Z.

Tools are available in the laboratory.

The tubular shield has a slot into which the infra-red receiver should fit.  If you want to increase the range of angles over which the receiver can "see" the beacon, you can make the shield shorter by cutting it.  If you want to make the range of angles narrower, you can extend the tube with black tape. 

To use the open rectangular shield, first cut out one of the short ends.  Then put the shield around the infra-red receiver, with the newly open end in front.  Use a small amount of black insulating tape to hold the shield in place.  Put some tape over the top of the shield also, to stop unwanted light coming in from above.  You can adjust this shield by bending it to open or close the gap where the light comes in...

Use your program from Task 2 to test your shield.  If necessary, adjust the shield so that it allows in light over a suitable range of angles.  You need to be sure that if your robot "sees" the signal from the beacon, it is actually facing towards the beacon.

Task 3

Choose one of the beacon signals, and set a variable mybeacon to either 5 or 12 accordingly.  Get your robot to spin until it sees your chosen beacon signal, then stop.  Check that when your robot stops it is pointing straight at the correct beacon.  If necessary, you can adjust the shield or make the robot turn a little to correct any problems.  

Now add to this program so that the robot turns to face the beacon and then drives towards it.  It should continue checking the beacon signal as it drives - it may lose the signal as it drives towards the beacon, for example, if it is not driving in exactly the right direction, or if it is not driving in a straight line.  If it loses the signal, it should turn until it finds it again.  It should continue until it hits an obstacle - if all is well, this should be the wall below the beacon!

Task 4

Add a time limit to your program in task 3.  The idea is to ensure that your robot will not turn forever, looking for a beacon signal.  If it does not find a signal in a reasonable time, it should assume that there is an obstruction (perhaps another robot) and drive to another part of the table to try again.

Challenge 3

This combines your work in tasks 1 and 4.  Program your robot so that you can place it on a line, near one end of the table, and it will drive along the line until it hits something, then turn and drive to your chosen beacon.  It should stop when it hits the wall below the beacon.  

That is the basic requirement.  If you have time, you should consider refinements - for example:
- cope with an obstruction which blocks the beacon signal from a part of the table;
- beep and/or display messages to let humans know what is going on;
- let the robot start anywhere on the table, and find a line to drive along...

When this program is working, show it to one of the staff in the lab, and get your team number recorded.

Report

Add a comment at the start of your program for Challenge 3.  This should explain who you are, what your program was supposed to do, and how well it did it.  This report can be quite short, but it must provide enough information so that we can make sense of your program.  The program itself should have plenty of comments to help with this.

You can work on the report outside the laboratory - any text editor, such as Notepad, can open the program file and allow you to add comments.  The deadline for submission is 10am on Friday 5 February.  One submission from each team is sufficient - ideally the author should be a different member of the team each week.  As the entire team will be assessed on the basis of this report and program, you should all check that you are happy with it before it is submitted.

You can submit your report electronically, to the Digital Dropbox in Blackboard, with your team number in the name of the submission.  If you prefer, you can print the report and program and submit on paper (stapled pages please) before you leave the laboratory.

Tidying

Disconnect the white cable from the Handyboard, and make sure that the Handyboard is switched off.  These two steps are necessary to prevent the Handyboard battery from being discharged over the next few days.  We will charge these batteries for a few hours before the laboratory session next week, but there will not be time to re-charge them fully if you let them discharge completely!

Put all your Lego parts and your robot into the large plastic box.  Make sure the robot is accessible in the box, so that the Handyboard battery can be charged later.  Check the desk and the floor for stray pieces of Lego - you may need them for your competition robot!

If you were working at a desktop computer, you can leave the interface and charging unit on the desk.  If you were using a laptop computer, please put the interface and charging unit and the power supply unit into the box, to leave the desk clear.

 

HOME  |  SESSIONS   |  KIT  |  COMPETITION  |  NEWS  |  FAQ  |  LINKS
Copyright 2010, UCD School of Electrical, Electronic and Mechanical Engineering.  Contact