Obstacle Course
Once you have built a robot one of the first things you will want to do with it is to make it move around. This lesson uses the idea of an obstacle course to introduce you to the concepts of programming the RCX. At the end of this lesson you will be familiar with the following programming concepts:
  • Motor control (stop and start)
  • Wait commands (for implementing dead reckoning movements)
  • Subroutines

The programs shown in this lesson assume you're using a tank drive robot like the one shown in the projects area.

The Challenge: Obstacle Course

On a large flat surface (the FLL competition table works well) set up an obstacle course as shown in the following diagram.

Use heavy objects (like books) to mark the turning points. Your robot must navigate the course without touching any of the objects. If the surface you're using has walls, like the competition table, then it is fine for your robot to touch the walls.

To complete the obstacle course your robot will need to perform the following steps:

  1. go forward
  2. turn right
  3. go forward
  4. turn left
  5. go forward
  6. turn left
  7. go forward

What is not shown in the above steps is how far your robot must travel when it goes forward or turns. Experiment with your robot in the obstacle course you set up to find the right amount of movement.

To make a tank drive robot move forward you set the motors driving the wheels to move forward for a set amount of time, like this:

The first two blocks turn the motors on and the third block tells the program to wait for a preset time. During this time the robot will move forward. After the wait period is over the program will move on to the next block, which we want to be the start of a turn. There are several ways to make a tank drive robot turn. You can turn the motors in opposite directions which makes the robot spin, or you can stop one motor and set the other to move forward. The second method allows your robot to cover more ground while it is running so it is often a good choice to use. To make the tank drive robot turn in this way you can do something like this:

Questions

  • Which way does the tank drive robot turn if you use the above sample code (assuming the caster wheel is the rear of the robot)?
  • How can you make the robot turn in the other direction?

Solution

If you get stuck or you would like to compare your solution to one of ours, check out how one of the Hacienda robotics teams solved this obstacle course challenge.

Next Steps

Chances are if you used the sample code shown above to build up a program to solve this challenge you ended up with a lot of blocks that in the end make your robot do similar things. This is when you want to consider building a subroutine out of blocks in your program. Read on to find out how to create subroutines in your program.

Copyright © 2003, Hacienda Robotics Program.