Skip to main content

Lesson 1: What is a Bumper Sensor?

In this Lesson, you will learn what a sensor is and why you would use sensors with a VR Robot. The first sensor that you will learn about is the Bumper Sensor. You will learn how the Bumper Sensor works and how to use the VR Robot Bumper Sensors in a VEXcode VR Python project.

Learning Outcomes

  • Identify that the Bumper Sensor is a type of switch that can report when pressed or not pressed.
  • Identify that the Bumper Sensor can be used to cause a VR Robot action when pressed or not pressed.
  • Identify that the left_bumper.pressed and right_bumper.pressed are commands that report a Boolean value about the Bumper Sensor.
  • Describe why the Bumper Sensor would be used in a project.

Apply

Sensors are essential to robotics. For a VR Robot to truly be considered a robot, it must be able to sense and interact with its environment. This is commonly referred to as the Sense → Think → Act decision loop.

A diagram that shows a continuous cycle with three stages connected by arrows. The first stage, labeled Sense, includes the text Sense the Environment, indicating the process begins by gathering information from the surroundings. Moving to the next stage, labeled Think, the text reads Make Decisions Based on Sensor Data from Environment, suggesting this step involves processing the sensed information to make decisions. The final stage, labeled Act, includes the text Carry Out Decisions, showing that actions are taken based on the decisions. The arrows create a loop, returning the process back to the Sense stage, representing an ongoing cycle of sensing, thinking, and acting.

A VR Robot uses sensors to collect data from its surroundings (Sense),  make decisions based on this information (Think) and turn that information into instructions for behaviors (Act).

Sensors enable a VR Robot to interact with its environment, and allow the user to create more dynamic projects. These dynamic projects require a VR Robot to interact and respond to changing environments.

The Bumper Sensor

In this Unit, you will use the Bumper Sensor, a sensor that can detect physical contact. The Bumper Sensor is used to inform a VR Robot when it has made contact with an object or wall. A VR Robot can then use the reported information from the Left or Right Bumper Sensor to make decisions.

The VR Robot has two Bumper Sensors located on the front.

A front view of the VR Robot. The two bumper sensors on its front are highlighted with red boxes.

A Bumper Sensor is a switch that reports if it is pressed or not pressed.

  • The Bumper Sensor will report a sensor value of True when the Bumper Sensor is pressed.
  • The Bumper Sensor will report a sensor value of False when the Bumper Sensor is not pressed.

The Bumper Sensor is pressed by walls in the Wall Maze Playground, or by the outer walls surrounding other Playgrounds.

The VR Robot in the Wall Maze Playground. The robot is looking at a wall in front of it, indicating that it will need to turn to be able to move forward.

Read the Bumper Sensor - Robot Features - VEX VR article for detailed information on how the Bumper Sensor works.

Bumper Pressed Commands

The Bumper Sensor is used to determine if the VR Robot is touching an object or wall. That data can then be used in a project so the VR Robot can make a decision when the Bumper Sensor is pressed. 

Use the left_bumper.pressed and right_bumper.pressed commands in a text project to check the condition of the Bumper Sensor.

Left_bumper.pressed and right_bumper.pressed are Boolean reporter commands, that report True if the Bumper is pressed, and False if it is not pressed.

Two bumper pressed commands are written on two rows to show the difference between left or right bumper. On the top row, the command reads right underscore bumper dot pressed (). On the bottom row, the command reads left underscore bumper dot pressed ().

The left_bumper.pressed and right_bumper.pressed commands are typically used with a Control structure, like a while loop, so that the VR Robot can use the data from the Bumper Sensor to make a decision. You will learn more about while loops in the next Lesson. 

The Bumper Sensor and the Wall Maze Problem

Thinking about the Wall Maze Problem, the goal is to have the VR Robot drive while the Bumper Sensor is not pressed. When the Bumper Sensor is pressed, the VR Robot has reached a wall, and then needs to stop or turn to continue on in the maze. 

In the following example, the VR Robot will drive forward from the starting location, until the Left Bumper is pressed when it reaches the wall opposite. Once the Left Bumper is pressed, the VR Robot will stop driving. 

Video file

You will notice that the Dashboard displays the value the Bumper Sensor is reporting in real time as the project is run. When the Bumper Sensor is not pressed, the value is reported as False.

# Add project code in ""main"
def main():
	while not left_bumper.pressed():
		drivetrain.drive(FORWARD)
		wait(5, MSEC)
	drivetrain.stop()

# VR threads - Do not delete
vr_thread(main())
The Wall Maze Playground showing the Playground's dashboard and the VR Robot is at the starting position, not touching any of the walls. The Bumper Sensors in the playground dashboard are highlighted with a red box, reporting False, saying that they are both not being pressed.

When the Bumper Sensor is pressed, and the VR Robot is against the wall, the value is reported as True.

# Add project code in ""main"
def main():
	while not left_bumper.pressed():
		drivetrain.drive(FORWARD)
		wait(5, MSEC)
	drivetrain.stop()

# VR threads - Do not delete
vr_thread(main())
The Wall Maze Playground showing the Playground's dashboard when the front of the VR Robot is touching a wall. The Bumper Sensors in the playground's dashboard are highlighted with a red box, reporting True, saying that they are both being pressed.

You can use the Dashboard at any time, to help visualize sensor data as your project is running. Note, the Dashboard can be hidden and reopened at any time, as shown in this video. In the video clip below, the hamburger menu in the upper left corner of the Playground window is selected to display the Dashboard button below it. The Dashboard button is then selected and the Dashboard opens. This process is repeated to close the Dashboard.

Video file

Questions

Please select a link below to access the lesson quiz.

Google Doc / .docx / .pdf