Product Evaluation (Sensors)

From EG1003 Lab Manual
Jump to: navigation, search


A pre-built robot will be evaluated for accuracy and precision by utilizing two different sets of code, the first without the use of sensors and the second with sensors. The robot will be tested on one of the three provided mini-courses. The data from the product evaluation of both sets of code will determine if the robot should or should not use sensors in navigating the mini-course.

Product Evaluation


Professional engineers must be sure of standards. For the purpose of this lab, the EG1003 standard will be 80% precision and accuracy. This means that the product has to achieve a percent accuracy of 80% and meet a tolerance of 1cm for distance and 10 degrees for angle. [1]

When taking measurements, the first step is to determine an average (Equation 1).

Equation 1: Average.

In this equation, Ap is the average, P1, P2, P3, ..., Pn are the results of the tests, and N is the number of tests performed.

The average is compared to the standard. Accuracy is a variable the must always be considered. The degree of accuracy required will allow the results to be verified. Engineers often work on projects that affect people's safety so it is critical that the solutions to the problems solved by technical professionals are accurate.

The comparison of the average to the standard is called accuracy, defined as Acc in Equation 2.

Equation 2: Accuracy.


Precision is the repeatability of a result, or how close the results are to each other, defined as Prec in Equation 3.

Equation 3: Precision.


A product can be accurate but imprecise, or precise but inaccurate (Figure 1). The goal is to achieve a combination of the highest accuracy and precision. In order for engineers to make a recommendation based on experimental test data, it is important to determine how a product compares to a standard. Engineers need these benchmarks to determine the quality of a product.

Figure 1: Accuracy and precision.


Equation 4: Percent accuracy.

In Equation 4, %Acc is the percent accuracy, Ps is the standard value, and Ap is the value measured.

Precision shows how precise a product is compared to the standard.

Adequate precision is determined by an acceptable tolerance, set by the manufacturer. In this lab, the precision of the robot must be compared to the tolerance allowed:

Distance Test:
Angle of Deviation Test:

Calculating percent accuracy and precision and then comparing those results to a standard determines the quality of the product.

Quality Improvement

Quality improvement is a process of analyzing a design and testing it through physical modeling, computer simulation, or mathematical modeling. Quality improvement ensures that a product will perform as expected and allows improvements to be made to the design.


  • Does the robot perform to standard?

Changes will be implemented after testing the initial code.

Reverse Engineering

Reverse engineering software involves reversing a program's machine code to obtain the original source code or determine the file structures the program uses. This is done when source code is lost or is not available. For example, when a project is reactivated after being dormant for years to add new features to a product, the original design documentation may have been lost. Also, when companies are writing a program that must interface with a second company's software, the second company may not have any incentive to cooperate by describing how the data in the files they use are organized, forcing the first company to deduce it on their own. Sometimes, this process is used to improve the performance of a program, to fix a bug, or to find a virus. When the source code is obtained in this way for any of these reasons, it is legal and necessary. Reverse engineering software to copy it constitutes a copy¬right violation and is illegal.[2]


Design Considerations

Carefully consider the lab objectives and what needs to be done to achieve them:

  • What made or will make the results, inaccurate or imprecise?

Center of Gravity

Center of Gravity is the place in a system or body (such as a robot) where the weight is evenly distributed and all sides are in balance. An example of the center of gravity is the middle of a seesaw when it is balanced.

You can think of a robot’s center of gravity as the “center position” of all the weight on the robot. Because Center of Gravity uses both weight and position, heavier objects have a greater effect than lighter ones in determining where the center of gravity is. For example, if your robot can collect, hold, and/or manipulate objects, those objects change the center of gravity as they are being manipulated because they add weight.

Figure 2: Change of Center of Gravity because of change of weight of the robot.

Likewise, pieces that are farther out have a greater effect than pieces that are near the middle of the robot. So, if your robot has an arm that lifts and/or reaches, its center of gravity changes with that movement.

Figure 3: Change of Center of Gravity because of dynamic parts.

Drivetrain Design


  • Two Motors
  • Four Wheels
  • Gears transmitting Power from the Motors to all Wheels


Turning Scrub is the friction that resists turning. This friction is created from the wheels dragging sideways on the ground as a robot (or another mobile vehicle) turns. The greater the Turning Scrub in a Drivetrain, the harder it is for a robot to turn. Turning Scrub in a basic Drivetrain can be easily managed and minimized in two ways:


Figure 4: Wheelbase Example.


Figure 5: Different Wheels Example.

EV3 Sensors

Sensor Basics

A sensor is a device that measures a specific value and is used as an input. Different properties can be measured by the EV3 sensors, such as light intensity, angle, or distance. The three sensors used in this lab are the light sensor, gyro sensor, and an ultrasonic sensor.

Light Sensor

The light sensor or color sensor (Figure 6) can measure reflected light intensity, color, and ambient light, and is useful when the robot has the option to follow a line or use differences in color to perform different actions, such as stopping when detecting a different color. If measuring color, the sensor outputs a value (0-7) that corresponds to a specific color. Measuring reflected light outputs a value (0-100) depending on the intensity of the light that is reflected. The ambient light works the same way as the reflected light, except it measures only the surrounding light. The light sensor, as well as all other sensors, can be found in the yellow category the Mindstorms software. The light sensor should be placed so that it is 2 cm, at max, away from whatever it trying to record.

Figure 6: Light sensor.

The type of value the sensor can measure can be changed by clicking the small box on the bottom left of the block (Figure 7).

Figure 7: Light sensor, value input.

Gyro Sensor

The gyro sensor can measure the degrees it turns or the rate at which it is turning. For example, if the robot is set to turn 90º using the gyro, the robot will keep trying to turn until 90º is reached, regardless of any bumps in its way (Figure 8). The gyro sensor should be placed parallel to the plane of the EV3 Brick.

Figure 8: Gyro sensor.

Ultrasonic Sensor


Figure 9: Ultrasonic sensor.

Switches and Loops

Switches and loops are used to tell the robot what actions to perform depending on the inputs from its surroundings, measured by the sensors.


A switch is an “if-else” statement: if the initial condition is true, the top action will occur, if false, the bottom action will occur. This block is used when the robot has to perform different actions depending on the input from the sensors (Figure 10).

Figure 10: Switch.


A switch will only run the code once, so if repeated action is desired, a loop must be used to repeat the switch’s statement. A loop continuously runs the code until the end statement occurs. The end statement can be determined with a sensor or hard-coded to a specific duration or rotations. Figure 11 shows an infinite loop.

Figure 11: Loop.

Materials and Equipment

  • A Mindstorms kit with pre-made robot
  • A computer with Mindstorms software
  • A mini-course with accuracy markings


Problem Statement

Evaluate two types of code for a robot by creating a line of code without the use of sensors, and then a separate line of code using sensors. For each trial, record the distance from the wall and angle of deviation from the center line. Test the first code by running four trials of Section 1 of the mini-course as marked on the physical course. Create a second line of code using switches and loops that incorporate the types of sensors found on the robot and features on the mini-course. Test the robot again with four trials of Section 1. This part of the procedure will have a total of 8 trials. Download the pre-made Datasheet and fill in the data for each trial.

Course Breakdown

The mini-course (Figure 12) has a designated Section 1 to complete the eight trials of the lab: one flat straight section of four tiles and a right turn with a wall at the end. The competitive trial will utilize the entire course. In Figure 8, Section 1 is marked in red.

Figure 12: Mini-course.

Part 1: Reverse Engineering

Upon receiving the pre-built robot, selected by the TA, analyze the design and performance of the robot by both physical inspection and basic testing (i.e. run the robot at least once to see how it works). Run the robot once on the ramp and once on the flat surface in Section 1. There are 5 basic problems in the pre-built robots. The problems are listed below:

  1. The Center of Gravity of the robot is too high. This will be observed when the robot is tested over the ramp. The high center of gravity does not allow the robot to traverse the hill.
  2. The incorrect Drivetrain is installed. The tires on the rear wheels of the robot cause it to slip when it tries to turn.
  3. The Light Sensor is positioned incorrectly. The Light sensor is more than 2 cm above the ground.
  4. The Gyro Sensor is installed in the incorrect orientation. It has been installed vertically which hinders its functioning.
  5. The Ultrasonic Sensor is also oriented incorrectly. The Ultrasonic sensor is installed in the z-axis orientation whereas the robot will need the sensor to record data in the x-axis.

The fixes for these problems are listed below:

  1. The Connectors connecting the EV3 Brick and the chassis can be shortened to lower the robot.
    1. Disconnect the Gyro Sensor
    2. Remove the angled connectors marked in the picture below
      Figure 13: Robot before modifications.
    3. Remove the right-angled connectors shown in the picture below
      Figure 14: Robot before modifications.
    4. Connect a 7-hole connector to the square frame as labeled in the picture below using the blue arrow:
      Figure 15: Robot before modifications.
    5. Connect the right-angled lego pieces as marked in the picture above using red arrows.
  2. The Tires can be attached to the rear wheels which will provide enough traction for a proper turn.
  3. The Light Sensor can be moved to a different mounting position to make it closer to the ground.
  4. The Gyro Sensor can be flipped to make it horizontal.
    1. Connect it as shown in the picture below
      Figure 16: Robot before modifications.
  5. The Ultrasonic Sensor can be oriented so that it’s horizontal instead of diagonal. This will be achieved when the Center of Gravity is brought down.

Part 2: Hardcoding

Based off of your observations, make design changes to the robot in order to run trials on the first section (Section 1) of the mini-course.

Every run, unless the robot goes off the course, counts as a trial. There is only one test run allowed after which all runs will be recorded as trials. When troubleshooting the code, please cross check the port number on the code and the port the sensor/motor is connected to before anything else.

