CS Level 1 - VEXcode VR Python

Unit 4 - Navigating a Maze

# Lesson 3: Adding Drivetrain Commands to Solve the Wall Maze

### Solving the Wall Maze Problem

Now that the VR Robot has driven to the letter ‘A’ as well as to the number ‘2’ on the Maze Wall Playground, how would you create a project where the VR Robot drives to other locations, such as to the letter ‘B?’ So far, we have used data from the Bumper Sensor to drive to a wall, then turn to move to the next wall. To navigate to the letter 'B', we need to be able to move the VR Robot to a point in the middle of the maze surface, so that it can get on a different path towards our destination.

If the code only contained drive and turn_for commands, the VR Robot could get “stuck” in the number ‘2’ section of the Wall Maze, because it would continue to turn left or right without ever backing up.

Instead, we can estimate the distance from the last wall the VR Robot touched to where it needs to turn. We can then use Drivetrain commands, like drive_for and turn_for, with the while loops and Bumper Sensor data in our project to solve the maze!

• Begin by modifying your previous project or create a new project to match this base project.
• The project above begins to drive the VR Robot to the letter ‘B,’ however, in order for the VR Robot to do so, it would first need to back up and then turn left.
• Edit the code by removing the stop command and replacing it with drive_for and turn_for commands.
• We can estimate that the VR Robot needs to drive in reverse for approximately 300 millimeters (mm). First, set the parameters of the drive_for command to “reverse” for 300 millimeters (mm).
• Then, set the parameters of the turn_for command to turn left 90 degrees.
• Launch the Wall Maze Playground if it is not already open and run the project.
• Adding these commands will orient the VR Robot in the right direction to drive the letter ‘B.’

• Select the “Reset” button to reset the Playground and move the VR Robot back to the starting position.
• Now that the VR Robot is oriented in the correct direction, add the following commands to drive the VR Robot to the letter 'B' on the Wall Maze Playground.
• Launch the Wall Maze Playground if it is not already open and run the project.
• The VR Robot will now drive to the letter ‘B’ on the Wall Maze Playground.

## Mini Challenge

In this challenge, the VR Robot should navigate to the number ‘3’ in the Wall Maze Playground using multiple while loops, Drivetrain commands, and the Bumper Sensor.

Follow these steps to complete the mini challenge:

• Watch the solution video and review how the VR Robot should drive in order to complete the mini challenge.

• Create a project by adding or removing the necessary commands to the Unit4Lesson3 project to drive the VR Robot to the number ‘3’ on the Wall Maze Playground.
• Start the project to test if it works.
• If the project is not successful, edit and try again. Continue this process until the challenge is complete.
• Once the VR Robot successfully drives to the number ‘3’ on the Wall Maze Playground, save the project.

Congratulations! You have successfully completed the Wall Maze Challenge!