Two knobs, three shapes — and your first drive to somewhere that isn't straight ahead.
Student PIN:
Project
Coding Project 5
Strand
Coding
Phase
Make It Move
Time
One class period
What You Are Doing
Finding out how a robot turns, learning the three shapes a turn can have, and driving from your starting box to the spilled cubes.
Mission Anchor
Mission 12 — Restack the Freight (approach only — you will finish it in Project 8)
Before You Start
Project 4 — you need your straight-driving power values and your starting position method.
What You Need
Before you start: type your PIN in the box at the top of the page. Your teacher gave you this number. When you finish, press Download to save a local copy of your answers. This does not turn in your work automatically; give the downloaded file to your teacher.
Try It — Break the Straight Line
In Project 4 you worked hard to make your robot drive straight. Now you are going to ruin it on purpose — and pay close attention while you do.
Start a new project called Turns. Put in your straight-driving program from Project 4, but keep msleep(3000) the same for every single run.
Then change one wheel only. Leave the left wheel at your usual power. Change the right wheel to each value below, run it, and describe the path the robot took.
⚠ Floor, Not Table
These runs go in circles and curves. Do this on an open floor with nothing in the way — not on a table, not on the field.
Right wheel power
What path did the robot take?
same as left
70
55
20
10
0
−50
−100
What did your data tell you?
When the two power numbers are…
The robot…
close together
far apart
one is zero
opposite signs
At the end of Project 3 you predicted what a robot would do with one wheel forward and one wheel backward. Were you right?
Learn It — Two Knobs, Three Shapes
You only have two things to adjust, and they do completely different jobs.
Code / part
What it means
motor power
Sets the shape of the path. The difference between the two numbers decides whether the robot goes straight, curves gently, curves hard, or spins on the spot.
msleep() time
Sets how far along that path the robot travels. It does not change the shape at all — only how much of it you get.
The Two Rules You Just Discovered
The closer the two power numbers are, the straighter the robot goes.
The further apart they are, the sharper the curve.
Everything else in this project is those two sentences applied on purpose.
The three shapes
, where both wheels go the same direction at different speeds.
The robot sweeps a wide arc, like a car going around a bend.
Sharpness comes from how different the two numbers are.
motor(0,50);motor(3,25);
, where one wheel drives, the other sits still. The robot swings around the stopped wheel — like ring around the rosie.
More power on the moving wheel means a faster swing, not a tighter one.
motor(0,50);motor(3,0);
, where the wheels go opposite directions. The robot spins in place without moving forward or backward at all.
Also called a pivot or spin turn. This is what you use for precise angles.
motor(0,50);motor(3,-50);
Which One Should You Use?
Zero radius when you need to point a different direction without giving up your position — the usual choice on a crowded field.
Radius when you want to travel and turn at the same time, like driving around an obstacle.
One-wheel when you want to swing around something you are already next to.
Friction Matters More Than You Think
Two moving wheels fight friction better than one moving wheel does. A one-wheel turn asks a stopped wheel to skid sideways, so it is the least repeatable of the three. If a turn will not come out the same twice, try the same turn as zero radius instead.
Two spilled cubes form a scoring stack — one spilled cube is another spilled cube. Both cubes must originate from the spilled cube area. Edge-to-face or corner-to-face contact does not satisfy this definition for Mission 12.
The scoring stack remains intact and the lower cube of the stack is touching the black line.
Scores
One spilled cube is another spilled cube.
A robot is supporting one or both cubes while the relationship exists.
The scoring stack exists and the lower cube is touching the black line.
Does Not Score
Two spilled cubes touching side-by-side.
A spilled cube stacked on a cube that did not originate from the spilled cube area.
The stack no longer exists at final scoring.
The upper cube is touching black line but the lower cube is not.
Do It — Learn to Aim
Step 1 — Drive a big circle
Create a new project called Circles. Put a chair in the middle of an open floor.
Write a program that drives your robot in one big circle all the way around the chair, without it. Use only one set of motor(), msleep(), and ao() — no stopping and restarting.
Left power
Right power
msleep
Step 2 — Drive a tight circle
Swap the chair for something small — a tissue box works. Circle that instead, same rule: one set of commands.
Left power
Right power
msleep
Compare your two sets of numbers. What did you change to make the circle smaller?
Step 3 — Try all three shapes
Run each one and record what the robot actually does.
Turn type
My powers
What it did
Radius
One-wheel
Zero radius
Which of the three moved the robot the least distance across the floor? Why does that matter on a crowded field?
Step 4 — Build a 90° turn
Create a new project called Right Angle. Use a zero radius turn and find the msleep() that gives you a 90° turn.
Keep both powers the same the whole time. Change only the time.
Try
msleep
Too far, not far enough, or right?
1
2
3
4
5
Test One Step at a Time
Get the turn right on its own before you attach it to anything else. one command is easy. Debugging a whole run to find out which command was wrong is not.
Step 5 — Prove it with a square
Here is the honest test of a 90° turn: do it four times and see if you end up where you started, facing the way you started.
Drive forward, turn 90°. Repeat four times total.
If your robot did not close the square, was each turn too much or too little? How could you tell?
A small error in one turn becomes a big error after four. This is why turning by time is hard — and why Project 11 replaces it with counting.
Step 6 — Drive to the spilled cubes
Onto the field. New project called Approach 12.
Start in your starting box, exactly the way you decided in Project 4. Drive out, turn, and stop next to the spilled cube area — close enough and square enough that a claw could pick a cube up.
Write your plan as first:
// 1. Drive forward out of the starting box
// 2. Turn toward the spilled cubes
// 3. Drive up to them
// 4. Stop
Move
Left power
Right power
msleep
Forward
Turn
Approach
Step 7 — Run it five times
Same rule as Project 4. One good approach is luck.
Run
Did it arrive in a position a claw could work from?
1
2
3
4
5
Which part of the run was least reliable — the drive out, the turn, or the final approach?
Score It — Checkpoint
No points yet — Mission 12 does not score until something gets stacked. What you have built is the half of the mission that has to work before the other half matters.
My turning numbers
Every project from here uses these. Write them down properly.
Setting
Value
zero radius turn — left power
Zero radius turn — right power
msleep for a 90° turn
msleep for a 180° turn
msleep for a 45° turn
You worked out 90° by testing. Did doubling it give you a good 180°? Did halving it give you a good 45°?
Match the turn to the job
The robot needs to…
Which turn type?
Face the other way without leaving its spot
Curve around a cone while still moving down the field
Swing its front end around a cube it is already beside
Make a small heading correction while driving straight
Can you do it again?
Think about it
Your square test almost certainly did not close perfectly. Where did the error come from — was the robot doing the wrong thing, or was your program asking for something it cannot deliver?
A teammate’s robot turns 90° perfectly on the carpet but on the field mat. Nothing in the program changed. What happened?
You now have a robot that gets to the right place and points the right way. What is the next thing it needs before Mission 12 can actually score?
Next
In Project 6 — Bulldoze Run, you put driving and turning together to score four missions at once — and you do it all without a claw, by pushing.