Lesson Goals:
- Introduction to the Riders platform.
- Learn to launch a simulation.
- Learn how to control the camera in the simulation window.
- Learn to manage split windows and setup a good development environment.
- Learn to open a python code file.
- Control a robot with basic commands: move and turn.
- Apply this knowledge to solve some puzzles.
Introduction:
- Personal introductions to the students.
- Demonstrate how to open Riders and open the lesson.
- Ask students to read the introduction and help anyone who is unable to open the lesson.
- Discuss that Riders allows students to work with python and ROS which are real systems used for real robots. We want to motivate the students with the knowledge that what they learn here is directly applicable in the field of robotics.
Checkpoint 1: Run a simulation
- Discuss that the first thing we’ll do is learn to launch a simulation.
- Demonstrate how to open the Riders Project Tree button.
- Demonstrate launching a simulation by clicking Start.
- Discuss that everyone should see the simulation window open and point out the robot which is yellow.
- Discuss that they should see the first checkpoint marked in their lesson. The checkpoint indicates they have accomplished a skill and are ready to proceed.
Controlling the Camera
- Discuss that the simulation window has a camera which can be controlled with the mouse/track pad. Demonstrate panning and zooming and ask the students to try this. It will be useful for many lessons.
Split Windows
- Discuss that the window setup can be modified using split screen options. Windows can be split by right clicking tabs at the top, selecting options such as Split Right, and then dragging tabs to the new panes.
- Demonstrate how to arrange windows to show the lesson plan and the simulation window.
- Discuss the importance of this as students will benefit from mastering this option as they proceed. For many lessons it will be useful to have several windows organized and visible at the same time.
Opening the Python code file
- Discuss that students will now start writing some python code to control the robot.
- Demonstrate opening the Node: user_code to open a python code file.
- Demonstrate how to split arrange windows so you can see the code, simulation, and the documentation.
Debugging
- Demonstrate how to open the log output by right clicking 'Node: user_code' and selecting Watch Node Logs. This can show errors in the syntax of the code.
Checkpoint 2: Move the Robot
- Demonstrate adding a first line of code:
robot.move_forward()
- Discuss that students should try adding the code and then run the simulation again (click Start).
- Discuss that students should see the robot move forward one square and stop.
Checkpoint 3: Rotate the Robot
- Demonstrate adding a second line of code:
robot.turn_right()
- Discuss that students should now see the move forward followed by the turn right.
Checkpoint 4: Solve the Red Puzzle
- Discuss that students should now try to solve the 1st puzzle, which is to collect all of the red equipment.
- Mention the status bar which shows the battery level. The robot will stop moving if they run out of battery. They will get three more energy units if they pick up a battery. They use one unit for each turn and move.
- Do not demonstrate solving the Red puzzle since this will be a crucial test of understanding. Students need to be able to add additional lines of code, run the simulation, and fix their code if necessary. Here they just need to swap the order of the lines they already have.
Solution:
robot.turn_right() robot.move_forward()
Checkpoint 5: Solve the Red+Green Puzzle
- Discuss that students who complete the Red puzzle can proceed with trying the Red+Green puzzle. They must collect all Red and Green objects.
Solution:
robot.move_backward() robot.move_backward() robot.turn_right() robot.move_forward() robot.move_forward() robot.turn_left() robot.move_forward() robot.move_forward() robot.turn_left() robot.move_forward() robot.move_forward() robot.move_forward() robot.turn_right() robot.move_forward() robot.move_forward()
Checkpoint 6: Solve the Red+Green+Blue Puzzle
- Note that checkpoints are usually essential skills but this lesson is introductory and the harder puzzles are really more for fun and to generate some positive atmosphere. This final puzzle only has one solution. If the students don’t solve it there is no harm in continuing with the next lesson.
Solution:
robot.move_forward() robot.move_forward() robot.move_forward() robot.turn_right() robot.move_forward() robot.move_backward() robot.move_backward() robot.turn_right() robot.move_forward() robot.move_forward() robot.move_forward() robot.turn_left() robot.move_forward() robot.move_forward() robot.move_forward() robot.turn_right() robot.move_forward() robot.move_forward() robot.turn_right() robot.move_forward() robot.move_forward() robot.move_backward() robot.turn_left() robot.move_forward() robot.turn_right() robot.move_forward() robot.move_forward() robot.move_forward()
Challenge
- Optionally mention the challenge problem, which is to write an automated algorithm to find the puzzle solution. Discuss that students probably won’t know how to write code to solve this challenge yet, but they will be learning these skills over the next few months. They can start thinking about how this algorithm might work without doing any actual coding yet. Advanced students may wish to try it now. They will need to setup a data structure which stores the locations of the all the objects.