0% found this document useful (0 votes)
42 views

Loop There It Is

The document provides instructions for programming loops to repeat robotic actions using the VEX V5 Clawbot. It discusses using repeat blocks and forever blocks to repeat behaviors a set number of times or indefinitely. An example project uses a repeat block to have the Clawbot drive forward and turn four times. Students are challenged to program the Clawbot to drive in a square while opening and closing its claw and raising and lowering its arm before each turn.

Uploaded by

Ethan Benoit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Loop There It Is

The document provides instructions for programming loops to repeat robotic actions using the VEX V5 Clawbot. It discusses using repeat blocks and forever blocks to repeat behaviors a set number of times or indefinitely. An example project uses a repeat block to have the Clawbot drive forward and turn four times. Students are challenged to program the Clawbot to drive in a square while opening and closing its claw and raising and lowering its arm before each turn.

Uploaded by

Ethan Benoit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 94

Loop, There It Is!

Learn how to program loops to get your robot grooving!


Discover new hands-on builds and
programming opportunities to further
your understanding of a subject matter.
The Completed Look of the Build

Completed VEX V5 Clawbot

The VEX V5 Clawbot is an extension of the VEX V5 Speedbot that can be programmed to
move around and interact with objects.
Parts Needed: Part 1
Can be built with:
 VEX V5 Classroom Starter Kit
Parts Needed: Part 2
Build Instructions
The green icon indicates that the build needs to be flipped over (upside down).
Only one of the two sub-assemblies made in this step is used right now. The other will be used later in step 9.
Make sure your Smart Motors are oriented in the correct direction (screw holes facing the outside of the build and
the shaft hole towards the inside).
Make sure your Smart Motors are oriented in the correct direction (screw holes facing the outside of the build and
the shaft hole towards the inside).
The green icon indicates that the build needs to be rotated (180 degrees).
The blue call out shows what the orientation of the Robot Brain should be if the build were flipped right side up.
Make sure the 3 wire ports on the Robot Brain are facing the V5 Radio!
The green call outs indicate which port on the Robot Brain to plug each device into using their respective cable.
Be sure to make two assemblies in this step!
This step adds onto the two assemblies started in Step 29.
Make sure to add this to only one of the two sub-assemblies you just made.
Make sure the 12- tooth gear is installed on the right side of the claw.
Make sure that the port on the Smart Motor is facing the right side of the robot when the claw is installed (the
same side as the V5 Radio).
Build Instruction Tips
Check the Appendix for information on how to use the new Hex Nut Retainers.
Exploration
Now that you've finished the build, test what it does. Explore your build and then answer
these questions in your engineering notebook.

Where is the pivot point (the point the robot rotates about) for this robot build?

 Make a prediction and then manually move the 4” wheel on one side forward while at the
same time moving the 4” wheel on the opposite side backwards at the same rate.

After manually moving both wheels, now describe where the pivot point is. How would the
pivot point of the robot change if the Build design was changed so both of the 4” Omni
Wheels (steps 14-17) were also powered by motors, making all 4 wheels powered?

 Make a prediction and then manually move both wheels on one side forward while at the
same time moving both wheels on the opposite side backwards at the same rate.

After manually moving the wheels again, now describe where the pivot point is. Explain how
a robot’s pivot point could change its behavior.
Test your build, observe how it functions,
and fuel your logic and reasoning skills
through imaginative, creative play.
Robot Repetition

Assembly line robots must perform actions repeatedly

Using Loops to Repeat Robotic Actions


Robots and computers are very good at consistency when performing actions multiple times.
Computers use repetition to perform millions of calculations per second with incredible
consistency. Since robots are built to interact with their environment and perform tasks
precisely, they can be effectively used to repeat behaviors.

Behaviors to be repeated are grouped in programming structures called loops. The number
of times and how fast they repeat depend on many factors that the programmer can specify.

Here are some examples of where repetition can be useful:


 Performing routine tasks multiple times
 Checking certain conditions multiple times to check for changes
Programming Loops - VEXcode V5
Blocks
The V5 Clawbot is ready to move!

You can use the Help information inside of VEXcode V5 Blocks to learn about the blocks. For
guidance in using the Help feature, see the Using Help tutorial.

Hardware/Software Required:

Quantity Hardware/Other Items

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

1 VEXcode V5 Blocks (latest version, Windows, MacOS,


Chromebook)

1 Engineering Notebook

1 Using Loops (Tutorial)

1 Repeating Actions (No Gyro) example project

1. Let's start programming with loops.


 Start by watching the Using Loops tutorial video.

 Open the Repeating Actions (No Gyro) example project.

 View the opened example project.


