Professional Documents
Culture Documents
Clarify Objectives
A group must design, construct, and program a Lego NXT microprocessor-based
robot. This robot has to be able to pick up /identify green colored balls positioned
arbitrarily in the square arena and place them outside of the arena. In this arena are
also white colored balls that can be collected but must be identified as white and
therefore be kept inside the arena. There will be a maximum time of 3 minutes for the
robot to attempt the task.
6. Generate Alternatives
In the beginning of the project the team thought that the two touch sensors
should be used in the front, in order to detect walls when sampling the arena space, and
the ultrasonic sensor should be used in the back to sense when it is close to a wall and
then fling the ball out of the arena. The reason that this was the original design of the
robot was because when we were looking at examples of how people approached the
final project on blackboard we saw that most groups had bumpers in the front and so
we tried that model first. However this idea was quickly abandoned because the forklift
was continuously running into the wall before the bumpers (on either side of the robot)
got a chance to even come in contact with the wall. Also, to build better bumpers more
parts were needed than what was included in the Lego kit.
Once we abandoned this idea we thought of using the ultrasound sensor in the
front of the robot instead of the two touch sensors. This was a good idea because we
wouldn’t have to deal with the problem of the forklift being two long, we could just
program how close we wanted the robot to be able to come to the wall using the
ultrasound sensor. The group also visualized/discussed different ways of placing the
ultrasound sensor on the robot and which way would be the best/most effective. It was
decided that the ultrasound sensor would be on the front of the bot above the forklift.
The advantage of having it at this position was that the forklift would not run into the
wall before the ultrasound sensor picked up the wall. However the disadvantage is that
if the sensor was not placed correctly (if it pointed down at all) it would pick up the balls
and would then turn around thinking that it was the wall.
Lastly when it was decided to have the ultrasound sensor on the front of the
robot the two touch sensors were then moved to the back of the robot where a huge
bumper was created so that it could detect the wall when it reversed into it, and then
fling the ball out of the arena.
7. Model/Analyze Design
See Final Flowchart
Description
Tasks
main() This task sets the sensors and what ports
they are in, starts off the robot by stating
for it to move forward, and starts the task
hunt(), wall(), and ball().
hunt() This task causes to robot to sample the
arena space by continuously moving
forward and turning randomly by using
the variables move_time, and turn_time.
wall() This task lets the robot know when the
back of the robot is approaching a wall(by
using the ultrasound sensor), and then
flips the forklift. This task is made to eject
any green balls that are on the forklift,
and this is done by using and if
statement(which resides inside of a
while(true)statement) that deals with the
ultrasound sensor. It then restarts the task
hunt() to search for another green ball.
ball() This task is made to sense if there is a
green or white ball in front of the light
sensor by using “if” statements and
dynamic thresholds. If there is a green ball
(or reading inside a certain threshold) task
hunt(), and wall() are stopped, the robot
then moves the forklift upwards so that
whatever ball is on the forklift does not
fall off when backing up, and then
reverses until either or of the touch
sensors on the back of the robot are
activated(this is done by using an until
statement), and then flips the forklift all
the way back ejecting the ball. If a white
ball is sensed (or a reading within that
threshold) task hunt(), and wall() are then
stopped, and then the robot reverses a
little bit so that the light sensor and
forklift are cleared, and then restarts task
hunt(), and wall().
Preprocessor
#define LIGHT SENSOR_2 Sets the sensor in port two to be referred
to as “LIGHT” in the code instead of
SENSOR_2, in order to make it clearer that
we are using the light sensor.
#define TOUCH1 SENSOR_3 Sets the sensor in port three to be
referred to as “TOUCH1” in the code
instead of SENSOR_3, in order to make it
clearer that we are using one of the touch
sensors.
#define TOUCH2 SENSOR_4 Sets the sensor in port four to be referred
to as “TOUCH2” in the code instead of
SENSOR_4, in order to make it clearer that
we are using one of the touch sensors.
Variable
int move_time This variable is set to Random(9000), so
every time the while(true) statement
restarts a new random value is assigned to
this variable and is then used as a value
for how long the robot should move
forward.
int turn_time This variable is set to Random(5000), so
every time the while(true) statement
restarts a new random value is assigned to
this variable and is then used as a value
for how long the robot should turn right.