Skip to content

Instantly share code, notes, and snippets.

@trevphil
Last active June 3, 2019 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevphil/82da5dddd3ff66de38be6e657ae00511 to your computer and use it in GitHub Desktop.
Save trevphil/82da5dddd3ff66de38be6e657ae00511 to your computer and use it in GitHub Desktop.
Check scenario
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