18-642 Project 2

Page last updated 8/31/2019 (changelog)

This project introduces you to cleaning up messy code that you didn't write. It requires you to examine an existing project, figure out what the code is doing, and modify it. The focus of this project is on process, so you can receive full points even if you did not successfully complete the implementation. The turtlesim from Project 1 has been modified to move stepwise, and has been renamed ece642rtle.

Lab Files:

Hints/Helpful Links:


This procedure requires you to limit the time spent on certain steps. Read through the entire procedure before starting the project!

  1. Choose a version control system (git, svn...) and set up version control in the ~/catkin_ws/src/ece642rtle directory. Note that this cannot be a public repository (i.e. nobody should be able to find it on github). You can always host a repository in your AFS space. Take a screenshot of the checkout process.
  2. Ensure that you can build run the code as it stands:
    1. Rename the files ~/catkin_ws/src/ece642rlte/student/student_turtle.cpp and ~/catkin_ws/src/ece642rtle/student/student_maze.cppto ANDREWID_student_turtle.cpp and ANDREWID_student_maze.cpp, respectively, where ANDREWID is your student ID.
    2. In ~/catkin_ws/src/ece642rtle/CMakeLists.txt, change lines 44 and 45 by replacing "ANDREWID" with your Andrew ID.
    3. Run the following: cd ~/catkin_ws
      catkin_make -DCATKIN_WHITELIST_PACKAGES="ece642rtle"

      Note: to build the project following the first time, you only need to type catkin_make, without the flag after it.
    4. In one terminal, roscore
    5. In a second terminal, cd ~/catkin_ws/ && source devel/setup.bash && rosrun ece642rtle ece642rtle_node . This command should launch a window with the turtle inside a maze.
    6. In a third terminal, cd ~/catkin_ws/ && source devel/setup.bash && rosrun ece642rtle ece642rtle_student . This command should cause the turtle to start solving the maze.
  3. Confirm that the turtle is solving the maze, using the Wall Follower algorithm, obeying the left-hand rule. This algorithm solves the maze by following the wall with the left hand.
  4. Spend one hour trying to change the turtle from the left-hand rule (left hand following the wall) to the right-hand rule (right hand following the wall).
    1. You may only edit the [..]/src/ece642rtle/student/ANDREWID_student_turtle.cpp file.
    2. STOP after one hour.
    3. To make and run the code, you can either follow the procedure in step 2 above, or use the build_run_turtle.sh script (type ./build_run_turtle.sh to run it) in ~/catkin_ws/src/ece642rtle . This script should work if you run it from anywhere.
    4. If you succeeded, great!
    5. If you've "almost" succeeded, cut off your efforts after 75 minutes total (strict deadline). You'll get to come back to this later.
    6. If you did not succeed, use your version control to revert to a state such that the turtle solves the maze successfully. Usually your best bet is to revert all the way back to the initial code.
  5. Spend additional time cleaning up the code so that you think it is understandable:
    1. Keep a log tracking your time to the nearest tenth of an hour (6 minute increments) with no log entry longer than 30 minutes. Example:
      0.3 hours: Found and used a tool ([tool name]) that automatically applies a coding style.
      0.2 hours: converted turtle direction to enum.
    2. Spend at least two hours improving code quality without trying to complete the changes, even if you got the change working in part 5, above.
    3. You can spend up to six hours if you want to, but no more than six.
    4. Make sure that the code still successfully solves the maze.
    5. Important note: do not consult with other students as to what might or might not be "good" style. There is no expectation as to what "good" coding style is for this project other than what you personally think is "good." We want to see where you are coming from as you start the course so we can assess what content to include/not include this semester. (That having been said, if you can't find 2 hours of work to improve style and are leaving things mostly as they are, perhaps think of things you might do that make the code easier to understand even if you normally would not do them.)
    6. Also, do NOT consult with other students for hints on turtle directions and so on. Also, do NOT throw the code away and start from scratch with your own design. The point of this project is NOT actually to change the turtle behavior. The point is to give you a microcosm experience of inheriting "clever" legacy code and having to make a change. In the real world you'd probably be getting 100,000 lines of code that mostly looks like this, and there would be nobody else to help you. Also, that code will be too huge to throw it away and start over.
  6. After you have improved the code, spend up to one additional hour trying to convert to right-hand rule.
  7. Answer the following questions in a writeup:

Handin checklist:

  1. Your writeup. Call this file p02_writeup_[AndrewID]_[Family Name]_[Given Name].pdf.
  2. Your modified student_turtle.cpp file. Call this file p02_ANDREWID_student_turtle.cpp.

Zip these two files and turn them in on Canvas as Project02_[Andrew ID]_[Family name]_[Given name].zip

Please do NOT put these files inside a subdirectory. When unzipped they should not have any directory associated with the file name, and should just unzip into the current directory. (The file name convention will retain whose work it is.)

The rubric for the project is found here.