During the spring semester of 2017, I taught the Pioneers in Engineering Robotics 2-unit class in which I prepared approximately 40 mentors to educate 200 students in robotics, computer science, and engineering. One of the goals that I carried from working as one of those mentors is engaging students in programming. The competition requires programming the robot for a teleoperated mode in which the robot is controlled using an Xbox controller and an autonomous mode in which the robot is controlled solely by the program written for it.
Developing an effective autonomous mode can be difficult for the students when working with a constantly changing and developing robot. Student programmers often have little time to perfect their code once the final form of the robot is established.
To give students more time and experience with programming for robotics, Wing Lam and I developed a robotics simulator that can be controlled with identical code.
The purpose of the simulator is to allow students to immediately get hands-on with programming without the requirements for physical robots. By using a simulator, we can effectively give every student with a laptop their own robot that they get to program and experiment with individually. Often with the limitation of a single robot, programming can concentrate to a single student. I hoped to democratize the process and give more students the opportunity to understand programming with robotics.
In my previous experience teaching students programming, setting up their computers to run python was difficult. Installing Python across so many multiple operating systems with various levels of permissions for a large number of students was time intensive. Some school computers did not even allow installation. This process combined with trouble shooting lead to a lot of overhead for programming lessons.
The solution I decided upon was to utilize repl.it, an online IDE for Python. Repl.it is capable of running Python 3.5 with all standard libraries. Repl.it runs within the browser, thus the installation process is reduced to sharing a 7 character URL. This is amazingly fast in comparison with the previous process. Any computer with a web browser is able to execute the code. Repl.it also bypasses command line, allowing students to focus on programming rather than trouble shoot on how to execute the file.
The simulator uses text to represent the robot. The red arrow represents the robot in its position on the field and the direction it is facing. The two red squares represent the spinning motors on each side of the robot. The white sticks labeled L and R are the joysticks of the controller and show the current state of the input. The code is an implementation of arcade drive, in which the robot is controlled by a single joystick.
The default code implements tank drive, in which each motor is controlled by one joystick. Click play to see the robot in action. The code to control the robot is fully customizable. The slides to my programming lesson detail how the API functions and how you can utilize them to create different styles of control.
Repl.it did have some drawbacks. As an online IDE, we could not utilize graphics packages to display the robot. Instead we created a representation using Unicode characters. This is much less glamorous than many simluation engines could’ve given us. Further, we were unable to read live input from controllers. We decided the ability and ease that repl.it afforded us was worth this cost.
Overall, I hope the simulator allows aspiring computer scientists to be able to really flex their fingers during the earlier stages of the competition before the robot is even built.