Last active
June 3, 2019 13:43
-
-
Save trevphil/82da5dddd3ff66de38be6e657ae00511 to your computer and use it in GitHub Desktop.
Check scenario
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func checkScenario(_ scenario: Scenario) { | |
let filter = KalmanFilter() | |
// Add up the distance between each location in the true path | |
let trueDist = unfilteredDistance(scenario.truePath) | |
// Add up the distance between each location in the noisy path | |
let unfilteredDist = unfilteredDistance(scenario.noisyPath) | |
// Add up the distance between each location in the noisy path | |
// AFTER applying the Kalman Filter we created earlier | |
let filteredDist = filteredDistance(scenario.noisyPath, using: filter) | |
let unfilteredErrorRate = abs(trueDist - unfilteredDist) / trueDist | |
let filteredErrorRate = abs(trueDist - filteredDist) / trueDist | |
XCTAssertLessThanOrEqual(filteredErrorRate, scenario.minAllowableError, | |
"GPS filtering did not meet accuracy threshold [\(scenario.description)]") | |
XCTAssertLessThanOrEqual(filteredErrorRate, unfilteredErrorRate, | |
"GPS filtering performed worse than raw data [\(scenario.description)]") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment