Skip to main content
Teacher Portal

Teacher Toolbox icon Teacher Toolbox - The Purpose of this Section

Using the Vision Sensor effectively requires the students to be able to configure it and tune it depending on the environment that it is in. In the following activity, the students will learn how to do both.

For more information about programming the Vision Sensor with VEXcode V5, visit the help information in VEXcode V5 for Python, or view the V5 Section of the VEX Library.

The following is an outline of what your students will do in this activity:

  • Open the Detecting Objects (Vision) example project.

  • Configure the Vision Sensor.

  • Run the Detecting Objects (Vision) example project.

  • Discuss and Reflect.

  • Tune the Vision Sensor.

Teacher Tips icon Teacher Tips

If this is the student's first time using VEXcode V5, they can access many helpful articles in the VEX Library

Teacher Tips icon Teacher Tips - Using Autocomplete

Autocomplete is a feature in VEXcode V5 that predicts the rest of the command you are typing. As students are working in VEXcode V5, encourage them to use the Autocomplete feature to help with the Python syntax. You may notice an autocomplete function as you start to type the command. Use your “Up” and “Down” keys to select the name you want, then press “Tab'' or (Enter/Return) on your keyboard to make the selection. For more information on using Autocomplete check out this article.Image of the autocomplete feature in a Python project

Get the hardware required, your engineering notebook, and open VEXcode V5.

Materials Required:
Quantity Materials Needed
1

VEX V5 Classroom Starter Kit

1

VEXcode V5 (latest version, Windows, macOS)

1

Engineering Notebook

1

Configuring a Vision Sensor (VEX Library)

1

Tuning the Vision Sensor (VEX Library)

1

Detecting Objects (Vision) example project

This activity will give you the tools to use the Vision Sensor.

You can use the Help information inside of VEXcode V5 to learn about the commands.

Image of the Help in VEXcode V5 open in a Python project window

Step 1: Open an Example Project

VEXcode V5 contains many different example projects. You'll use one of them in this exploration.

Open the Detecting Objects (Vision) example project by completing the following steps:

  • Open the File menu.
  • Select Open Examples.

Image showing select open examples from the file menu in VEXcode V5

  • Use the filter bar at the top of the application and select "Sensing."

Image showing how to select sensing from the top toolbar of the example project window in VEXcode V5

Select and open the Detecting Objects (Vision) example project.

The image shows an icon representing Detecting Objects (Vision) with a visual of a sensor detecting an object. The icon features a square with an object being detected, symbolizing the use of a vision sensor for object recognition. Below the icon, the text

Save your project as Detecting Objects.

  • Check to make sure the project name Detecting Objects is now in the window in the center of the toolbar.

Teacher Tips icon Teacher Tips

  • Make sure that the students have selected Open Examples from the File menu.

  • Make sure that the students have selected the Detecting Objects (Vision) Example project. You can point out to students that there are several selections to choose from on the Open Examples page.

  • You can ask students to add their initials or the name of their group to the project name. This will help differentiate the programs if you ask the students to submit them.

  • Since VEXcode V5 has autosave, there is no need to save the project again after it has been saved for the first time.

  • If students need help saving, direct them to the one of these articles: 

Step 2: Configuring and Using the Vision Sensor

The image shows a user interface for a vision sensor system. In the center, there is a live camera feed displaying a hand holding a red object, labeled REDBOX. A white grid overlays the object to assist in identifying its position within the frame. On the right side of the screen, there are several options to set and clear color-coded boxes, including BLUEBOX, REDBOX, and GREENBOX, among others. The options for SIG_4 to SIG_7 are also present, with corresponding Set and Clear buttons. Below these, there's a Clear All button and a brightness adjustment option. The bottom of the interface shows various indicators such as version number, connection status, and additional information.

Open the previously saved Detecting Objects (Vision) example project.

How is the Vision Sensor being used in this project? Predict what will happen when the project is run and write down the predictions in your engineering notebook.

The image displays a Python program designed for a VEX V5 robot. The program imports necessary libraries from VEX and begins with defining three events: check_red, check_blue, and check_green. The program then defines three functions: has_blue_callback, has_red_callback, and has_green_callback. Each function checks if there is a blue, red, or green object detected by the vision sensor and prints the corresponding message on the V5 Brain's screen. The has_blue_callback function clears row 1 on the screen, sets the cursor, and takes a snapshot using the vision sensor to detect a blue object. If a blue object is found, the program prints

  • Download and run the project. Place different colored objects in front of the Vision Sensor and observe the robot's behavior. Record in your engineering notebook how your prediction was different or correct compared to what you actually observed from the project.