Do the following in your engineering notebook.
 Predict what the project will have the Clawbot do. Explain more than the fact that the
project repeats.
What is it repeating? What is the Clawbot doing?
 Write your prediction, but do not break the short project into more than two parts.

 Save, download, and run the Repeating Actions (No Gyro) example project.

 For help, see the tutorial in VEXcode V5 Blocks that explains how to Download and Run a
Project.

 Check your explanations of the project in your engineering notebook and add notes to
correct them as needed.
2. Run the project and observe the robot.

Look at the Repeating Actions (No Gyro) project (on the right) again. This project will repeat
the forward and then turn behavior four times. A repeat block is used when you want to
use a set of behaviors for a certain number of times. If the repeat block is replaced with a
forever block, the robot would repeat the forward and then turn behaviors forever.

In the project on the left, a sensor's input is used to determine when to begin turning. The
project on the right uses a fixed Drivetrain distance to determine when to begin turning.

In order to continually check a sensor's input, an if/else block is used together with a forever
block. In the project on left, the robot will turn right when the BumperH sensor is pressed,
otherwise the robot will drive forward forever if the BumperH sensor is not pressed. To
continually check the BumperH sensor's value, the if/then block is within a forever block.

The above project on the left is a practical use-case of a structure that repeats forever - using
forever blocks and if/then blocks together. Imagine a self-driving sweeper that continues to
drive forward until it runs into a wall or object, then turns before continuing to drive.
3. The Squared Loops Challenge!

 Have your Clawbot drive in a square.


 Before each turn, the claw must be opened and closed, and the arm must be raised and
lowered.
 The Clawbot cannot drive along a side of the square more than once.
 You can use the Repeating Actions (No Gyro) example project as a starting point but save
it as SquaredLoops before making any changes.

In your engineering notebook, plan the following:


 Plan out your solution and predict what each block in your project will have the Clawbot
do.
 Download and run your project to test it before submitting it.
 Make changes to the project as needed and take notes about what was changed during
testing.
Programming Loops - VEXcode V5
Text
The Clawbot V5 is ready to move!

This exploration will give you the tools to be able to start creating some cool projects that use
loops.

 VEXcode V5 Text instructions that will be used in this exploration:

o Drivetrain.driveFor(forward, 300, mm);


o Drivetrain.turnFor(right, 90, degrees);
o ClawMotor.spinFor(reverse, 70, degrees);
o ArmMotor.spinFor(forward, 360, degrees);
o while (true) {}
o repeat (4) {}
o wait(5, seconds);

To access additional information, right click on a command name in your workspace to see
help for that command.

Make sure you have the hardware required, your engineering notebook, and VEXcode V5
Text downloaded and ready.
Hardware/Software Required:

Quantity Hardware/Other Items

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

1 VEXcode V5 Text (latest version, Windows, MacOS)

1 Engineering Notebook

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


project

1. Let's start programming with loops.


 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.

 Select File and Open Examples.


 Scroll through the different Example projects. These projects demonstrate a variety of
actions your Clawbot can perform. Select and open the Clawbot Template (Drivetrain 2-
motor, No Gyro) example project.
 Name the project RepeatingActions and select Create.

 Type the following code:

Look over the project and then do the following in your engineering notebook.
 Predict what the project will have the Clawbot do. Explain more than the fact that the
project repeats.
What is it repeating? What is the Clawbot doing?
 Write your prediction, but do not break the short project into more than two parts.

 Save, download, and run the Repeating Actions project.

 Check your explanations of the project in your engineering notebook and add notes to
correct them as needed.
2. Run the project and observe the robot.

Look at the Repeating Actions project (on the right) again. This project will repeat the forward
and then turn behavior four times. A "repeat" loop structure is used when you want to use
a set of behaviors a certain number of times.

If the repeat structure is replaced with a "while" loop structure, the robot will repeat the
forward and then turn behaviors "while" the condition is true. You can also set the condition
to "true" to have the "while" loop continue forever.

In the project on the left, a sensor's input is used to determine when to begin turning. The
project on the right uses a fixed Drivetrain distance to determine when to begin turning.

In order to continually check a sensor's input, an "if/else" statement is used together a


"while" loop. In the project on left, the robot will turn right when the "BumperB" sensor
is pressed, otherwise the robot will drive forward forever if the "BumperB" sensor is not
pressed. To continually check the BumperB sensor's value, the "if" statement is within a
"while true" loop.

