Skip to main content
Teacher Portal

Teacher Toolbox icon Teacher Toolbox - Activity Outline

  • This exploration will introduce students to basic programming of the V5 Clawbot's Claw Motor.

  • Learning to program the Claw Motor enables students to properly control how the V5 Clawbot grasps objects in its environment.

The V5 Clawbot is ready to grasp!

This exploration will let you start creating some cool projects that use the V5 Clawbot's claw to grasp objects.

  • VEXcode V5  Instructions that will be used in this exploration include:
    • ClawMotor.setPosition(0, degrees);
    • ClawMotor.spinFor(90, degrees);
    • ClawMotor.setTimeout (2, seconds);
  • To find out more information about the instruction, select Help and then select the question mark icon next to a command to see more information.

    VEXcode V5 with a drive for command typed in the workspace, and the Help for that command open to the right. The Help defines the command and gives information about how it is used.

  • Make sure you have the hardware required, your engineering notebook, and VEXcode V5 downloaded and ready.
Materials Required:
Quantity Materials Needed
1

VEX V5 Classroom Starter Kit  (with up-to-date firmware)

1

VEXcode V5

1

Engineering Notebook

1

Clawbot Template (Drivetrain 2-motor, No Gyro) example project

1

Aluminum can

Step 1: Preparing for the Exploration

Before you begin the activity, do you have each of these items ready? Check each of the following:

  • Are the motors plugged into the correct ports?

  • Are the smart cables fully inserted into all of the motors?

  • Is the Brain turned on?

  • Is the battery charged?

Teacher Tips icon Teacher Tips

Model each of the troubleshooting steps for the students.

Step 2: Start a New Project

Before you begin your project, select the correct template project. The Clawbot Template (Drivetrain 2-motor, No Gyro) example project contains the Clawbot's motor configuration. If the template is not used, your robot will not run the project correctly.

VEXcode V5 Toolbar with the File menu open and Open Examples highlighted in a red box. Open Examples is the fourth item in the menu beneath New Blocks Project, New Text Project, and Open.

Complete the following steps:

  • Open the File menu.
  • Select Open Examples.

VEXcode V5 example project selection window with the Templates filter selected at the top and the Clawbot drivetrain 2 motor no gyro project highlighted with red boxes to indicate which project to open.

  • Select and open the Clawbot Template (Drivetrain 2-motor, No Gyro) example project.
  • Since we will be programming to control the claw, rename your project ClawControl.
  • Save your project.
  • Check to make sure the project name ClawControl is now in the window in the center of the toolbar.

Project name dialog box in the VEXcode V5 Toolbar reads Claw Control and shows Slot 1 selected.

Teacher Tips icon Teacher Tips

  • Since this is a beginning activity with programming, the teacher should model the steps, and then ask the students complete the same actions. The teacher should then monitor the students to ensure that they are following the steps correctly.

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

  • Make sure that the students have selected the Clawbot Template (Drivetrain 2-motor, No Gyro) example project.

    You can point out to the students that there are several selections to pick from on the Examples page. As they build and use other robots, they will have a chance to use different templates.

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

Teacher Toolbox icon Teacher Toolbox - Stop and Discuss

This is a good point to pause and have the student groups review the steps that were just completed on starting a new project in VEXcode V5.

Step 3:  Program the V5 Claw to Open

We are now going to begin by programming the claw to open!

Start of a VEXcode V5 C++ project. The first command below the initialization section reads Claw motor dot set position (0, degrees) ; .

  • Write the ClawMotor.setPosition(); instruction as shown above in the programming area to set the starting position for the claw.

VEXcode V5 C++ project with two commands - Claw Motor dot set position (0, degrees) ; and Claw motor dot set timeout (2, seconds) ; .

  • Add the ClawMotor.setTimeout(); instruction as shown above.
    • Notice that this instruction appears before the ClawMotor.spinFor(); instruction. Its purpose is to set how long the Claw motor can run and stops it after that time. So even if the motor doesn't move a full 60 degrees, the project stops the Claw motor after two seconds have passed.

VEXcode V5 C++ project to set the claw position and motor timeout with a third command added that reads Claw motor dot spin for (reverse, 60, degrees) ; .

  • Write the ClawMotor.spinFor(); instruction as shown above to open the claw 60 degrees.

Slot selection open with slot 1 highlighted in a red box beside the project name dialog box in the VEXcode V5 Toolbar. The project name reads Claw Control.

  • Select the slot that the project will be downloaded to on the V5 Robot Brain by clicking on the boxed 1 icon to open up all available project slots and select the desired slot.

VEXcode V5 Toolbar with a red box around the green Brain Icon. The Brain icon is to the right of the Controller icon and to the left of the Download icon.

  • Connect the robot to your computer or tablet. The Brain icon in the toolbar turns green after a successful connection has been made.

