CS 452/652 Fall 2019 - Train Control (Part 1)

(Version: Mon Oct 21 20:05:28)

Demo Date: Thu, Nov 7, 2019 (submit code & documentation at 9:00am)


The traffic control milestones each require a capability that is likely to be useful for almost any project. The first milestone is concerned with
  1. knowing exactly where one train is when it is motion, and
  2. stopping one train at any point on the track.


For the first milestone we expect that you have the train moving at a constant velocity and can stop it at a chosen location. Given an appropriate command from the terminal your program should switch turnouts that put the train on course to the location, then give a ‘speed zero’ command at the right time to stop the train at the requested location. To accomplish this, your program must be able to
  1. find a route to the location and switch the turnouts, and
  2. give the stopping command at the right time.
The usual way of getting the train to a constant velocity is to set turnouts to make part of the track into a loop, then to run the train around the loop until it gets to a constant velocity. Calculate a route from any switch in the loop to the destination, switch the turnouts appropriately, wait, then give the stop command at the correct moment.

Routing and Switching

Route calculation and switching should be as simple as possible. The route need not be the shortest and it should not require the train to change direction. (In later milestones you will be required required to use routes that change direction and that are the shortest, so do your route finding in a way that will easily accommodate those improvements.) Switching may be done all at once, usually starting at the destination and working backward so that when the train is switched out of the loop all other turnouts are set correctly. (Setting turnouts as the train requires them will be needed in later milestones to implement switching in a way that makes it easy to reorder switching and to interleave other activities.) Routing and switching should be smart enough to behave correctly when the destination is in the loop. Use the track information available via the course web page to build an internal model of the track(s). A stopping locations will be given as a track node number (from this data set) and a distance offset. The offset can be negative.


Stopping requires two capabilities:
  1. knowing your stopping distance for the speed at which you are travelling, and
  2. knowing when you are exactly that distance from the destination, which is possible if you know the velocity at which you are travelling.
We would like to be able to assess each of these independently of the other. To do so we request that every time you receive a new sensor trigger you predict the time at which you will trigger the following sensor and compare it to the time at which the following sensor is actually triggered. The difference should be displayed on the terminal in two forms: as a time difference, tactual − tpredicted, and as a distance, v(tactual − tpredicted).

What To Expect During the Demo

Hand In

Hand in the following, nicely formatted and printed.
  1. A description of how to access, make, and operate your program in a README file, including the full pathname of your executable file.
  2. The names of your group members in the same README file.
  3. A description of the structure of your kernel and application so far, highlighting the changes for this assignment. Describe which algorithms and data structures you used and why you chose them.
  4. A pointer to your code repository, readable by the TAs and instructor, containing the source code of your assignment, instructions how to make the executable and the PDFs containing the documentation. The code and documentation must remain unmodified after submission until the assignments have been marked. Email the commit SHA to the TAs and instructor before 9:00am on the demo date.