AmazenRacer Robot Design Document
Project 2: The Altered Maze

Team 3: Vijay Gangareddygari, Ronald Olaski,
Nicole Staretz, and Melisa Tyira

SE 532 Engineering of Software Systems
Spring 2003

Table of Contents

Introduction

1.1Scope

Hardware Design

2.1 Construction

2.1.1 Wheels and Base

2.2 Sensors

2.2.1 Touch Sensor

2.2.2 Light Sensor/Proximity Sensor

Software Design

3.1 Justification

3.2 Features

Source Code

Introduction

1.1Scope

The second project was to navigate the robot through the Project 1 maze that had been altered slightly. One half of each wall on the left and right sides of the maze were removed, thus adding complexity to the original maze. The intent was to move the robot through the maze as quickly as possible without getting the robot stuck and without allowing the robot to fall off the table.

Hardware Design

2.1 Construction

We redesigned our robot differently than what we had used for Project 1. This was due to the fact that our first design would not work with the new setup of the maze. Our first design needed all walls in tact in order for the robot to hit. The new design required a light sensor and proximity sensor to complete the task set out in Project 2.

2.1.1 Wheels and Base

The hardware design of the robot included sturdy construction of all American Lego parts. Design was based on 4 wheels for balance and durability. The wheels and hardware built were based on a number of trial and error tests with earlier robot versions. After competing in the first maze race, we realized that we should create a design that would allow the robot to navigate through the maze faster while still remaining highly durable.

The hardware included 4 wheels for balance and steady navigation throughout the maze. As with Project 1, when building the body of the robot, special care was given to make it robust enough to withstand any force of impact with the wall at the maximum robot speed. Even though the fastest speed of seven on the motor was not necessarily the goal, the hardware design supported wall contact at this speed. Therefore it was decided that durable wheel construction was the best design when using touch sensors.

2.2 Sensors

The hardware consisted of a single touch sensor on the front right bumper, a guide only on the left front bumper, a proximity sensor on the right side, and a light sensor on the left side.

2.2.1 Touch Sensor

The use of a touch sensor on the right bumper and a guide on the left bumper was determined to be the best method for allowing the robot to come in contact with a wall. Since the design of the robot allowed for it to hit head on, it was determined that only one touch sensor would be necessary. If the left bumper without a touch sensor hit the wall, the algorithm would allow for the robot to continue going straight until it straightened out and the right bumper hit. Light sensors on the right and left sides were already being used; therefore only one touch sensor was used in the front.

2.2.2 Light Sensor/Proximity Sensor

The light sensor on the left side and proximity sensor (which is made up of a light sensor and the IR input/output unit) on the right side were used in order to determine when the robot had moved past the end of a wall. These sensors allow the robot to turn to head toward the next parallel wall on the interior of the maze. Both of these sensors were needed on the left and right side because we knew that the robot would need to hug the interior walls on both sides depending on which direction the robot was traveling. Due to the constraints of having the I/R unit on one side of the robot, only one proximity sensor could be used. This is the reasoning behind using a light sensor on the left side.

The Proximity Sensor is a highly sensitive sensor that consists of the Infrared unit and a light sensor attached above the infrared unit. The proximity sensor utilizes the IR input/output component as an input-only unit and the light sensor as a transmit-only unit. With the light sensor and the IR unit combined to create the proximity sensor, the send/receive properties create a greater sense of distance and better movement control.

Software Design

3.1 Justification

The procedure to move the robot through the maze is straightforward and will work every time based on the assumptions. We could assume there would be walls around the maze with the exception of the two halves of each side of the maze that were removed. The team set out to devise a fail proof algorithm that would move the robot steadily through the maze while hugging each interior wall until the end of the interior wall was determined. Once it was determined that the end of the interior wall had been reached, the robot would turn 90 degrees left or right to continue on to the next parallel interior wall. The robot would follow this plan until the end of the maze was reached.

The code is fail-proof as long as the walls of the maze are parallel, which was another constraint given to us at the start of the project. Regardless of where the entrance to the maze, on the right side, in the middle, or at the left side, the maze maneuvers always work. The robot first enters the maze and when it hits a wall it backs up and turns 90 degrees left. At this point, the pattern described below begins.

The algorithm is as follows: the robot first enters the maze and when it hits a wall it backs up and turns 90 degrees left. At this point the robot assumes it is traveling left. (Start of the maze always turns left). The robot will ride along this wall that it had come in contact with, until it reaches the end of the wall. This is determined by the sensor located on the right side. When it reaches the end of the wall, it will turn 90 degrees right, then continue moving forward until it hits another wall. Once it has reached the next interior wall, the robot will back up and turn 90 degrees left and travel straight until it reaches the end of this interior wall. This is determined by the sensor located on the left side. Once the robot reaches the end of this interior wall, it will continue the pattern by turning 90 degrees right and continuing straight until it hits the next interior wall.

