Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please, thank you! 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

C++ please, thank you!

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:

1464815342.110273122787, 17.889999389648, 0.095994234085

1464815342.123246669769, 17.920000076294, 0.087267547846

1464815342.137223720551, 17.889999389648, 0.095994234085

1464815342.150209188461, 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

image text in transcribed

First, you need to read the input data from the file line by line, then extract the time, distance, and angle from each line.

second, label each data set follow the giving algorithm.

Third, filter the labeled data by using the filter window( you need 11 valid data points to filter). The filter means to calculate the 11 points' distance average, and relabel the data with "filtered".

The only data value which is being filtered is the distance. In other words, The program needs count the number of valid data points until 11 valid data points are counted consecutively. Once 11 points are counted, the filter will take the average of all 11 data points and replace the midpoint data point with the average of all 11 data points. After this, it resets its counter and counts 11 consecutive data points again, finds the average again, and replaces the midpoint of the new window with the new average again. Example below:

image text in transcribed

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:

image text in transcribed

image text in transcribed

image text in transcribed
The input data times may have minor jitter, i.e., on average the frequency is 75 Hz, but is not guaranteed to always be 1/75 empty file, or reading in an invalid file format. The maximum distance is 81.0m, and the default angle if no obstacle is found is -pi/2 rad i.e., less than-1.570). 01.03.0.05840 0.01333.1.01.0.05840 10.02667.1.1.0.05340 10.04.1.04.0.05840 10.05333.1.0.05840 0.06667,0.979.0.05840 10.03.0.958,0.05340 10.09333.0.937,0.05840 0.10667,0.916.0.05340 10.12.0.295,0.05340 0.13333,0.374,0.05340 0.14667,0.324 0.05340 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 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_Pl 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. If the sample has the default angle, the sample is labeled UNDEFINED If the sample can be used in filtering, but does not represented filtered data, it is labeled VALID If the angle between two points exceeds the angle maximum tolerance, the sample is labeled ANGLE RESET. If it is within the angular tolerance but the distance between two points exceeds the distance maximum tolerance, then the second point is given DISTANCE RESET. If a sample is not within either distance or angle tolerance of a previous sample, and is not at the maximum distance or default angle, it is given ANGLE RESET. Output file format The output file should be in the same format as the input file, of lines of text each of which is followed by a new line. There used in filtering (VALID), filtered valid data with (FILTERED), marks a new position due to a significant change in angle (ANGLE RESET), a significant step in distance (DISTANCE RESET), or that the sample is undefined (UNDEFINED), as text outputs. TTTTT.TTTTTT, DD.DDDDDD, A.AAAAAA, STATUS All numerical values should be printed with setprecision (6) of a C++ stream. The input data times may have minor jitter, i.e., on average the frequency is 75 Hz, but is not guaranteed to always be 1/75 empty file, or reading in an invalid file format. The maximum distance is 81.0m, and the default angle if no obstacle is found is -pi/2 rad i.e., less than-1.570). 01.03.0.05840 0.01333.1.01.0.05840 10.02667.1.1.0.05340 10.04.1.04.0.05840 10.05333.1.0.05840 0.06667,0.979.0.05840 10.03.0.958,0.05340 10.09333.0.937,0.05840 0.10667,0.916.0.05340 10.12.0.295,0.05340 0.13333,0.374,0.05340 0.14667,0.324 0.05340 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 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_Pl 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. If the sample has the default angle, the sample is labeled UNDEFINED If the sample can be used in filtering, but does not represented filtered data, it is labeled VALID If the angle between two points exceeds the angle maximum tolerance, the sample is labeled ANGLE RESET. If it is within the angular tolerance but the distance between two points exceeds the distance maximum tolerance, then the second point is given DISTANCE RESET. If a sample is not within either distance or angle tolerance of a previous sample, and is not at the maximum distance or default angle, it is given ANGLE RESET. Output file format The output file should be in the same format as the input file, of lines of text each of which is followed by a new line. There used in filtering (VALID), filtered valid data with (FILTERED), marks a new position due to a significant change in angle (ANGLE RESET), a significant step in distance (DISTANCE RESET), or that the sample is undefined (UNDEFINED), as text outputs. TTTTT.TTTTTT, DD.DDDDDD, A.AAAAAA, STATUS All numerical values should be printed with setprecision (6) of a C++ stream

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions