Robotics · Lesson 1
RoboMaster: Navigate the Room
Make a robot drive a loop, read a card, and draw a figure 8 with nobody touching the controls
- Grades 7 to 12
- Time 3 class periods
- Difficulty Beginner
A parade starts and ends in the same place, and a robot can do that too, if you tell it exactly how. Over three days you will program a RoboMaster S1 to loop the whole room and stop on the spot where it began, change its lights to match whichever number card you hold up, and drive a figure 8 around two tables. You write every instruction. The robot follows every one of them, including the wrong ones, with total confidence.
What you'll learn
- How to program a robot to move by distance, time, and angle instead of steering it
- How to plan, test, and fix a route, changing one thing at a time
- How a robot uses its camera to read a vision marker and react to it
- Why a robot that does exactly what you said is not always doing what you meant
What you need
- A RoboMaster S1, charged, and a school iPad with the RoboMaster app. Mr. Krigger has both ready.
- Open floor, tape on the floor for the start spot, and two tables for Day 3
- The number cards (1 to 5) from the robot kit
- Paper and a pencil for sketching your route
Safety rules, read before you start
These are non-negotiable. Breaking them on purpose means you lose access to the robots and earn a 0 for the day.
- Say "clear" before you press Run. Check that no feet, bags, or hands are near the robot, then say it out loud and wait for your crew to answer.
- One person holds the Stop button every time the robot runs. Autonomous does not mean unsupervised.
- The robot lives on the floor. Never run it on a table, a chair, or near stairs. Never carry it while the wheels are spinning.
- Leave the blaster alone. This lesson never fires it. Do not fire it anyway to see what happens.
- Batteries charge at the charging station and nowhere else.
- Report damage, a burn smell, or an injury right away. You will not be in trouble for reporting something. These are the only RoboMasters this class has.
Your crew and the plan
You work in your competition crew, three or four people sharing one robot. Pass the iPad around. Every person writes and runs part of every program, because every person turns in their own code.
| Day | Mission | You finish with |
|---|---|---|
| Day 1 | The Circle: loop the room and come back | A robot that starts in one light color, drives around the room, and stops on the start spot in a different color |
| Day 2 | Number Lights: show a card, change the color | Numbers 1 to 5 each turn the robot a different color |
| Day 3 | The Figure 8: around two tables | A figure 8 that touches neither table and ends back on the start spot |
Day 1
The Circle
- Pick up your crew's robot and iPad from Mr. Krigger. Do not turn the robot on yet.
- Say the safety rules out loud as a crew, then pick who holds the Stop button first.
- Find the tape X on the floor. That is the start spot for every crew.
Goal: by the end of today your robot has started in one light color, driven a full loop around the room, and stopped back on the X in a different color.
Step 1: Wake it up and drive it
- Press the button on the battery to power on the robot.
- Open the RoboMaster app on the iPad and connect to the robot's own Wi-Fi network. It shows up in the iPad's Wi-Fi settings, and it is not the school network.
- You should see the robot's camera on the screen.
- Drive it with the on-screen joysticks. Forward, backward, turn, and then push sideways. That one is different.
Step 2: Open the code editor
- In the app, go to Lab, then create a new Scratch program. Scratch is code you build by snapping blocks together.
- Find the Chassis blocks. The chassis is the body that moves.
- Find the LED blocks. We will use these in a minute.
These are the blocks you will use most. The exact wording is how DJI's app writes them.
| Block | What it does |
|---|---|
set chassis to translate at (0)° for (1) m | Drives a set distance in the direction of the angle. 0° is forward. Longest allowed is 5 m. |
set chassis to translate at (0)° for (1) s | Same, but for an amount of time instead of a distance |
set chassis to rotate (right) at (0)° | Turns by that many degrees. Pick left or right in the block. |
set chassis translation speed to (0.5) m/s | Sets how fast it drives. Start slow. |
set chassis (all) LED color to (green) and effect to (solid) | Lights the robot in a color you choose |
wait (1) s | Pauses the program |
Step 3: Find out how it behaves
Before you plan a route, learn your robot. Build each test, run it, and write down what you saw. Mark the floor with tape so you can measure.
| Test | Question it answers |
|---|---|
| Translate at 0° for 1 m | Did it go one meter? Measure it. Run it three times. Does it land in the same place? |
| Rotate right 90° | Is it a right angle? Which way does a right turn go? |
| Translate at 90° for 1 m | Which way does 90° send it, left or right? Try −90° too. |
| Translate at 0° for 2 s | How far does two seconds take you? Is that the same as a distance block would give? |
Step 4: The Circle mission
Here is the job. Your program must:
- Start with the robot sitting on the tape X, with its LED set to a color you pick.
- Drive a complete loop around the room, around the furniture and the open floor Mr. Krigger marks out. The route is your design.
- Stop on the X. As close as you can get.
- End in a different color than you started. Set the LED to the new color as the last thing the program does.
- Run on its own. Nobody touches the joysticks.
Step 5: Build it a piece at a time
- Start the program by setting the starting color.
- Add the first side of the route. Run it. Where did the robot end up?
- Add the first turn. Run it again from the X. Did it turn where you wanted?
- Add the next side and repeat. Do not build the whole loop and then test it. You will not know where it went wrong.
- Last block: set the finish color.
A translate block drives at most 5 meters, so a long wall needs two blocks back to back. Here is the shape of a program for a rectangular room. Your numbers will be different, because your room is not a perfect rectangle.
set chassis (all) LED color to (green) and effect to (solid)
set chassis translation speed to (0.5) m/s
set chassis to translate at (0)° for (3) m
set chassis to rotate (right) at (90)°
set chassis to translate at (0)° for (4) m
set chassis to rotate (right) at (90)°
... more sides, until you are back at the X ...
set chassis (all) LED color to (red) and effect to (solid)
Step 6: It missed. Now fix it.
Your first run will not be perfect. That is normal. Every run tells you something, so use it.
| What happened | Try this |
|---|---|
| It turned too far | Lower the angle a little, like 87° instead of 90° |
| It did not turn enough | Raise the angle a little |
| It stopped short of the corner | Make that side a bit longer |
| It drives past the corner | Make that side a bit shorter |
| It drifts to one side on a straight run | Slow it down, or add a small correction turn after the straight part |
| It ends near the X but not on it | Adjust the last side. This is the hardest one, because every earlier error is in it. |
wait block between a move and a turn helps, test that and nothing else, and keep it only if it does.Check yourself: what do you fix first?
Your robot finishes the loop but stops about 40 cm past the X. The corners all look fine. What do you try first?
Mini lesson: why a robot drifts
Your robot has no map. It cannot see the room and decide where the wall is. It knows what you told it and roughly how far its wheels have turned, and that is all.
Wheels slip a little on a smooth floor and grip a little on a rough one. Each move is off by a small amount. The next move starts from that wrong spot and adds its own small error, so the errors pile up. That is why the last side of a long loop is the hardest to get right, and why your robot lands closer to the X when the route is shorter. Navigating by counting how far you have gone, with no map, is called dead reckoning. Sailors did it for centuries before anyone had GPS.
Before you leave today
A progress check, not the hand-in. The full list is in the Turn in tab.
- The Circle works: starts in one color, loops the room, stops on the X in a different color
- You took a screenshot of your finished Circle program
- The robot is powered off and back on the charging station, with the iPad
Day 2
Number Lights
- Finish the Circle first if it is not done. Number Lights is a separate program, so you can come back to the Circle after.
- Collect your robot, iPad, and the number cards 1 to 5. Say the safety rules again. Someone new holds the Stop button.
- Start a new Scratch program. Do not build this one on top of the Circle.
Goal: by the end of today you can hold up a number card from 1 to 5 and the robot lights up a different color for each one.
Step 1: A robot that can read
The RoboMaster has a camera and it can recognize vision markers: printed cards with a symbol on them. Number cards are one kind. Show it a card and it knows which one you showed it, with no joystick and no one telling it. The robot is not reading the word. It is matching a pattern, the same way a store scanner matches a barcode.
Step 2: Turn on marker detection
Build the first piece. You are looking for these blocks:
| Block | What it does |
|---|---|
(enable) (vision marker) identification | Turns on the robot's marker recognition. Put this first in your program. |
set vision marker identification distance to (1) m | How far away the robot looks. It works between 0.5 and 3 meters. One meter is a good start. |
when ___ identified | An event block. The blocks inside it run when the robot sees that marker. Open the dropdown and choose a number marker. |
Build one when event for the number 1, and inside it set the chassis LED to a color. Run the program and hold up the 1 card about a meter in front of the camera.
Step 3: All five numbers
Now do the rest. Numbers 1 through 5 each get their own color. You pick the colors. They only have to be five different ones, so that you can tell them apart from across the room.
| Show this card | The robot turns this color |
|---|---|
| 1 | Your choice |
| 2 | Your choice |
| 3 | Your choice |
| 4 | Your choice |
| 5 | Your choice |
Test each one by itself, and then flip through all five quickly. Does the robot keep up? Does the color change when you switch cards, and not before?
Step 4: Make it hard to fool
Real sensors fail in boring ways. Find your robot's limits before someone else does.
- Distance. Back away until it stops recognizing the card. How far is that? Does it match the distance you set?
- Light. Tilt the card toward a window, then into your own shadow. What happens?
- Angle. Hold the card a little crooked. How crooked can it be?
- Speed. Hold the card still for a second. A card waved past may never register.
Your five blocks are all right, but the robot never reacts to any card. What did you most likely forget?
Mini lesson: how a robot sees
A camera gives the robot a picture, which to a computer is a grid of tiny colored dots. Looking for a marker means searching that grid for a pattern the robot already knows. When it finds one, it tells your program, and your program decides what to do. That is the same path a self-checkout scanner, a license plate reader, and a phone's face unlock all follow. It is also why a dim room or a crooked card can fool it: the pattern in the picture stops matching the pattern in its memory.
Before you leave today
A progress check, not the hand-in. The full list is in the Turn in tab.
- Cards 1 to 5 each turn the robot a different color
- You took a screenshot of your Number Lights program
- You know how far away, and in what light, your robot recognizes a card
- Robot powered off and back on the charging station
Day 3
The Figure 8
- Mr. Krigger has set two tables on the floor. Do not move them. Everyone runs the same course.
- Collect your robot and iPad. Say the safety rules. Someone new holds the Stop button.
- Open your Circle program. You have already built half of what you need.
Goal: by the end of today your robot drives a figure 8 around the two tables, touches neither one, and ends back on the start spot.
Step 1: The mission
A figure 8 is two loops joined at a crossing. The robot goes around one table one way, passes back through the middle, and goes around the other table the opposite way.
- Start on the X, in the middle between the tables
- Loop the first table, cross back through the middle, loop the second table the other way
- Finish on the X, and touch neither table
Step 2: Why this is harder
In the Circle, every turn went the same direction. Here the robot turns one way on the first loop and the other way on the second. It also passes through the same spot twice, so any drift on loop one ruins the crossing and then loop two. Mistakes pile up in both directions at once.
Build it in four pieces and run each one before you add the next: loop one, the crossing, loop two, the finish. Your Circle program already knows how to loop. That is your starting point. You will change the turn directions for the second loop.
Step 3: Build and tune it
- Build loop one. Run it from the X. Does it clear the first table?
- Add the crossing. Run it. Is the robot lined up for the second loop?
- Add loop two with the opposite turns. Run it.
- Adjust until it finishes on the X without touching a table.
Your robot clears the first table, then clips the second one on its way around. Where do you look first?
Bonus task: Rainbow
Figure 8 done early, or just want a victory lap? Make the robot cycle through colors like a rainbow. This one is not graded. It is a bonus task you can do for the fun of it, and for the pleasure of showing Mr. Krigger.
- You already know the pieces: the LED block and the
waitblock. Set a color, wait, set the next one. - Too fast to see? Make the waits longer. Too slow to feel like a rainbow? Make them shorter.
- Want a harder version? Put it inside your Figure 8, so the robot changes color as it drives.
Before you leave today
A progress check, not the hand-in. The full list is in the Turn in tab.
- The Figure 8 works: around both tables, touching neither, ending on the X
- You took a screenshot of your Figure 8 program
- Optional: your Rainbow, shown to Mr. Krigger
- Robot powered off and back on the charging station
Base and Stretch
Base · everyone
All three missions working. The Circle: starts in one color, loops the room, stops on the X in a different color. Number Lights: cards 1 to 5 each give a different color. The Figure 8: around both tables, touching neither, ending on the X. Your own code for each, and a reflection.
Stretch · required for HS, bonus for MS
Pick two. Reverse Circle: make the Circle run the other way around the room by changing as little as you can, and say what you changed. Number moves: card 5 also makes the robot spin once, as well as changing the color. Card chooses the course: show a 1 before the Figure 8 to loop the left table first, or a 2 to loop the right table first, and the robot decides on its own.
What you turn in
Everything on this list comes out of something you already built. Your own work, from your own turn on the iPad.
- The Circle code. A screenshot of your whole Scratch program. Show every block.
- The Number Lights code. A screenshot of the whole program.
- The Figure 8 code. A screenshot of the whole program.
- If you did a Stretch: a screenshot of that code, and a sentence saying which one it is
- Reflection, 3 to 5 sentences: which mission was hardest, what you changed to fix it, and what you would do differently if you started again
Handing it in
Two things to hand in, not one
1 · The assignment
Your code screenshots and your reflection go here, as file uploads.
- Open RoboMaster: Navigate the Room in Schoology
- Click Submit Assignment
- Click Upload
- Select all your files at once, then Submit
2 · The exit ticket
A separate item in Schoology, taken in class. It is a short quiz on this lesson, and it is graded on its own.
You can do the assignment and the exit ticket in either order, but both have to be done.
figure8_code.png tells Mr. Krigger what he is opening. A file called IMG_4417.png does not.What comes next
You just built two of the entries for the RoboMaster Competition. The Circle is Precision Return. The Figure 8 is the Figure 8 Grand Prix, autonomous division. Every crew has to enter at least one autonomous event, and these two are guaranteed to be on the board.
So keep your programs. A crew that tunes its Circle again before the competition lands closer to the X, and the Number Lights work is the start of a robot that reacts to what it sees. Next up is RoboMaster Competition: Design the Game, where your crew designs an event of its own.
Vocabulary
| Term | What it means |
|---|---|
| Autonomous | The robot runs on its program with nobody touching the controls |
| Chassis | The body of the robot that moves, wheels included |
| Mecanum wheels | Wheels with angled rollers that let the robot slide sideways and diagonally |
| Scratch | Code you build by snapping blocks together instead of typing it |
| Translate | Move in a straight line, in any direction, without turning |
| Rotate | Turn in place |
| Dead reckoning | Working out where you are by counting how far you have gone, with no map or GPS |
| Vision marker | A printed card with a symbol or number on it that the robot's camera recognizes |
| Event block | A block that waits for something to happen, like seeing a card, and then runs the blocks inside it |
| Debugging | Finding and fixing what is wrong with your program |
| Iteration | Test, change one thing, test again, until it works |
When it goes wrong
The app will not connect to the robot.
My program runs but the robot barely moves.
It turns too far or not far enough.
It turned left when I wanted right.
It does not end on the X.
The LED does not change color.
My rainbow flashes by too fast to see.
wait block between colors longer. One second per color is easy to see. A tenth of a second is a blur.It never reacts to a number card.
It reacts to the wrong number.
when block and check which marker is chosen in its dropdown. It is easy to build two blocks for the same number.