Freeway Speed Measurement Lab


In this lab, you will be creating a java-based simulator for a freeway speed measurement system. Speed is measured by determining the difference in time between pulses from two sensors. Although this may initially seem like a simple problem, there are many situations that can occur that will create incorrect speed measurement. For example: a car drives over the first sensor and then misses the second sensor because it changes lanes. In this lab, your goal is to design a method that accurately determines the freeway speed.

  1. The simulator must be created in Java.
  2. Input will be provided in a file with the following format:

    sensor_id event time

    Each line of the input file will contain either 0 or 1 for the sensor ID, a 0 or 1 for an event (0 represent falling edge, 1 represent rising edge), and a double representing the time that the event occurs. A rising edge occurs whenever a car first moves over a sensor. A falling edge occurs whenever a car moves off the sensor. The lines of the file are sorted based on time. For example:
    0 1 1.1 // rising edge on sensor 0 at time 1.1
    0 0 1.12 // falling edge on sensor 0 at time 1.12
    1 1 1.2 // rising edge on sensor 1 at time 1.2
    1 0 1.3 // falling edge on sensor 1 at time 1.3
  3. The simulator must have a graphical interface that contains the following:
    1. A label representing the average free way speed.
    2. A text field that specifies the name of input file.
    3. At least 2 radio buttons that select the different modes. The first mode should be the naive method, which simply measures the time between a rising event on the first sensor and a rising event on the second sensor. The second mode should be your improved method. If you want to have several different modes to compare with, feel free to add more radiobuttons.
    4. A button to start the simulation. Whenever this button is pressed, the file specified by the text field is opened, and the simulation will execute using the method specified by the checkboxes, until the entire file has been read.
  4. You will be using a Frame in this lab, as opposed to an Applet, due to the requirement for file I/O.
  5. The interface should look something like this:
  6. Assume the two sensors are 200 feet apart.
  7. Feel free to add additional features to your program.
  8. To get credit, you must have the functionality checked off in lab and turn in your code online.
  9. In addition to turning in your code, write a small report that describes your improved method. Make sure to include a table that contains results for the naive approach and your approach for all provided test files.
  10. The due date will be announced in lab.
  11. Useful conversion: 1 mile = 5280 feet

Use the following test files for testing and for your report:

Straight forward tests:
65 Mph test
30 Mph test
45 Mph test

Difficult tests (Use your program to determine the speed):
Test 1
Test 2
Test 3