Be sure to look at the Blackboard Module for this week for various hand-in mechanisms!
This is a group programming assignment that should be completed in class.
Create a procedure that enforces a speed limit:
This procedure compares a robot's current speed to a speed limit and returns TRUE if the robot is not exceeding the speed limit. It returns FALSE if the robot is exceeding the speed limit. The general use of this procedure is to implement an emergency shutdown function whenever the result is FALSE. Assume that the robot uses direct drive electric motors with a conventional automotive-style steering system (Ackerman steering). Try to create the simplest possible procedure that handles relevant special cases.
Also create and execute a set of unit tests. You can use CUnit, Google testing frameworks, brute force, or whatever unit test process you prefer. Be sure to cover the following cases:
Prioritize your work so that you are able to hand in code that compiles and a COMPLETE test plan table. Do as many tests as you can in time available. This means that if you don't have time to finish your test plan will have all the tests, but some of them will have blank test output and pass/fail cells. As long as you hand in the code, a reasonable table, and have done at least a couple tests you'll get full credit.
22-1. Write a program that exercises 32-bit floating point math edge cases in C or C++ as described below.
Ground rules:This software can be as simple as you like. For example, you can hard-code test input values in const declarations. However, we want you to create a SINGLE function that is used for ALL the test cases and the function needs to do some computation that creates special values, not just return special values. So, for example, to generate infinity you might divide two inputs and in the test set one of them to zero.
As an example, if you have some function that takes three input parameters
a, b, c, the computation result to produce NaN using Function A might be:
22-1-d4 Positive NaN: a=17 b=34 c=59==> FuncA(a,b,c)==> result=+NaN (0x7FC00000)
You should hand in two files for this homework question. First file: a single .cpp file with all the code including a main() function that can be compiled and run. Second file: powerpoint that gives the results lines from the program run annotated with any comments that are relevant. If you couldn't get a particular value to work, show what you could get to work and explain what you think went wrong.
22-1a.(5 points) Create one function that takes at least one floating point input and returns one floating point output. For example, something that computes (b + sqrt(a)) / c (which might or might not be enough for all test cases). Tell us what the function does (normal human-readable math description is OK). This should be mathematical notation (scan of hand-written is fine) and not source code. A function with a switch statement that returns hard-coded special values is NOT acceptable.
22-1b. (5 points) Create one function called " PrintResult(float r)" that takes a floating point number as input and prints an output including the special values that you need to produce. If simply calling "printf" from within that function does the whole job, good for you. If not, do what you need to do for things to work. You can ONLY use one or more "printf" calls as your output function -- no other library formatting helper routines. It is OK to have internal decision logic and multiple different printf calls if you need to.
22-1c. (5 points) Create one function called " PrintHex(float r)" that takes a floating point number as input and prints an output indicating the hexadecimal value of the floating point variable.
22-1d. (5 points) Create a .cpp file with the function, output printing functions, and test routines using 32-bit floating point variables. As mentioned, don't use standard templates and only use libraries for I/O and generating special floating point values. Also implement enough tests to complete the following (one test per result). We encourage you to use Cunit, but that is not required. Hand in the source code all as one .cpp file even if it is a bit large just to help with grading manageability. Make sure that the code compiles with gcc on a course platform. It should compile warning free with default command line parameters, although the float to hex conversion might generate an unavoidable warning depending upon your compiler and how you write the code.
22-1e. (5 points each * 8=40 points) Your code, when run, shall produce the following output values using your floating point output function. Show the input variable values (floats) and the output variable values (both float and hex) as printed out from your program (a screenshot is fine). Some creativity might be required to display the values properly depending upon your runtime environment.
Hand in: a single .cpp or .c file with all code (should be able to compile / if you need a special command line please note that in your powerpoint file), AND a powerpoint file with results (add comments in powerpoint as necessary so they make sense). Put them both into a single zip file with the usual naming convention as "HW22"