Hands-on Activity: Cleaning the Floor Using a Robot: An Introduction to Random Numbers

Contributed by: AMPS GK-12 Program, Polytechnic Institute of New York University

A photograph shows a small flying saucer-shaped white, black and gray plastic and metal device with buttons and ports.
A Roomba® (iRobot) vacuum cleaner.
copyright
Copyright © 2006 Larry D. Moore, Wikimedia Commons http://commons.wikimedia.org/wiki/File:Roomba_original.jpg

Summary

Posed with a paradigmatic engineering problem, students consider and explore mathematical algorithms and/or geometric concepts to devise possible solutions. The problem: How should a robotic vacuum move in order to best clean a floor of unknown shape and dimensions? They grapple with what could be a complex problem by brainstorming ideas, presenting the best idea for a solution and analyzing all presented solutions, and then are introduced to an elegant solution. Rather than elaborately calculating the most efficient route and keeping track of which tiles the robot has visited, a random number generator determines which direction the robot will take when it hits a barrier. Students are able to visually confirm how an unfamiliar programming concept (a random number generator) can make for a simple and efficient program that causes an EV3 robot (that is suitably equipped) to clean a bare floor. Then students think of other uses for random numbers.
This engineering curriculum meets Next Generation Science Standards (NGSS).

Engineering Connection

Many problems faced in engineering can only be solved by the use of complex mathematics or specific mathematical algorithms. A random number generator is one example algorithm that is commonly used in computer programs for many purposes, from character actions in games to encrypting Internet communications. It can also be used for modeling real physical systems, which inherently contain some noise or randomness, such as weather forecasting. In addition, engineers must design products so that random or unpredictable processes from the surrounding environment have minimal impact on safety and reliability.

Pre-Req Knowledge

  • Some understanding of the engineering design process, specifically that it is a circular and iterative process, rather than linear.
  • Experience building and programming LEGO MINDSTORMS EV3 robots.
  • Familiarity with the concepts taught in the What Is a Robot? lesson.

Learning Objectives

After this activity, students should be able to:

  • Provide examples of how engineers approach problem solving using their knowledge of mathematics.
  • Describe how the concept of random numbers can be used to solve real-world problems.

More Curriculum Like This

What Is a Program?

Using a few blindfolds and a simple taped floor maze exercise, students come to understand that computers rely completely upon instructions given in programs and thus programs must be comprehensive and thorough. Students create and test basic programs, first using just the LEGO intelligent brick, an...

Elementary Lesson
How Do You Make a Program Wait?

Building on the programming basics learned so far in the unit, students next learn how to program using sensors rather than by specifying exact durations. Working with the LEGO® MINDSTORMS® EV3 robots and software, they learn about wait blocks and how to use them in conjunction with move blocks set ...

How Do You Make Loops and Switches?

Students learn how to program using loops and switches. Using the LEGO® MINDSTORMS® robots, sensors and software, student pairs perform three mini programming activities using loops and switches individually, and then combined.

Python Calculus

Students analyze a cartoon of a Rube Goldberg machine and a Python programming language script to practice engineering analysis. In both cases, they study the examples to determine how the different systems operate and the function of each component.

High School Lesson

Educational Standards

Each TeachEngineering lesson or activity is correlated to one or more K-12 science, technology, engineering or math (STEM) educational standards.

All 100,000+ K-12 STEM standards covered in TeachEngineering are collected, maintained and packaged by the Achievement Standards Network (ASN), a project of D2L (www.achievementstandards.org).

In the ASN, standards are hierarchically structured: first by source; e.g., by state; within source by type; e.g., science or mathematics; within type by subtype, then by grade, etc.

  • Define the criteria and constraints of a design problem with sufficient precision to ensure a successful solution, taking into account relevant scientific principles and potential impacts on people and the natural environment that may limit possible solutions. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • New products and systems can be developed to solve problems or to help do things that could not be done without the help of technology. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Requirements are the parameters placed on the development of a product or system. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Knowledge gained from other fields of study has a direct effect on the development of technological products and systems. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Design involves a set of steps, which can be performed in different sequences and repeated as needed. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Modeling, testing, evaluating, and modifying are used to transform ideas into practical solutions. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Define the criteria and constraints of a design problem with sufficient precision to ensure a successful solution, taking into account relevant scientific principles and potential impacts on people and the natural environment that may limit possible solutions. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