The pattern is repeated throughout the maze until the robot exits the maze and is manually shut off. The main rules that this robot follows are:

  1. Every time a wall is hit and the touch sensor is triggered, back up and turn 90 degrees. The direction that the robot turns after backing up is determined by the last direction it had turned where the first turn after the first hit will always be left. Every turn after hitting the wall will be the opposite direction that it went in last.
  2. Every time the end of an interior wall is determined, turn 90 degrees and proceed straight to the next interior wall. The robot will turn in the corresponding direction of the light sensor or proximity sensor that is facing the wall.

3.2 Features

Since this robot is a wall hugger, this would be the best design if this was truly a race. The software and hardware design enabled the robot to follow the shortest path from the beginning to the end of the maze without approaching any of the exterior walls. Since the robot never comes in contact with the exterior walls, the situation where the robot is in danger of falling off the table will never be encountered.

The limitation of this robot is that it is limited to a maze with interior walls that have a perpendicular connection to the exterior walls.

Source Code

/**

* Lego Mindstorm System 2.0 and Lejos 1.0.2

*

* AmazenRacer February 28, 2003

* The robot rips through the maze with ease

* navigating around walls if they exist or

* not falling off the edge if walls do not exist.

*

* Vijayalashmi Gangareddygari

* Ron Olaski

* Melisa Tyira

* Nikki Staretz

**/

import josx.platform.rcx.*;

public class AmazenRacer {

private static final int MOTOR_SPEED = 7;

private int BACKUP_TIME = 225;

private int TURN_TIME = 675;

private int NINETY_DEGREE_TURN = 600;

private boolean huggingwall = true;

public static void main(String args[]) throws InterruptedException {

AmazenRacer roboDemo = new AmazenRacer();

}

public AmazenRacer() throws InterruptedException {

// S3 Sensor is Touch Sensor for Right Front Bumper...

Sensor.S3.setTypeAndMode(SensorConstants.SENSOR_TYPE_TOUCH,

SensorConstants.SENSOR_MODE_BOOL);

Sensor.S3.activate();

// S1 Sensor is Light Sensor for Reading Left Wall...

Sensor.S1.setTypeAndMode(SensorConstants.SENSOR_TYPE_LIGHT,

SensorConstants.SENSOR_MODE_PCT);

Sensor.S1.activate();

// Promiximity Threshhold default is 15. Larger #s get closer to wall.

// Use threshhold of 30 and Sensor 2 in conjunction with the IR Device.

ProximitySensor sensor = new ProximitySensor(Sensor.S2, 30);

// Parts I. and II. are initialization of robot setting up against wall

// They could also have been part of the Part III. loop

// Loop runs continuously driving robot through maze

// *** Part I. .. Drive to first wall ***

while (Sensor.S3.readValue() == 0)

{

Motor.A.setPower(MOTOR_SPEED);

Motor.C.setPower(MOTOR_SPEED);

Motor.A.forward();

Motor.C.forward();

}

// *** Part II. .. Back up and position robot to Hug Right Wall using Proximity Sensor

// BACK UP + 90 deg left

Motor.C.backward();

Motor.A.backward();

Thread.sleep(BACKUP_TIME);

Motor.A.stop();

Motor.C.forward();

Thread.sleep(TURN_TIME);

Motor.A.forward();

Motor.C.forward();

// *** Part III. .. Hug Wall Both Sides while Driving Straight Back in Maze ***

while (true) {

// going left until no prox on right

while (Sensor.S2.readValue() > 27)

{

Motor.A.setPower(MOTOR_SPEED);

Motor.C.setPower(MOTOR_SPEED);

Motor.A.forward();

Motor.C.forward();

}

// turn 90 deg right

Motor.C.stop();

Thread.sleep(NINETY_DEGREE_TURN);

// going straight till hit wall head on

while (Sensor.S3.readValue() == 0)

{

Motor.A.setPower(MOTOR_SPEED);

Motor.C.setPower(MOTOR_SPEED);

Motor.A.forward();

Motor.C.forward();

}

// BACK UP + 90 deg right and go left

Motor.A.backward();

Motor.C.backward();

Thread.sleep(BACKUP_TIME);

Motor.C.stop();

Motor.A.forward();

Thread.sleep(TURN_TIME);

Motor.C.forward();

Motor.A.forward();

// going right until no prox on left

while (Sensor.S1.readValue() > 20)

{

Motor.A.setPower(MOTOR_SPEED);

Motor.C.setPower(MOTOR_SPEED);

Motor.A.forward();

Motor.C.forward();

}

// turn 90 deg LEFT

Motor.A.stop();

Thread.sleep(NINETY_DEGREE_TURN);

// going straight till hit wall head on

while (Sensor.S3.readValue() == 0)

{

Motor.A.setPower(MOTOR_SPEED);

Motor.C.setPower(MOTOR_SPEED);

Motor.A.forward();

Motor.C.forward();

}

// BACK UP + 90 deg left

Motor.C.backward();

Motor.A.backward();

Thread.sleep(BACKUP_TIME );

Motor.A.stop();

Motor.C.forward();

//varies slightly depending on light dependency

Thread.sleep(TURN_TIME + 25);

Motor.A.forward();

Motor.C.forward();

}

} // end AmazenRacer constructor

} // end AmazenRacer class

Page 1 of 11

Robot Design Document