The above project on the left is a practical use-case of a structure that repeats forever - using
while loops and if statements together. Imagine a self-driving sweeper that continues to
drive forward until it runs into a wall or object, then turns before continuing to drive.
3. The Squared Loops Challenge!

 Have your Clawbot drive in a square.


 Before each turn, the claw must be opened and closed, and the arm must be raised and
lowered.
 The Clawbot cannot drive along a side of the square more than once.
 You can use the RepeatingActions project from above as a starting point but save it as
SquaredLoops before making any changes.

In your engineering notebook, plan the following:


 Plan out your solution and predict what each instruction in your project will have the
Clawbot do.
 Download and run your project to test it before submitting it.
 Make changes to the project as needed and take notes about what was changed during
testing.
Become a 21st century problem solver
by applying the core skills and concepts
you learned to other problems.
Robots in Manufacturing

Robots working in a manufacturing plant.

Factory Robots
Factories first began using modern industrial robots in the early 1960’s. These robots could
do the dirty, dull, and dangerous jobs that were previously completed by humans. Since then,
factories all over the world have invested millions of dollars to develop and build robots that
can manufacture their products quickly and efficiently.

Factory robots are always being improved upon as new technology is expanded. New metals
and materials allow robots to be used in high pressure or high temperature environments.
Usually separated to keep human workers safe in case of an accident, factory robots are
being made from new “softer” materials. These materials, such as rubber and plastic, can
help reduce injuries in a robot/human collision. With the introduction of artificial intelligence
and sensors, factory robots can be “taught” new ways of delivering these products overnight
and adapt their movements in real time. This allows more productivity and precision.
Factory robots are used in the production of many products, but the top three robotic jobs in
manufacturing are:
 Drilling
 Welding
 Painting and Sealing
Controllers and Loops - VEXcode
V5 Blocks

Controllers and Loops


In competitions, teams must manipulate their robots wirelessly with controllers. The controller
is programmed to update the robot based on input from the user. Loops are used in the
project so that the robot repeatedly checks for updated input information. Loops allow the
project to rapidly check which buttons have been pressed, or how far joysticks have been
pushed. Once checked, this information is quickly relayed to the robot so that it responds
quickly to the controller's instructions.

The following image shows the Tank Drive example project from VEXcode V5 Blocks. The
forever loop in this project checks the positions of Axes 2 and 3 forever in order to set the
velocity of the motors.

Tank Drive example project from VEXcode V5 Blocks

Loops are important even for autonomous programming without a controller. A loop helps to
simplify and organize repeated commands within a project.
Controllers and Loops - VEXcode
V5 Text

Controllers and Loops


In competitions, teams must manipulate their robots wirelessly with controllers. The controller
is programmed to update the robot based on input from the user. Loops are used in the
project so that the robot repeatedly checks for updated input information. Loops allow the
project to rapidly check which buttons have been pressed, or how far joysticks have been
pushed. Once checked, this information is quickly relayed to the robot so that it responds
quickly to the controller's instructions.

The following image shows the Tank Drive example project from VEXcode V5 Text. The
forever loop in this project checks the positions of Axes 2 and 3 forever in order to set the
velocity of the motors.

Tank Drive example project from VEXcode V5 Text


Loops are important even for autonomous programming without a controller. A loop helps to
simplify and organize repeated commands within a project.
Is there a more efficient way to come to
the same conclusion? Take what you’ve
learned and try to improve it.
Prepare for the Groove Machine
Challenge

Dance floor set up

Prepare for the Groove Machine Challenge!


In the Groove Machine Challenge, you will break up into groups and program your robot to
go through a dance routine for a dance-off using your knowledge of loops.

For the challenge, you will need to clear a space on the floor large enough for a V5 Clawbot
to move around for a dance routine without bumping into anything. A 1x1 meter area is
recommended to give each Clawbot adequate space for moving.
Design, Develop, and Iterate on
your Project - VEXcode V5 Blocks
Answer the following questions in your engineering notebook as you design your project.

 What type of robot dance will you create? Explain with details.
 What types of loops will you use and why?
 What steps will you follow to test the dance? Explain with details.

In order to help you plan, click here for a few example dance moves that you might include in
the Clawbot's dance.

Follow the steps below as you create your project:

 Plan out the dance using drawings and pseudocode.


 Use the pseudocode you created to develop your project using VEXcode V5 Blocks.
 Open the Clawbot (Drivetrain 2-motor, No Gyro) example project.

 Save your project as GrooveMachine.

 Run your project to test it often and iterate on it using what you learned from your testing.
 Share your final project with your teacher.