Suggest an alignment not listed above

Materials List

To share with the entire class:

Each student needs:

Note: This activity can also be conducted with the older (and no longer sold) LEGO MINDSTORMS NXT set instead of EV3; see below for those supplies:

  • LEGO MINDSTORMS NXT robot, such as the NXT Base Set 
  • LEGO MINDSTORMS Education NXT Software 2.1
  • computer, loaded with NXT 2.1 software

Introduction/Motivation

Computers are involved in nearly every aspect of our lives. Simple or complex, computers are present in our phones, cars, kitchen appliances, vacuum cleaners and even watches (see the Apple Watch website https://www.apple.com/watch/ for an example). How do humans "tell" computers what to do? (Answer: Through the use of computer programs.) In this activity, we will continue to use the EV3 robots and the LEGO MINDSTORMS EV3 programming environment to explore the world of robots and engineering.

Computers do not understand the spoken or written language that we use in ordinary discourse, but instead comprehend computer software, which is also called computer code. This software is a set of instructions that computers can understand and follow. The software directs the computer processor to perform specific tasks, such as opening a file, editing a text document or displaying a video. The software is written using programming languages, which are specific languages designed to communicate instructions to computers in the form of software. People who compose these instructions are called computer programmers, and they use languages such as Java or Python to create the software. Just as regular human language has rules of grammar and syntax, programming languages also have certain rules that use special words and formats intended for particular types of computers. When a computer is combined with physical mechanisms and electronic sensors, a robot is created.

Robots are designed and created by engineers. They follow a series of steps called the engineering design process to guide them in the creation of new products. This design process is circular and iterative. This means that engineers repeat the steps as many times as necessary in order to make improvements to the product. While the engineering design process includes about six basic steps, this activity will focus on three of them: defining the problem, brainstorming and developing ideas and solutions, and evaluating alternatives and performing design analysis. (Note: For more information on the engineering design process and its steps, refer to the recommended websites in the Additional Multimedia Support section.)

To follow the design process, we are going to look into a real-world engineering design problem related to robots. Specifically, we will consider the design of robotic vacuum cleaners. First, let us start by brainstorming about why this kind of robot would be important to create. Can you think of any reason why someone would want to have a robot clean the floor, instead of using a regular vacuum cleaner? (Give students a moment to think about this and offer their ideas to the class.) Consider the case of people who are injured or disabled. They may not be able to vacuum the floor themselves, or it may be a very difficult and time-consuming task. A robot could be very useful if it was set up to consistently clean the floor every day or week. If you were part of the engineering team tasked with designing this robot, what features would you want to include that would help clean the floor?

In this activity, we will focus on a specific part of the design. Consider the following typical example engineering design problem: How should a robotic vacuum move in order to best clean a floor of unknown shape and dimensions? Note that posing this question gets us started with step 1 of the engineering design process: defining the problem.

Vocabulary/Definitions

computer software: A set of instructions that a computer can understand and follow. Software directs the computer processor to perform specific tasks, such as opening a file, editing a text document or displaying a video.

programming language: A language designed to communicate instructions to a computer in the form of code. Programming languages are what computer programmers use to create apps, games and other useful software.

random number generator: A computer program or calculation, or mechanical system or device that generates a sequence of numbers that lack any pattern.

random numbers: A set of numbers in which each successive number bears no systematic relationship to the number before it.

Procedure

Background

In this activity, students are given background information on computer software and programming, and the engineering design process, and then invited to solve an engineering problem. Next, they are introduced to the concept of random numbers and a random number generator and watch two short videos on the topic. Then, students apply this new knowledge to the same problem.

Before the Activity

  • Conduct this activity using one shared EV3 robot per class. Or, if more robots are available, provide one EV3 robot per group.
  • Gather materials and make copies of the Random Numbers Pre-Quiz, Random Numbers Worksheet and Random Numbers Post-Quiz.
  • Provide enough smooth floor space to run the activity. Use boxes, poster board, walls and other available classroom objects to create for each robot a minimum 3 x 3 ft. low, walled off area in which to move.
  • Be ready to show the class two short video clips, as listed in the Additional Multimedia Support section.
  • Prepare the EV3 robot according to the 5-Minute Bot Building Instructions.
  • Download the RandomMovement.ev3 file to the computer and open it with the EV3 software. Once the file is opened, connect the EV3 intelligent brick to the computer with the USB cable. Then, use the MINDSTORMS software to download the rbt program onto the EV3 brick, by selecting the download button located on the bottom right of the computer screen. As an alternative, if you are familiar with programming the EV3 brick you may want to write your own programs to demonstrate different patterns of movement, including random movement, circles and other geometric shapes.

With the Students

  1. Administer the pre-quiz.
  2. Explain to students the concepts covered in the Introduction/Motivation section to provide a general review of software programming, robots as computers and specific steps of the engineering design process.
  3. Hand out the worksheets and ask students to write their names on them.
  4. Introduce the engineering design problem: To program an EV3 robot to move in order to most efficiently clean a floor with an irregular shape. (Refer to the irregular floor area provided on the worksheet.) Then ask: What mathematical or geometric concepts can we use to solve this engineering challenge?
  5. Tell students that, for simplicity, we assume that: A) when the robot touches a square of the floor, we deem that entire square "clean." (We can reduce the problem of partially cleaned tiles as much as we want by making the size of the virtual tiles as small as we want.) B) the robot cannot keep track of its past travels, so the program cannot use the information about which squares have been previously cleaned as part of the algorithm that governs its movement. By identifying the problem, we have completed step 1 of the engineering design process.
  6. Divide the class into groups of four to six students each. Ask groups to each come up with a short list of steps or a geometrical pattern that they think would cause the robot to efficiently cover the area of an irregularly shaped floor. Point out that doing this is step 3 of the engineering design process: brainstorming and developing ideas and possible solutions. (Note that Step 2 is "conduct background research.") Have each group document on the worksheet its best proposed solution to the problem, including any steps or mathematical equations, and then draw a sketch or diagram to visually represent the solution. For example, students might draw a series of circles to show a path for where the robot would move about the room.
  7. Have each group make a brief presentation to the class explaining its design solution. Suggest that students either draw the proposed robot movement on the classroom board or act out the robot movement in front of the class.
  8. Next, guide students through the thought process to examine the various suggested strategies in more depth. This helps students think through how their plans would play out in reality, particularly with regard to robustness and efficiency in dealing with a complex floor shape, compared to a simple rectangular area. Doing this serves as step 4 of the engineering design process: evaluating alternatives and performing design analysis. Expect possible student-suggested movement strategies to include a spiral, back and forth, consecutively smaller squares, circular patterns, special movements for dealing with obstacles, etc. Demonstrate how they might work by drawing or physically moving a robot around the classroom space to show the feasibility of the strategies. As the class observes these demonstrations and discusses the pros and cons of the various solutions, have students record their observations and realizations on their worksheets. Examples:
  • For a spiral pattern, draw on the board a robot following a spiral pattern inside a square room. As Figure 1 illustrates, a robot would miss cleaning the room corners.
  • For a back and forth pattern, point out that this strategy would not work well for a room with many obstacles, such as a classroom full of desks.
  • For a consecutively smaller squares strategy, a robot trying to clean a non-square room would miss parts along the outer edge.
  • For a circular pattern, point out that the robot would miss cleaning in the gap areas between circles.
    A drawing shows a spiral path (a curved black arrow) starting in the middle of a square (representing the area of a room) and coiling outward until it reaches the square edges (walls). The black line does not enter into the four square (room) corners.
    Figure 1. Robot movement example.
    copyright
    Copyright © 2014 Raymond Le Grand, School of Engineering, NYU Polytechnic
  1. Introduce the concept of randomness versus order with an exercise in which students are able to visually see the effects of randomness in a mathematical context. Have students line up in the classroom according to height (see Figure 2). Then, read a list of names from the student roster in a random order and have students line up in the order that they are called. Then ask students to describe on their worksheets the difference between the first line ordered according to height and the second line that is random. Then, explain that random lists are defined by a lack of order, intentional pattern or conscious decision. Also explain the existence of "random number generators," starting with a humorous video, Random Number Generator (2:09 minutes) and then the Random vs. Pseudorandom Number Generators (6:40 minutes, but just show the first 1:20 minutes). See website addresses for the videos in the Additional Multimedia Support section.
    A photograph shows 15 kids lined up along one wall of a classroom. It looks like they are lined up according to height, with a few exceptions.
    Figure 2. A classroom exercise to help visualize order vs. randomness.
    copyright
    Copyright © 2014 Raymond Le Grand, School of Engineering, NYU Polytechnic
  2. Explain random numbers: A random number is a number that is chosen without conscious decision or pattern. Random numbers do not have "order," but a computer or other device can generate them. A device that picks out random numbers in an unbiased manner, with no favor being given to any particular number, is called a random number generator. Some examples of these devices include coins, dice and spinners. A computer program can use a random number generator to make decisions, such as having a screen saver display random shapes.
  3. Remind students that engineers use the process of iterative design to create good products. Engineers are rarely satisfied with initial designs, but continuously seek to improve them by applying what they learn from analysis to making changes to the designs. Now that all group designs have been analyzed and students have gained new information, it is time to take a fresh look at their designs for how to improve them. Invite the groups to brainstorm about applying this new concept of random numbers to the problem of the robot floor cleaner by asking: How could we use random numbers or a random number generator to make the robot move around and clean the entire room? Expect that the leap of figuring out how the random number generator can be used in this program may be difficult for students. If so, go back over the basic problem of what the robot should do (given our assumptions) in order to have it clean the entire floor surface. If no students are able to answer the question, propose the following answer: The random numbers can be used to make the robot move in random directions, thus eventually covering the entire floor. Have students compare the results of this technique to some of the others initial design ideas that were considered before the concept of random numbers was introduced.
    A photograph shows a girl observing a robot moving to avoid its surrounding low walls.
    Figure 3. Student observes the random movements of a EV3 robot.
    copyright
    Copyright © 2014 Raymond Le Grand, School of Engineering, NYU Polytechnic
  4. Ask students to select a floor area shape and create a perimeter of obstacles, such that the obstacles become low walls defining that area. To do this, use boxes, poster board, classroom walls and any other handy materials or furniture. For best results, make the physical implementation at least 3 x 3 ft. in size. See Figure 3 for an example. Only one robot and floor shape are necessary for students to visually see the results, but if each group has a robot, have each group create its own floor area.
  5. Place the pre-programmed EV3 robot inside the area and begin the robot program. The robot will automatically try to avoid the obstacles and make random turning movements. Without giving the answer to students about what is happening, direct students to watch what the robot does and record on their worksheets their detailed observations about the robot movements.
  6. Explain that the robot is programmed to turn a random amount each time it detects an obstacle with its ultrasonic sensor. By doing this, it covers the entire floor area, regardless of the shape of the area. The Roomba® (iRobot) vacuum cleaner, uses this method in homes around the world to clean carpet floors.
    EV3 program code
    Figure 4. The LEGO EV3 program directs the robot to detect obstacles and turn randomly.
    copyright
    Copyright © LEGO MINDSTORMS EV3
  7. Open the LEGO MINDSTORMS software and show students the EV3 code used to program the robot (Figure 4). Specifically, talk about how the first part of the code (the inner loop) is set up to make the robot go straight until the ultrasonic sensor detects an obstacle, with a threshold value of 10 inches. Then, the robot moves straight backwards for one rotation. Next, a random number is taken from the random number generator block, which is multiplied by a factor of 10, then sent to a move block, where the duration of the turn is set by the multiplied random number. Finally, the entire program is in a loop, so after it finishes turning it starts again at the beginning, moving straight ahead.
  8. As an exit reflection, invite students to think of other applications in which a random number generator might be part of a solution to an engineering problem. After listening to ideas from students, give the following examples.
  • Computer programs use random number generators for everything from character actions in games to encrypting Internet communications.
  • Random numbers are also used for modeling real physical systems, which inherently contain some noise or randomness, such as weather forecasting.
  • In addition, engineers must design their products such that random or unpredictable processes from the surrounding environment have minimal impact on product safety and reliability. For example, civil engineers design bridges so that they do not crumble under the random gusts of wind during storms, while still supporting the weight of cars distributed at random intervals along its surface.
  1. Administer the post-quiz.

