0% found this document useful (0 votes)
12 views7 pages

AA Fundamentals - Thinking VEX

Uploaded by

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

AA Fundamentals - Thinking VEX

Uploaded by

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

ROBOTC

Fundamentals

Thinking About Programming Programmer & Robot

In this lesson, you will learn about the roles of the programmer and the robot, and how the two
need to work together in order to accomplish their goals.

Robots are made to perform useful tasks. Each one is designed to solve a specific problem,
in a specific way.

Robotic Tractor
Problem:
Drive safely through a field
which may contain obstacles

Solution:
Move towards the destination,
making small detours if any
obstacles are detected

Labyrinth Robot
Problem:
Get through the maze.

Solution:
Move along a predetermined
path in timed segments.

© Carnegie Mellon Robotics Academy / For use with VEX® Robotics Systems Thinking about Programming • 1
ROBOTC

Fundamentals

Thinking about Programming Programmer & Robot (cont.)

Let’s take a closer look at the Labyrinth robot. How does it find its way through the maze?
How does it know how to do that?

Problem ?????? Goal Reached

Creating a successful robot takes a team effort between humans and machines.

Role of the Robot


The robot follows the instructions
it is given, thereby carrying out the
2 17.75” plan.

15.25”
58.5”

11”

26”

14” 1

17”

Role of the Programmer


The human programmer identifies
the task and plans a solution, then
explains to the robot what it needs
to do to reach the goal.

© Carnegie Mellon Robotics Academy / For use with VEX® Robotics Systems Thinking about Programming • 2
ROBOTC

Fundamentals

Thinking about Programming Programmer & Robot (cont.)

The human and the robot accomplish the task together by dividing up the responsibilities.
The human programmer must come up with the plan and communicate it to the robot. The robot
must follow the plan.

Human Robot

Problem Create plan Follow plan Goal Reached

Because humans and robots don’t normally speak the same language, a special language must be used
to translate the necessary instructions from human to robot. These human-to-robot languages are called
programming languages. Instructions written in them are called programs. ROBOTC is just one of
many such programming languages that humans use to talk to machines.

Human Robot

Problem Create plan Write program Follow program Goal Reached

End of Section.
Humans and robots communicate by using programming languages such as ROBOTC. A human
who writes a program is called a programmer. The programmer’s job is to identify the problem
that the robot must solve, create a plan to solve it, and turn that plan into a program that the
robot can understand. The robot will then run the program and follow its instructions to perform the
task.
A robot can only follow its program. It cannot think for itself! Just as it can be no stronger than it
is built, the robot can be no smarter than the program that a human programmer gave it. You, as
programmer, will be responsible for planning and describing to the robot exactly what it needs to
do to accomplish its task.

© Carnegie Mellon Robotics Academy / For use with VEX® Robotics Systems Thinking about Programming • 3
ROBOTC

Fundamentals

Thinking About Programming Planning & Behaviors

In this lesson, you will learn how thinking in terms of “behaviors” can help you to see the logic
behind your robot’s actions, and break a big plan down into practical parts.

Behaviors are a convenient way to talk about what a robot is doing and what it must do. Moving
forward, stopping, turning, looking for an obstacle… these are all behaviors.

1 1

Complex Behavior Basic or Simple Behavior


Some behaviors are big, like “solve the maze.” Some behaviors are small, like “go forward for 3
seconds.” Big behaviors are actually made up of
these smaller ones.

As you start programming, you should also start thinking about the robot’s actions in terms of
behaviors. Recall that as programmer, your primary responsibilities are:
• First, to come up with a plan for the robot to reach the goal.
• Second, to translate that plan into a program that the robot can follow.
The plan will simply be the sequence of behaviors that the robot needs to follow. The program will
be those behaviors translated into the programming language.

© Carnegie Mellon Robotics Academy / For use with VEX® Robotics Systems Thinking about Programming • 4
ROBOTC

Fundamentals

Thinking about Programming Planning & Behaviors (cont.)

1. Examine problem
2 To find a solution, start by examining the problem.

Here, the problem is to get from the starting point


(1) to the goal (2).

2 Follow the pa 2. Broad solution


th
to reach the Try to see what the robot needs to do, at a high
goal
level, to accomplish the goal.

Having the robot follow the path shown on the


left, for example, would solve the problem.
You’ve just identified the first behavior you need!
Write it down.

3. Break solution into smaller behaviors


2 Follow the pa Now, start trying to break that behavior down into
th
to reach the smaller parts.
goal