Teacher Tips icon Teacher Tips

The three colored objects do not have to be cubes, they can be any relatively small green, red, and blue object.

Motivate Discussion icon Motivate Discussion - Answers

Facilitate a classroom discussion to have the students share what they predicted this project will do in their engineering notebook, and also reflect on how to configure the Vision Sensor.
Facilitate the discussion by asking the following questions:

  1. What are the steps for configuring the Vision Sensor?

  2. What does the if else structure do?

  3. What would happen to how the Vision Sensor detects objects if we changed rooms?

Answers will vary:

  1. The students should note that the object name will have to be decided. The object should be placed in the frame of the Vision Sensor and stilled using the "Freeze" button. The color will then be selected and configured using the "Set" button. The students should outline the steps listed in this article.

  2. The if else structure runs the instructions inside the first or second parts of the if else based on the Boolean value reported. More information on how to use this instruction can be found in the Help information.

  3. If the Vision Sensor was asked to detect objects in a different environment, the lighting could change and the colors of the objects could look different. This may make it difficult for the Vision Sensor to detect objects.

Extend Your Learning icon Extend Your Learning - Configure more objects

Choose two other colored objects to configure, possibly white, purple, yellow, etc...

If the students need help, refer them to the Help information or the Configuring a V5 Vision Sensor article.

Step 3: Tuning the Vision Sensor

Often times an object is configured to be recognized by the Vision Sensor in one environment, for example, in a classroom. When the Vision Sensor is then taken into a different environment, such as a competition setting, the object may not be recognized by the Vision Sensor. This is often due to a change in lighting after the Vision Sensor has already been configured. To solve this problem, you may have to tune your Vision Sensor.

The image shows a user interface for a vision sensor system. In the center, there is a live camera feed displaying a hand holding a red object, labeled REDBOX. A white grid overlays the object to assist in identifying its position within the frame. On the right side of the screen, there are several options to set and clear color-coded boxes, including BLUEBOX, REDBOX, and GREENBOX, among others. The options for SIG_4 to SIG_7 are also present, with corresponding Set and Clear buttons. Below these, there's a Clear All button and a brightness adjustment option. The bottom of the interface shows various indicators such as version number, connection status, and additional information

Open the previously saved Detecting Objects (Vision) example project.

How will tuning the Vision Sensor affect how well it can detect objects? Take the Clawbot to a different part of the room with more or less light.

The image shows a VEX robot equipped with various components, including sensors and a claw mechanism, positioned on a gray surface. The robot appears to be designed for a task involving object manipulation, as it is facing a large purple cube placed in front of it. The robot's structure is made of metal beams, and it is equipped with omni-directional wheels for enhanced maneuverability. The claw mechanism at the front of the robot is likely intended for grabbing or moving the purple cube as part of a robotics challenge or task

  • Download and run the project. Place different colored objects in front of the Vision Sensor and observe the robot's behavior. Document in your engineering notebook how well the Vision Sensor detects objects. Does the Vision Sensor need tuned after it changed locations?
  • Tune the Vision Sensor as necessary. Test the Vision Sensor after it has been tuned to determine if it can detect objects better and make adjustments as needed.

Motivate Discussion icon Motivate Discussion - Reflecting on the Activity

Q: Did the Vision Sensor detect objects as you expected it to?
A: Answers will vary; however, the goal of this question is to promote cognitive thinking. Students should note that the Vision Sensor's ability to detect objects can change depending on the environment and light.

Q: Why is it important to be able to tune the Vision Sensor as needed?
A: While answers may vary, a common response should be that if a robot uses a Vision Sensor and is taken to a competition or even used in a game or challenge, how well the robot performs will depend on the accuracy of the Vision Sensor. Tuning it is important for accuracy.

Extend Your Learning icon Extend Your Learning - Multiple Objects

Ask the students to run the Detecting Objects (Vision) project and place more than one of the configured objects in front of the Vision Sensor. What happens? Ask them to document their findings in their engineering notebook.
Now, ask the students to place one configured object and one unknown or not configured object in front of the Vision Sensor. What happens? Ask them to document their findings in their engineering notebook.

Ask the students before testing it, what would happen if they placed three configured objects in front of the Vision Sensor? Ask the students to write down their predictions before testing it. Ask them to record their observations after testing it.

Facilitate a discussion on what the students predicted and observed.

Facilitate the discussion by asking:

  • What were the differences between one, two, and three objects?

  • Would you adjust the project in any way for recognizing multiple objects?