18-642 Project 7
Updated 8/28/2022. Changelog
Learning objective: Take a high level design, create a statechart, and
create code to go with the statechart.
Do NOT modify your code until AFTER you have updated your
statechart. Doing code first then updating statechart completely
undermines the learning objective for this project.
For this project start with the material from the previous project
(Requirements and Sequence Diagrams) and finish the design flow through to
code. We want you to do a more rigorous design process including: product
requiremnents, sequence diagrams, statecharts, code, and traceability.You
should re-use the design materials from the previous project as a starting
point, but you should be updating those materials to match where you end up
with your statechart and code. You'll be carrying this new design forward for
the rest of the project phases, so it's worth your while to get it right.
This project spans extra time (about two weeks). We are assigning it as a
two-week chunk to give you more mid-semester time management flexibility
as you complete work for other courses. We strongly recommend you try to get
ahead and take a first pass through as much as you can on week 1 so you don't
have a time crunch on week 2. But, if you are overwhelmed with another course
it's up to you how you prioritize and manage your time.
- Recall that you should satisfy the behavior requirements from Projects 5
and 6. (In a later project these will be enforced):
- The turtle shall not move more than one adjacent square per call to tick.
- The turtle shall rotate at most 90 degrees per tick.
- The turtle shall only move in the direction it is facing.
- The turtle shall be facing the potential wall segment that it is calling
bumped for.
- The turtle shall make at most one call to bumped per tick.
- The turtle shall not move through walls.
- The turtle shall stop when it solves the maze via reaching the end square.
Lab Files:
Hints/Helpful Links:
- Please follow the handin naming convention: every filename (before the
file extension) must end in [FamilyName]_[GivenName]_[AndrewID]. You
don't need to re-name ALL the files with the project number, and especially we
don't want you to have to waste time renaming all your source code files for
every project. But the highest level zip file shall have a P07 prefix, and
files specific to this project (e.g., the project 7 writeup) shall also have a
project number prefix.
- In this and future projects, $ECE642RTLE_DIR refers to
~/catkin_ws/src/ece642rtle (or corresponding project workspace).
- Some studenst say they find this order unintuitive or weird. That is often
because they learned to do "documentation" after writing code. A
significant point of this course is to change the order you do these tasks in
to be the one in the procedure below (code comes later, only after you've
figured out the design). If any concerns or questions about this please ask at
instructor office hours.
- See the Recitation video and slides on Canvas
Procedure:
(It is expected you will iterate across these procedural steps as you refine
your design.)
- High Level Requirements: Re-use high level requirements from
the previous project as a starting point. You shall update these to match any
changes you make.
- Sequence Diagrams: Re-use sequence diagrams from the
previous project as a starting point. You shall update these to match any
changes you make.
- SD to Reqs Traceability: Re-use the traceability table from
the previous project as a starting point. You shall update these to match any
changes you make.
- State chart: Draw a state chart for student_turtle based on
the sequence diagrams and high level design in general. (If it makes sense to
break the design down into multiple state charts that is OK. Make sure each
statechart has unique labels and numberings for traceability.)
- Define the inputs, outputs, and internal variables in a table:
Example:
Name |
Type |
Range |
Description |
bumped |
input |
{TRUE, FALSE} |
Tells the turtle whether it has just bumped a wall |
move |
output |
{turn_left, turn_right, move_forward} |
The next move the turtle shall make |
... |
... |
... |
... |
- Follow the conventions set forth in class to make a state chart. In
particular, all output variables you described in the table must have an output
at all states, and transitions shall only occur on checks on input variables or
internal variables defined in the table. Make sure the initial state is
indicated with an arrow, and that all states and transitions are numbered. You
are allowed to use sub-states if it makes sense for your design. (Look up a
tutorial on advanced state chart notation if you like.)
- Compute Functions: If you used a compute function of some
sort in your sequence diagrams, then that compute function should be showing up
as a truth value that is the result of a function call in your statechart
(e.g., as a guard condition). For all such compute functions create an
appropriate design description. Depending upon the compute function this might
be a state chart, a flowchart, control equations, or a pseudocode algorithm.
Each compute function should have its own design. (If there is no compute
function of this type simply say "no compute function" and you will
receive full credit assuming that statement is actually true.
- High Level Reqs to Statechart Design Traceability: Perform
traceability of requirements to statechart and compute function using a table.
(If you have multiple state charts use either one bigger table or multiple
smaller tables to trace all of them.) Each state and transition shall be a row
in the table (compute functions should be one or more rows as well), and each
requirement shall be a column:
|
R1 |
R2 |
.. |
S1 |
x |
|
|
S2 |
|
|
|
.. |
|
|
|
T1 |
|
|
|
.. |
|
|
|
Because your requirements are product-level requirements, and your statechart
is low-level design, it is possible that a requirement might trace to more than
one state or vice versa. That is allowed and expected, as long as you achieve
full traceability: each row and each column must have at least one cell checked
off. If a row has zero cells checked off, that means the corresponding state or
transition does not meet any requirements and is extraneous. If a column has
zero cells checked off, that means the corresponding requirement is not being
fulfilled by any states or transitions. Revise your requirements and statechart
until you achieve full traceability. (If there is a compelling reason not to
have full traceability, explain specifically why.)
- Implementation: Implement your design (i.e., statechart +
compute function(s)) in student_turtle.cpp
- Your top-level statechart implementation shall be a function in
ANDREWID_student_turtle.cpp, which shall contain a switch statement
with cases for every state. Since your statechart implements the turtle
movement logic, no part of your statechart implementation shall be in
student_maze.
- Define a current state variable, and use a switch statement to switch
between current states. (For the following writeup items, we use the term
"the state's block" to refer to the case of the switch statement that
handles the current state.)
- Make sure all outputs are being set in all state blocks.
- Put transition logic at the end of the state's block. This should check
internal variables and input variables and set the current state variable
accordingly.
- Comment each state and transition with its label ("S1" or
"T1") in the code. You will be graded on the traceability of
statechart to code, so make sure you have an accurate label for each state and
transition.
We highly recommend that you write this
implementation from scratch, instead of manipulating your existing
student_turtle code. This way, it will be clear that your turtle
movement code implements your statechart.
- System Test: Verify that your implementation works on mazes
m1-m3. Remember you can run the code with a given maze file by providing it as
an argument to build_run_turtle.sh: ./build_run_turtle.sh
[mazefile]
to give some time management flexiblity, this code shall compile and
execute, causing the turtle to move at least one square. It shall also conform
to the statechart. HOWEVER, if it does not actually solve the maze you
will still get full credit for this project. (You'll want to fix that
in the next project phase, and we suggest you try to fix it now, but this
prevents there being an all-nighter debugging session between you and a
hand-in. Caution -- if you take this as license to ignore writing code and
ignore fixing mistakes in your algorithm/design the next project phase will
have a high workload.)
- Writeup: Answer the following questions in a writeup:
- Your name. (If they are printed out, the file name info is lost.)
- Q1. Include screenshots of the turtle attempting to solve m1, m2, and m3.
- Q2. Did you solve m1, m2, m3? If not, briefly describe the behavior that
seems to be causing the maze solution(s) to fail.
- Q3. Did your turtle succeed in solving all of the other mazes? Name any
mazes your implementation did not solve. If your turtle did not solve the
mazes, why (give us your best guess as to algorithm problem, or describe the
behavior that seemed to result in not solving the maze)? How would you change
your algorithm so that it could solve the mazes (it's OK to be pretty high
level here; we just want you to show you've started thinking about this)?
- Q4. How useful do you think doing the more formal design process is in
terms of creating code that will need less debugging for this project? Why do
you think it was useful (be specific) and/or why do you think it was not useful
(be specific).
- Q5. How different is your code than it was from the previous project?
- Q6. Any problems or things you'd change about this assignment?
Project Handin Checklist:
- 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)
- Your brief writeup answering the questions
- Sequence diagrams (even if unchanged)
- High Level Requirements (even if unchanged)
- SD to requirements traceability (even if unchanged)
- Statechart
- Compute function designs
- Requirements to detailed design (statechart + compute function)
traceability
- Updated implementation code base
- Screenshots of M1, M2, M3 solution attempted runs (at least show program
ran enough to attempt to solve)
Other requirements:
- Use the usual project naming conventions with a prefix of "p07"
for items other than source code.
- 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.
- We want a SINGLE acrobat file, not a shower of small files that the TAs
have to go through individually.
- The whole hand-in shall be in a single zip that contains a writeup (one
.pdf file) and a .zip file with the code (a second file, which is a .zip within
the single hand-in .zip file)
- 8/28/2022: released.
- 10/20/2023: updated with font size requirement