Attachments

Troubleshooting Tips

If the robot does not work, make sure its motors and ultrasonic sensor are connected to the correct ports.

Investigating Questions

  • What are random numbers? (Answer: A set of numbers in which each successive number bears no systematic relationship to the number before it.)
  • Who makes computer programs? (Answer: People who write instructions in the specific languages that computers understand are called computer programmers or computer scientists.)
  • How do robotic vacuum cleaners move around a floor area? (Answer: Robotic vacuum cleaners usually move around randomly, in order to make sure they clean the entire floor areas of unknown shape.)

Assessment

Pre-Activity Assessment

Pre-Quiz: At the beginning of class, administer the Random Numbers Pre-Quiz to determine students' base knowledge of the activity topics, including computer software and programming, the concept of random, and random numbers.

Activity Embedded Assessment

Worksheet: Have students use the Random Numbers Worksheet during the activity to sketch group ideas for the path the robot should take in covering an irregularly shaped room, provide a definition of a random number, and record robot movement observations. Review their worksheets to gauge their depth of understanding.

Post-Activity Assessment

Post-Quiz: At the end of class, administer the Random Numbers Post-Quiz to assess student's understanding of the concepts explained in the activity, including the definitions of computer software, programming language, random and random number generator. Additional questions ask for an example of random vs. non-random relationships, their ideas on how they would program a robot to clean a kitchen floor, and in what ways a random number generator might be useful for solving engineering problems. Review their answers to assess their level of comprehension.

Activity Scaling

  • For lower grades, engage students' attention by having them design their own "cleaning accessories."
  • As a further challenge for upper grades, have students write their own programs that direct a robot to cover the entire floor area.

Additional Multimedia Support

As part of the Procedure section, show students the following video clips about random numbers:

For more detailed information about the steps of the engineering design process, see the Creative Engineering Design unit.

For more information about the engineering design process, see https://www.teachengineering.org/engrdesignprocess.php.

Prepare the EV3 robot for the activity by follow the online tutorial, 5-Minute Bot Building Instructions, which provides excellent guidance through the building process because of its many images: http://robots2doss.org/2013/10/5-minute-bot-for-the-ev3-kit/

Contributors

Raymond Le Grand, Lester Greenman

Copyright

© 2015 by Regents of the University of Colorado; original © 2014 Polytechnic Institute of New York University

Supporting Program

AMPS GK-12 Program, Polytechnic Institute of New York University

Acknowledgements

This activity was developed by the Applying Mechatronics to Promote Science (AMPS) Program in the School of Engineering, funded by National Science Foundation GK-12 grant no. 0741714. However, these contents do not necessarily represent the policies of the NSF, and you should not assume endorsement by the federal government.

Last modified: August 4, 2017

Comments