Lesson 2: Driving for Distance - Moving Forward and in Reverse
In this Lesson, you will create a VEXcode VR project that uses forward and reverse Drivetrain commands to knock down the first castle in the Castle Crasher Playground!
- Identify how to use the [Drive for] block to drive the VR Robot a specific distance.
- Identify how to change the parameter in the [Drive for] block to move the VR Robot forward and reverse.
- Identify how to use the [Set drive velocity] block to set the speed of the drivetrain.
- Identify the range of values used in the [Set drive velocity] block.
Create a New Project
A VEXcode VR project must be created in order for a VR Robot to move forward in order to collide with the first castle in the Castle Crasher Playground, then drive in reverse to return to the starting position.
Follow these steps to create a new VEXcode VR project.
- Launch VEXcode VR at vr.vex.com.
- Once you launch VEXcode VR, a new project will automatically start.
Name Your Project
- To name your project, select the project name box.
- Enter the new project name Unit2Lesson2, and select “Save."
Drive Forward and in Reverse
Use the [Drive for] block to program a VR Robot to move forward to knock over the first castle on the Castle Crasher Playground.
- Drag the [Drive for] block into the workspace and place under the [When started] block.
- Select the “Open Playground” button to launch the Castle Crasher Playground if it is not already open.
- Check to make sure that the Castle Crasher Playground is open.
- If a different Playground opens, change to the Castle Crasher Playground. To change Playgrounds, select the Select Playground button.
- Select Castle Crasher in the Select Playground menu.
- Select the “Start” button to test the project.
- The VR Robot will drive forward for 200mm on the Castle Crasher Playground. Note that the VR Robot did not touch the center castle. The parameters in the [Drive for] block need to be adjusted so the VR Robot can drive further.
- Select the “Reset” button to reset the Playground and move the VR Robot back to the starting position.
Select the Next button to continue with the rest of this Lesson.