If you're having trouble getting started, review the following in VEXcode V5 Blocks:
 Example projects
 Using Loops tutorial

 Previous versions of your project


 The Help feature to learn more about the blocks
The Groove Machine Challenge -
VEXcode V5 Blocks

V5 Clawbot with its arm up and claw open

The Groove Machine Challenge


In this challenge, you will break up into teams and program your robot to go through a dance
routine using your knowledge of loops. Your teacher will set a time limit for developing/testing
the dance and a time limit for the length of the dance. Everyone not on the competing head-
to-head dance-off teams will judge the dances and vote on the team that they think is best.

Rules:
 Each Clawbot will dance one-at-a-time within the 1x1 meter area.
 The dancing continues until the Stop button on the Brain's screen is pressed to stop the
project from running.
 The arm must be raised and lowered.
 The claw must open and close.
 The Clawbot must turn left and right.
 The Clawbot must drive forward and in reverse.
 The project needs to be stopped immediately if the Clawbot collides with anything or falls
over. That is a losing dance.
Design, Develop, and Iterate on
your Project - VEXcode V5
Text
Answer the following questions in your engineering notebook as you design your project.

 What type of robot dance will you create? Explain with details.
 What types of loops will you use and why?
 What steps will you follow to test the dance? Explain with details.

In order to help you plan, click here for a few example dance moves that you might include in
the Clawbot's dance.

Follow the steps below as you create your project:

 Plan out the dance using drawings and pseudocode.


 Use the pseudocode you created to develop your project using VEXcode V5 Text.
 Open the Clawbot Template (Drivetrain 2-motor, No Gyro) example project.

 Name the project GrooveMachine and select Create.

 Run your project to test it often and iterate on it using what you learned from your testing.
 Share your final project with your teacher.

If you're having trouble getting started, review the following in VEXcode V5 Text:
 Example projects:

 To access additional information while creating a program, right click on a instruction in


your work space to see additional information about it.

 Review previous versions of your RepeatingActions project to assist with creating your
new one.
The Groove Machine Challenge -
VEXcode V5 Text

V5 Clawbot with its arm up and claw open

The Groove Machine Challenge


In this challenge, you will break up into teams and program your robot to go through a dance
routine using your knowledge of loops. Your teacher will set a time limit for developing/testing
the dance and a time limit for the length of the dance. Everyone not on the competing head-
to-head dance-off teams will judge the dances and vote on the team that they think is best.

Rules:
 Each Clawbot will dance one-at-a-time within the 1x1 meter area.
 The dancing continues until the Stop button on the Brain's screen is pressed to stop the
project from running.
 The arm must be raised and lowered.
 The claw must open and close.
 The Clawbot must turn left and right.
 The Clawbot must drive forward and in reverse.
 The project needs to be stopped immediately if the Clawbot collides with anything or falls
over. That is a losing dance.
Understand the core concepts and how
to apply them to different situations.
This review process will fuel motivation
to learn.
Review - VEXcode V5 Blocks

1. True or False: Controllers use loops in order to check for input responses from the
buttons and joysticks.
o True
o False

2. Loops are .
o documents the data types available
o conditionally executes a group of statements
o statement(s) to handle errors that occur
o programming structures that repeat behaviors

3. True or False: In VEXcode V5 Blocks, the repeat and forever loop blocks repeat any
blocks inside of it, and for the number of times specified. Blocks inside of the repeat and
forever loop blocks are run in order from top to bottom.
o True
o False

4. In the following project, how many times does the robot turn right?
o The robot will turn right 9 times because it is set to turn 90 degrees.
o The robot will turn right one time because there is only one turn for block in
the project.
o The robot will turn right 4 times because the repeat block is set to repeat 4
times.
o The robot will turn right 5 times because the drive for block moves 5mm.

5. True or False: Robots are not good at repetitive tasks like humans are because any
slight error in their programming increases with each repetition.
o True
o False
Review - VEXcode V5 Text

6. True or False: Controllers use loops in order to check for input responses from the
buttons and joysticks.
o True
o False

7. Loops are .
o documents the data types available
o conditionally executes a group of statements
o statement(s) to handle errors that occur
o programming structures that repeat behaviors

8. True or False: In VEXcode V5 Text, the repeat and forever loop structures repeat
any instruction inside of it, and for the number of times specified. Instructions inside of
the repeat and forever loop structures are run in order from top to bottom.
o True
o False

9. In the following project, how many times does the robot turn right?
o The robot will turn right 9 times because it is set to turn 90 degrees.
o The robot will turn right one time because there is only one turn for instruction
in the project.
o The robot will turn right 4 times because the repeat structure is set to repeat
4 times.
o The robot will turn right 5 times because the drive for instruction moves
5mm.