Product Evaluation

Using the modified design, conduct four trials of the robot using a code without sensors to travel in a straight line across the first four tiles, turn 90 degrees to the right, and stop 5 cm from the wall. The values used in the sections of code below are only examples - the actual values must be determined through experimentation.

  1. Start the Mindstorms EV3 software
  2. Download the zipped folder containing the Mindstorms program.
  3. The hardcoding program should look like the one pictured below:
    Figure 17: Example hardcoded program
  4. Please read the comments before running the program
  5. Change the ports to the configuration on your robot
  6. Run a sample trial to understand the code
  7. Evaluate the number of rotations by measuring the total distance that the robot has to move for a certain block of code, and divide that by the perimeter of the wheel
  8. Change the values to the evaluated numbers
  9. Try to stop 5cm before the wall
  10. Run the program for four trials. For each trial, record the distance and angle using pre-made markings on the sides of the tile
  11. Distance is measured as distance from the wall for which the ruler on the side of the tile can be used. (Denote it as y)
  12. Angle of deviation is calculated in the following way:
    1. Measure deviation from the center of the wall. (Denote it as x)
    2. tan^-1 (x/y)
    3. If you are confused as to how to calculate angle of deviation, ask your TA for help.

Part 3: Sensors


Quality Improvement

Using the results of the original robot, incorporate the use of sensors in the robot's code. The following steps outline how to build a line-following code for the robot to stay on track. The values used in the sections of code below are only examples; the actual values must be determined through experimentation.

  1. Move to the Software Trials tab
  2. The program should look like this:
    Figure 18: Example code with sensors
  3. Please read the comments before running the program
  4. Change the ports to the configuration on your robot
  5. Run a sample trial to understand the code
  6. Using the port view shown below, set the readings on the Mindstorms code for the light sensors and the gyro sensors blocks to the appropriate values. Adjust Rotations as done in the previous part. Ask a TA for assistance if you don't know what values to use.
    Figure 19: Port view
  7. Take the same measurements as for Part 1: Harcoding
  8. Tabulate results neatly in the Datasheet.

Tabulation of Results

All data must be inputted into the Datasheet. From the datasheet, determine if the EG standards were met for accuracy and precision; recorded precision must be divided by 2 to get the corresponding tolerance:

Hardcode Accuracy %Acc Pass/Fail Precision Tolerance Pass/Fail
Distance Test
Angle of Deviation Test

Sensors Code Accuracy %Acc Pass/Fail Precision Tolerance Pass/Fail
Distance Test
Angle of Deviation Test

Part 4: Robot Competition

The robot competition consists of a single trial of the entire course to travel the most tiles as possible. Again, the values used in the sections of code below are only examples - the actual values must be determined through experimentation. The averages from the best type of coding (Part 1 vs Part 2) are also used to calculate the competition ratio.


The robot competition consists of attempting to travel the most amount of tiles possible in a single run. Only one trial counts as valid and must verbally be declared before the run starts.

  2. Notice that everything until the second loop is a replica of the Software Trial code. You only have to add the last loop. Ask a TA for assistance if you don't know how to do it.
    Figure 20: Full Competition Code

Competition Rules

  2. No changes in physical robot design
  3. No "re-tests"
  4. The trial used for the competition must be declared before the robot runs and cannot be disputed
  5. A robot counts as clearing a tile if it stops on the tile with at least 50% of the robot on the tile

Competition Ratio

The team with the highest competition ratio wins the competition. Adistance is the robot's average distance from the wall for four trials, Aangle is the robot's average angle of deviation for four trials, and Ntiles is the number of tiles cleared during the single competition run:



Individual Lab Report


  • Discuss product evaluation and the need for it
  • Discuss quality improvement and its importance
  • Explain why reverse engineering is important
  • Include examples of product evaluation, quality improvement, and reverse engineering
  • Discuss a standard, an average, accuracy, and precision
  • Discuss Different Design Considerations
  • Describe the importance of Center of Gravity and Drivetrain
  • Describe loops and switches and how they are useful in coding
  • Describe the light sensor, gyro sensor, and ultrasonic sensor used in the lab and their optimal position
  • Discuss the importance of tolerance and %Acc in determining product quality
  • Discuss the EV3 kit and software used
  • Describe Mindstorms programming for only the sensors coding portion
  • Describe all robot modifications
  • Compare the final code with sensors and final code without sensors; determine which is better. * * Substantiate the decision with data, observations, and other facts collected
  • Assess the techniques used in the testing process
  • Discuss better testing methods for the robot design
  • Recommend if any design improvements should be made


Team PowerPoint Presentation


  • If determinations were that the robot(s) did not meet the standard, what improvements could be made?
  • Why is product evaluation important?
  • Discuss why quality improvement is important
  • Discuss the importance of utilizing sensors