Following this path involves moving forward,


Go forward 3
seco
nds then turning, then moving forward for a different
Turn left 90º
Go forward 5 distance, then turning the other way, and so on.
seconds Each of these smaller actions is also a behavior.
Turn right 90º
Go forward 2
seconds
Turn right 90º Write them down as well. Make sure you keep
Go forward 2
seconds them in the correct sequence!
1

4. Break into even smaller pieces


Follow the If you then break down these behaviors into even
pathGo to smaller pieces, you’ll get smaller and smaller
forw
rear
acdhfor behaviors with more and more detail. Keep track
th 3 seconds
Go foe goal of them as you go.
rward 3 second
Turn left 90º s
Go fo
Turwrnard Eventually, you’ll reach commands that you can
on 5lefset co
mond
tor
s
TurnTurig
rnhton90 express directly in the programming language.
rigº ht motor
Go fo
Wrwait ard
3 sec on ds
2 seconds
1 For example, ROBOTC has a command to turn on
TurnTurig
rnhtoff90lef
º t motor
Turw
Go fo rnard
off right motor one motor. When you reach a behavior that says
2 seconds
to turn on one motor, you can stop breaking it
down because it’s now ready to translate.

© Carnegie Mellon Robotics Academy / For use with VEX® Robotics Systems Thinking about Programming • 5
ROBOTC

Fundamentals

Thinking about Programming Planning & Behaviors (cont.)

Large behavior Smaller behaviors ROBOTC-ready behaviors

Follow the pa Go forward fo


to reach the
th
3 seconds
r 1. Turn on left motor
goal
2. Turn on right motor
Go forward 3 Turn on left mo
seconds tor
Turn left 90º
Go forward 5
Turn on right
motor 3. Wait 3 seconds
seconds Wait 3 seconds
Turn right 90º
Go forward 2
Turn off left mo
Turn off right
tor 4. Turn off left motor
seconds motor
Turn right 90º
Go forward 2
seconds 5. Turn off right motor
Turn left 90
º
6. Reverse left motor
Reverse left mo
tor
Step by step
Turn on right
Wait 0.8 secon
motor 7. Turn on right motor
ds
1. Start with a large-scale Turn off left mo
behavior that solves Turn off right
tor 8. Wait 0.8 seconds
motor
the problem.
9. Turn off left motor
Go forward fo
2. Break it down into r
5 seconds
smaller pieces. Then 10. Turn off right motor
break the smaller
pieces down as well. Turn on left mo
Turn on right
tor
motor
11. Turn on left motor
3. Repeat until you Wait 5 seconds
have behaviors that 12. Turn on right motor
are small enough
for ROBOTC to 13. Wait 5 seconds
understand.
...

When all the pieces have reached a level of detail


that ROBOTC can work with – like the ones in the 1. Turn on left motor
2. Turn on right motor
“ROBOTC-ready behaviors” list above – take a look
3. Wait 3 seconds
at the list you’ve made. These behaviors, in the order 4. Turn off left motor
and way that you’ve specified them, are the plan 5. Turn off right motor
that the robot must follow to accomplish the goal.
Because these steps are still written in English, they Simple pseudocode
Your list of behaviors to perform in a specific
should be relatively easy for the human programmer order are a simple form of pseudocode.
to understand.
As the programmer becomes more experienced, the
organization of the behaviors in English will start to if (the light sensor sees light)
{
include important techniques from the programming
turn on left motor
language itself, like if-else statements and loops. hold right motor still
This hybrid language, halfway between English and }
the programming language, is called pseudocode.
It is an important tool in helping to keep larger
Later pseudocode
programs understandable. As your programming skills grow, your
pseudocode will include more complex logic.
But it will still serve the same purpose: to help
you find and express the necessary robot
behaviors in simple English.

© Carnegie Mellon Robotics Academy / For use with VEX® Robotics Systems Thinking about Programming • 6
ROBOTC

Fundamentals

Thinking about Programming Planning & Behaviors (cont.)

End of Section
Start with a very large solution behavior and break it down into smaller and smaller sub-behaviors.
This gives you a logical way to figure out what the robot needs to do to accomplish its task.
Recording the robot’s behaviors in English is the first step toward writing good pseudocode. It
allows you to easily review these behaviors and their organization as you prepare to translate them
into program code.
The only step remaining is to translate your behaviors from English pseudocode into the ROBOTC
programming language.

© Carnegie Mellon Robotics Academy / For use with VEX® Robotics Systems Thinking about Programming • 7

You might also like