Question: in c++ please. (updated) The filter should be run only when the full filter window of valid points is available; otherwise, the existing distance is
in c++ please. (updated)






The filter should be run only when the full filter window of valid points is available; otherwise, the existing distance is used. Angle data are not filtered, but are used to determine validity.
A sample is determined to be valid when compared to the previous sample: the relative distance must be strictly less than the specified tolerance of 0.1 m, and the relative angle must be strictly less than 15 degrees. Consider using the M_PI constant, defined in the cmath library to perform this calculation. The below should help in understanding how to classify each point, in order to determine whether to filter.
Input file format The input log consists of a timestamp, followed by distance and then angle information. TTTTT.TTT, DD.DD, A.AAA Each line is separated by a newline. If a line does not match this format, it should be ignored and the program should continue processing the file. The following is a simple example of the inputFile format: 1464 815342.110273122787, 17.88999938 9648, 0.095994234085 1464815342.123246669769, 17.920000076294, 0.087267547846 1464815342.137223720551, 17.88999938 9648, 0.095994234085 1464815342.15020918 8461, 17.920000076294, 0.087267547846 1464815342.163207292557, 17.909999847412, 0.095994234085 1464815342.177282094955, 17.920000076294, 0.087267547846 1464815342.189191341400, 17.909999847412, 0.095994234085 1464815342.204182624817, 17.909999847412, 0.087267547846 1464815342.217026233673, 17.899999618530, 0.095994234085 1464815342.230037212372, 17.920000076294, 0.087267547846 1464815342.243027210236, 17.909999847412, 0.095994234085 Data structures The following data structure and enumerated type should be used for storing and filtering data. typedef enum Filterstatus { UNDEFINED=-1, VALID, FILTERED, ANGLE_RESET, DISTANCE_RESET } FilterStatus; typedef struct obstacleDataSample_struct { double timestamp; double distance; double angle; Filterstatus status; } obstacleDataSample; Filter algorithm The only data value which is being filtered is the distance; the filter is an average of all distance points across the width of the filter, which is defined at compile time as 11 data points. The filtered value is the center of this filtering window. For example, consider the subset of values below: 0,1.03,0.05840 0.01333,1.01,0.05840 0.02667,1.1,0.05840 0.04,1.04,0.05840 0.05333,1,0.05840 0.06667,0.979,0.05840 0.08,0.958,0.05840 0.09333,0.937,0.05840 0.10667,0.916,0.05840 0.12,0.895,0.05840 0.13333,0.874,0.05840 0.14667,0.824,0.05840 For the above example, the average distance 0.957545 m would be valid for time 0.08. An example result in the appropriate file format) if these were the only datapoints in the file would be: 0.000000, 1.030000,0.058400, UNDEFINED 0.013330,1.010000,0.058400, VALID 0.026670,1.100000,0.058400, VALID 0.040000, 1.040000,0.058400, VALID 0.053330,1.000000,0.058400, VALID 0.066670,0.979000,0.058400, VALID 0.080000,0.957545,0.058400, FILTERED 0.093330,0.937000,0.058400, VALID 0.106670,0.916000,0.058400, VALID 0.120000,0.895000,0.058400, VALID 0.133330,0.874000,0.058400, VALID 0.146670,0.824000,0.058400, VALID Input file format The input log consists of a timestamp, followed by distance and then angle information. TTTTT.TTT, DD.DD, A.AAA Each line is separated by a newline. If a line does not match this format, it should be ignored and the program should continue processing the file. The following is a simple example of the inputFile format: 1464 815342.110273122787, 17.88999938 9648, 0.095994234085 1464815342.123246669769, 17.920000076294, 0.087267547846 1464815342.137223720551, 17.88999938 9648, 0.095994234085 1464815342.15020918 8461, 17.920000076294, 0.087267547846 1464815342.163207292557, 17.909999847412, 0.095994234085 1464815342.177282094955, 17.920000076294, 0.087267547846 1464815342.189191341400, 17.909999847412, 0.095994234085 1464815342.204182624817, 17.909999847412, 0.087267547846 1464815342.217026233673, 17.899999618530, 0.095994234085 1464815342.230037212372, 17.920000076294, 0.087267547846 1464815342.243027210236, 17.909999847412, 0.095994234085 Data structures The following data structure and enumerated type should be used for storing and filtering data. typedef enum Filterstatus { UNDEFINED=-1, VALID, FILTERED, ANGLE_RESET, DISTANCE_RESET } FilterStatus; typedef struct obstacleDataSample_struct { double timestamp; double distance; double angle; Filterstatus status; } obstacleDataSample; Filter algorithm The only data value which is being filtered is the distance; the filter is an average of all distance points across the width of the filter, which is defined at compile time as 11 data points. The filtered value is the center of this filtering window. For example, consider the subset of values below: 0,1.03,0.05840 0.01333,1.01,0.05840 0.02667,1.1,0.05840 0.04,1.04,0.05840 0.05333,1,0.05840 0.06667,0.979,0.05840 0.08,0.958,0.05840 0.09333,0.937,0.05840 0.10667,0.916,0.05840 0.12,0.895,0.05840 0.13333,0.874,0.05840 0.14667,0.824,0.05840 For the above example, the average distance 0.957545 m would be valid for time 0.08. An example result in the appropriate file format) if these were the only datapoints in the file would be: 0.000000, 1.030000,0.058400, UNDEFINED 0.013330,1.010000,0.058400, VALID 0.026670,1.100000,0.058400, VALID 0.040000, 1.040000,0.058400, VALID 0.053330,1.000000,0.058400, VALID 0.066670,0.979000,0.058400, VALID 0.080000,0.957545,0.058400, FILTERED 0.093330,0.937000,0.058400, VALID 0.106670,0.916000,0.058400, VALID 0.120000,0.895000,0.058400, VALID 0.133330,0.874000,0.058400, VALID 0.146670,0.824000,0.058400, VALID
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