VEXcode V5 Toolbar with a red box around the Download icon. The icons read from left to right, Controller, Brain, Download, Run, and Stop.

  • Click on the Download icon next to the Device Info icon to download the project to the V5 Robot Brain.

V5 Brain Home Screen showing the Claw Control project in slot 1 in the lower left corner. The row of icons above reads Drive, Devices, Settings, and VEX.

  • Check that the ClawControl project has downloaded to the brain in the slot you chose.

Teacher Toolbox icon Teacher Toolbox - Option to Model First

Model running the project in front of the class before having all of the students try at once. Gather the students in one area and position the Clawbot so that its claw can be seen by all. If you plan to demonstrate more than once, you can gently push the Claw closed between runs.
Tell the students it is now their turn to run their projects.

  • Run(in C++ or Python) the project on the Clawbot by making sure the project is selected and then press the Run button. Congratulations on creating your first project for moving the Claw!

Step 4:  Try This: Close the V5 Claw

Now that you have programmed the claw to open, you will now program it to close.

Close up top down image of the V5 Claw fully closed.

Image of the V5 Claw closed Now that you can open the claw, you will want to close it as well.

  • Return to your ClawControl project and add an additional ClawMotor.spinFor(); instruction to have the Claw Motor spin closed for 30 degrees. The claw should close half of the way because it originally spun open for 60 degrees.
  • Test that your revised project has the claw open for 60 degrees and then close for 30 degrees by downloading and running your ClawControl project.

Teacher Toolbox icon Teacher Toolbox - Solution

Previously, the Claw opened for 60 degrees. Included in that project was a set motor timeout instruction because it is an important practice to set a timeout when powering a manipulator that could have its movement restricted in some way. Setting a timeout prevents unnecessary wear on a motor.
The following is this step's solution:

Sample VEXcode V5 C++ solution with four commands that read, from top to bottom: Claw Motor dot set position (0, degrees); then Claw Motor dot set timeout (2, seconds); then Claw motor dot spin for (reverse, 60, degrees); and Claw motor dot spin for (forward, 30, degrees).

Step 5: Try This: Sequencing Multiple Movements

Close Up top down image of an open V5 claw with arrows pointing in and out indicating motion of the claw.

Image of the V5 Claw open with  Red arrows at the bottom of the image indicate the directions in which the claw can open and close, moving horizontally to grip or release objectsNot everything that you pick up with the claw will be the same size. Try opening the claw to different positions along the range of motion.

  • Spin the motor in order to:
    • Open for 70 degrees
    • Close for 20 degrees
    • Open for 10 degrees
    • Close for 30 degrees
    • Close for 25 degrees
  • If the Claw Motor starts at 0 degrees, how many degrees is the Claw Motor open at the end of the project?
  • Begin with the Claw Motor closed.

Teacher Toolbox icon Teacher Toolbox - Solution

The solution to this step is presented below.
The Claw Motor is still open at 5 degrees at the end of the project: 70 - 20 = 50 --> 50 + 10 = 60 --> 60 - 30 = 30 --> 30 - 25 = 5 degrees.

The project begins with a comment of Take the current position of the Claw as zero, then a command that reads claw motor dot set position (0, degrees);. Next a comment reads Set the Claw's timeout, with a command of Claw  motor dot set timeout (2 seconds);. Next are five spin for commands to spin the claw motor reverse 70 degrees, forward 20 degrees, reverse 10 degrees, forward 30 degrees, and forward 25 degrees.

Step 6:  Completing the Lock Tight Challenge

Close up side view of the V5 Claw grasping an aluminum soda can.

Closeup image of the V5 Claw holding an aluminum can The Lock Tight Challenge

  • Program the Clawbot to securely close the claw on an empty 12-ounce aluminum can without crushing the sides.
  • Have the Clawbot hold onto the can while it raises and lowers its arm for 45 degrees.
  • The Clawbot should then release the can and back away from it.
  • Start the challenge with an opened claw and an empty can within it.

Teacher Tips icon Teacher Tips

  • Have students start the challenge with an opened claw and an empty can within it.

  • If the can gets crushed or falls out of the claw, the challenge must be restarted after adjusting the project.

Teacher Toolbox icon Teacher Toolbox - Solution

Here is an example solution:

Sample VEXcode V5 C++ solution code starts with a comment of Take the current position of the Claw as zero and a command of Claw motor dot set position (0, degrees) ;. Next, a comment reads set the Claw's timeout with an attached command of claw motor dot set timeout (2, seconds) ; . Next are four spin for commands and a drive for command. They read, in order, Claw motor dot spin for (forward, 170, degrees) ; then Arm motor dot spin for (forward, 45, degrees); then Arm motor dot spin for (reverse 45, degrees) ; and Claw motor dot spin for (reverse, 150, degrees), and Drivetrain dot drive for (reverse, 150, mm).

  • The project sets the timeout, closes the claw around the can, lifts and lowers the can, releases it, and then backs away.
  • Programming Rubric  (Google Doc / .docx / .pdf )