18-642 Project 2
Released Fall 2024 (changelog)
Learning objectives: (1) Hands-on experience attempting to make a change to
messy code vs. making changes to clean code; and (2) baseline student's
personal concept of "clean" code.
*** See Canvas for a video recitation that might
be helpful to watch before diving in to this description ***
We'll do a video recitation for later projects, but we won't put this reminder
into the assignment after this project.
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.
- If you are not proficient at using command line tools and scripting or
other software development processes, we suggest you watch lectures 1-8 of the
MIT "Missing Semester" class:
https://missing.csail.mit.edu/
**** You will need to do some medium-skill-level bash scripts and use make
files in the second half of the course to make your project build script. If
you've never done that, be sure to work through tutorials now so you're ready
when you get there. You should watch every single one of the "missing
semester" lectures to prepare. Pace yourself to perhaps three per week and
you'll get there in time even if you fall a little behind. ***
Lab Files:
Hints/Helpful Links:
- See the Recitation video and slides on Canvas
- Please follow the handin naming convention: every filename (before the
file extension) must end in [FAMILY NAME]_[Given Name]_[AndrewID].
(AndrewID can be all lower case; Family Name does not have to be all caps.)
- Access the ROS tutorials here: ROS Tutorials.
- Be sure to start the roscore command before using rosrun.
- Be sure to run catkin_make in the /home/student/catkin_ws
directory.
- If ROS isn't finding some packages, type source
~/catkin_ws/devel/setup.bash
- Tutorial on git
(optional). There are many tutorials, guides, etc. on the Web, so we suggest
you look for the newest/best version of these materials if you haven't used
tools like this before.
Procedure:
This procedure requires you to limit the time spent on
certain steps. Read through the entire procedure before starting the
project!
- 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.
- Ensure that you can build run the code as it stands:
- 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.
- In ~/catkin_ws/src/ece642rtle/CMakeLists.txt, change lines 44 and
45 by replacing "ANDREWID" with your Andrew ID.
- Run the following:
cd ~/catkin_ws
catkin_make -DCATKIN_WHITELIST_PACKAGES="ece642rtle"
catkin_make
Note: to build the project following the first time, you only need to type
catkin_make, without the flag after it.
- In one terminal, roscore
- 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.
- 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.
- 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.
- 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).
- You may only edit the
[..]/src/ece642rtle/student/ANDREWID_student_turtle.cpp file.
- STOP after one hour.
- 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.
- If you succeeded, great!
- If you've "almost" succeeded, cut off your efforts after 75
minutes total (strict deadline). You'll get to come back to this later.
- 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.
- Spend additional time cleaning up the code so that you think it is
understandable:
- 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.
- 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.
- You can spend up to six hours if you want to, but no more than six.
- Make sure that the code still successfully solves the maze.
- 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, think of things you might do that make the code easier to
understand even if you normally would not do them.)
- Do NOT consult with other students for hints on turtle directions and so
on.
- 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.
- After you have improved the code, spend up to one additional hour trying
to convert to right-hand rule.
- Answer the following questions in a writeup:
- Your name. (If the writeups are printed out, the file name info is lost, so
put your name and Andrew ID in the document text as well)
- Q1: State what version control system you used in Step 1, and include your
screenshot.
- Q2: Did you successfully modify the turtle algorithm after the first
attempt (Step 4)? Why or why not?
- Q3: Include your log from Step 5.
- Q4: Did you successfully modify the turtle algorithm after the second
attempt (Step 6)? Why or why not? How long did you spend on step 6 (0.0 to 1.0
hours?) If you succeeded after Step 4, you do not have to answer this question
beyond "I spent 0 hours."
- Q5: Did you encounter any problems with the project? What general feedback
do you have? Did you find it too difficult or too easy?
Handin checklist:
- Your writeup. Call this file p02_writeup_[FAMILY NAME]_[Given
Name]_[AndrewID].pdf.
- Your modified student_turtle.cpp file. Call this file
p02_AndrewID_student_turtle.cpp.
Zip these two files into a single zip file and turn them
in on Canvas as P02_[Family name]_[Given name]_[Andrew ID].zip
** For this and future projects, all-caps, all-lower, and initial caps are
all acceptable for all file names in this course regardless of rubric file name
capitalization. Please don't use hacker-case or other painful capitalization
schemes. Thanks.
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.)
Other requirements:
- The writeup shall be in a single acrobat file for ease of navigation.
- Fonts for all diagrams and text shall be rendered at no smaller than 10
point font. Smaller fonts will require a resubmission
The rubric for the project is found here.
Changelog: