Lesson 2: Using the Electromagnet
Building the Project
-
The first blue disk is 750 millimeters (mm) away from the starting point of the VR Robot on the Disk Mover Playground. Drag in a drive_for command beneath the first comment and set the parameters to drive forward 750 millimeters (mm), so your project looks like this:
def main(): # 1. Drive to the first blue disk drivetrain.drive_for(FORWARD, 750, MM) # 2. Pick up the first blue disk # 3. Drive in reverse to the blue goal # 4. Drop the blue disk in the blue goal
For Your Information
The distance between the starting point of the VR Robot and the first blue disk was estimated using the dimensions of each grid square. Each grid square on the Disk Mover Playground is 200 millimeters (mm) by 200 millimeters (mm).
Using this information, it can be estimated that the first blue disk is 800 millimeters (mm) from the center of the VR Robot. Since the Electromagnet is on the front of the VR Robot, the distance between the Electromagnet and the first blue disk may be slightly shorter than the 800 millimeters (mm).
-
Once the VR Robot reaches the first blue disk, the VR Robot must boost the Electromagnet using the energize command. Drag or type the energize command beneath the second comment, so that section of the project looks like this:
# 2. Pick up the first blue disk magnet.energize(BOOST)
-
Next, the VR Robot will drive in reverse back to the starting point with the blue disk. Drag or type a drive_for command beneath the third comment, so that section of the project looks like this. Set the drive_for command parameters to reverse 750 millimeters (mm).
# 3. Drive in reverse to the blue goal drivetrain.drive_for(REVERSE, 750, MM)
-
Once inside the blue goal, the VR Robot will need to release the blue disk. Drag or type an energize command beneath the fourth comment, and set the parameter to ‘DROP', so that section of the project looks like this:
# 4. Drop the blue disk in the blue goal magnet.energize(DROP)
-
Open the Playground Window if it is not already open. Be sure the Disk Mover Playground opens, and run the project.
-
The VR Robot picks up the first blue disk by energizing the Electromagnet, then drives in reverse back to the blue goal and drops the blue disk.
Select the Next button to continue with the rest of this Lesson.