10. True or False: Robots are not good at repetitive tasks like humans are because any
slight error in their programming increases with each repetition.
o True
o False
Additional information, resources, and materials.
Using the 1 Post Hex Nut Retainer
w/ Bearing Flat

1 Post Hex Nut Retainer w/ Bearing Flat

Using the 1 Post Hex Nut Retainer w/ Bearing Flat


The 1 Post Hex Nut Retainer w/ Bearing Flat allows shafts to spin smoothly through holes in
structural components. When mounted, it provides two points of contact on structural
components for stability. One end of the retainer contains a post sized to securely fit in the
square hole of a structural component. The center hole of the retainer is sized and slotted to
securely fit a hex nut, allowing a 8-32 screw to easily be tightened without the need for a
wrench or pliers. The hole on the end of the Retainer is intended for shafts or screws to pass
through.

To make use of the retainer:


 Align it on a VEX structural component such that the end hole is in the desired location,
and the center and end sections are also backed by the structural component.
 Insert the square post extruding from the retainer into the structural component to help
keep it in place.
 Insert a hex nut into the center section of the retainer so that it is flush with the rest of the
component.
 Align any additional structural components to the back of the main structural component, if
applicable.
 Use an 8-32 screw of appropriate length to secure the structural component(s) to the
retainer through the center hole and hex nut.
Using the 4 Post Hex Nut Retainer

4 Post Hex Nut Retainer

Using the 4 Post Hex Nut Retainer


The 4 Post Hex Nut Retainer provides five points of contact for creating a strong connection
between two structural components using one screw and nut. Each corner of the retainer
contains a post sized to securely fit in a square hole within a structural component. The
center of the retainer is sized and slotted to securely fit a hex nut, allowing a 8-32 screw to
easily be tightened without the need for a wrench or pliers.

To make use of the retainer:


 Align it on a VEX structural component such that the center hole is in the desired location,
and each corner is also backed by the structural component.
 Insert the square posts extruding from the retainer into the structural component to help
keep it in place.
 Insert a hex nut into the center section of the retainer so that it is flush with the rest of the
component.
 Align any additional structural components to the back of the main structural component, if
applicable.
 Use an 8-32 screw of appropriate length to secure the structural component(s) to the
retainer through the center hole and hex nut.
Using the 1 Post Hex Nut Retainer

1 Post Hex Nut Retainer

Using the 1 Post Hex Nut Retainer


The 1 Post Hex Nut Retainer provides two points of contact for connecting a structural
component to another piece using one screw and nut. One end of the retainer contains a
post sized to securely fit in the square hole of a structural component. The other end of the
retainer is sized and slotted to securely fit a hex nut, allowing a 8-32 screw to easily be
tightened without the need for a wrench or pliers.

To make use of the retainer:


 Align it on a VEX structural component such that both ends are backed by the structural
component and positioned to secure the second piece.
 Insert the square post extruding from the retainer into the structural component to help
keep it in place.
 If the retainer is being used to secure two structural components, insert a hex nut into the
other end of the retainer so that it is flush with the rest of the component. If used to secure
a different type of component, such as a standoff, it may be appropriate to insert the screw
through this side.
 Align any additional components to the back of the main structural component, if
applicable.
 If the retainer is being used to connect two structural components, use an 8-32 screw of
appropriate length to secure the structural components through the hole and hex nut. If
used to connect a different type of component, such as a standoff, secure it directly or with
a hex nut.
Engineering Notebooks

Alexander Graham Bell's notebook entry from a successful experiment with his first telephone

An Engineering Notebook Documents your Work


Not only do you use an engineering notebook to organize and document your work, it is also
a place to reflect on activities and projects. When working in a team, each team member
will maintain their own journal to help with collaboration.

Your engineering notebook should have the following:


 An entry for each day or session that you worked on the solution
 Entries that are chronological, with each entry dated
 Clear, neat, and concise writing and organization
 Labels so that a reader understands all of your notes and how they fit into your iterative
design process

An entry might include:


 Brainstorming ideas
 Sketches or pictures of prototypes
 Pseudocode and flowcharts for planning
 Any worked calculations or algorithms used
 Answers to guiding questions
 Notes about observations and/or conducted tests
 Notes about and reflections on your different iterations
Example Dance Moves - VEXcode
V5 Blocks
Clap Your Hands!

The Sprinkler

Hands in the air!


Example Dance Moves - VEXcode
V5 Text
Clap Your Hands!

The Sprinkler
Hands in the air!

You might also like