Skip to content

Commit

Permalink
Additional features and bug fixes:
Browse files Browse the repository at this point in the history
- Include altitude value correction
- Small bug fixes
- Sample project refactoring
  • Loading branch information
Hypercubesoft committed Sep 19, 2017
1 parent 5389a29 commit 2371de0
Show file tree
Hide file tree
Showing 834 changed files with 1,266 additions and 28,813 deletions.
450 changes: 450 additions & 0 deletions HCKalmanFilter Sample/HCKalmanFilter Sample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "45FC375B1EB07118008FADC3"
BuildableName = "KalmanFilter.app"
BlueprintName = "KalmanFilter"
ReferencedContainer = "container:KlamanFilter.xcodeproj">
BlueprintIdentifier = "A5D359661F713E7700B436D5"
BuildableName = "HCKalmanFilter Sample.app"
BlueprintName = "HCKalmanFilter Sample"
ReferencedContainer = "container:HCKalmanFilter Sample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -32,10 +32,10 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "45FC375B1EB07118008FADC3"
BuildableName = "HCKalmanFilter.app"
BlueprintName = "HCKalmanFilter"
ReferencedContainer = "container:HCKalmanFilter.xcodeproj">
BlueprintIdentifier = "A5D359661F713E7700B436D5"
BuildableName = "HCKalmanFilter Sample.app"
BlueprintName = "HCKalmanFilter Sample"
ReferencedContainer = "container:HCKalmanFilter Sample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
Expand All @@ -55,10 +55,10 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "45FC375B1EB07118008FADC3"
BuildableName = "HCKalmanFilter.app"
BlueprintName = "HCKalmanFilter"
ReferencedContainer = "container:HCKalmanFilter.xcodeproj">
BlueprintIdentifier = "A5D359661F713E7700B436D5"
BuildableName = "HCKalmanFilter Sample.app"
BlueprintName = "HCKalmanFilter Sample"
ReferencedContainer = "container:HCKalmanFilter Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
Expand All @@ -74,10 +74,10 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "45FC375B1EB07118008FADC3"
BuildableName = "KalmanFilter.app"
BlueprintName = "KalmanFilter"
ReferencedContainer = "container:KlamanFilter.xcodeproj">
BlueprintIdentifier = "A5D359661F713E7700B436D5"
BuildableName = "HCKalmanFilter Sample.app"
BlueprintName = "HCKalmanFilter Sample"
ReferencedContainer = "container:HCKalmanFilter Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>HCKlamanFilter.xcscheme</key>
<key>HCKalmanFilter Sample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>45FC375B1EB07118008FADC3</key>
<key>A5D359661F713E7700B436D5</key>
<dict>
<key>primary</key>
<true/>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// MapService.swift
// HCKalmanFilter
// KalmanFilter
//
// Created by Hypercube on 1/19/17.
// Copyright © 2017 Hypercube. All rights reserved.
Expand All @@ -17,8 +17,15 @@ class MapService: NSObject, CLLocationManagerDelegate
var locationManager: CLLocationManager = CLLocationManager()
var lastLocation: CLLocation? = nil
var pathLengths: [Float] = []

var paths: [GMSMutablePath] = []
var realPaths: [GMSMutablePath] = []

var altidtudes: [Double] = []
var realsAltidtudes: [Double] = []
var allAltidtudes: [Double] = []
var allRealsAltidtudes: [Double] = []

var startTimes: [Date] = []
var endTimes: [Date] = []

Expand Down Expand Up @@ -89,6 +96,10 @@ class MapService: NSObject, CLLocationManagerDelegate
myMapService.pathLengths.removeAll()
myMapService.paths.removeAll()
myMapService.realPaths.removeAll()
myMapService.altidtudes.removeAll()
myMapService.realsAltidtudes.removeAll()
myMapService.allAltidtudes.removeAll()
myMapService.allRealsAltidtudes.removeAll()
myMapService.startTimes.removeAll()
myMapService.endTimes.removeAll()
}
Expand Down Expand Up @@ -154,7 +165,7 @@ class MapService: NSObject, CLLocationManagerDelegate
if lastLocation != nil {
let distance = myLocation.distance(from: lastLocation!)
if MapService.isRecordingLocation {
print("distance: " + distance.description + " accuracy: " + "\(myLocation.horizontalAccuracy)" + "speed: " + "\(myLocation.speed)") }
print("distance: " + distance.description + " accuracy: " + "\(myLocation.horizontalAccuracy)" + "speed: " + "\(myLocation.speed) " + "altitude: " + "\(myLocation.altitude)") }

if distance < 0.5 {
return }
Expand All @@ -180,13 +191,22 @@ class MapService: NSObject, CLLocationManagerDelegate
{
if self.resetKalmanFilter == true
{
self.altidtudes.removeAll()
self.realsAltidtudes.removeAll()

kalmanFilter.resetKalman(newStartLocation: myLocation)
self.resetKalmanFilter = false
}
else
{
let realAltitude = myLocation.altitude

let kalmanLocation = kalmanFilter.processState(currentLocation:myLocation)
print(kalmanLocation.coordinate )

self.addNewAltitudeValues(realAltitude: realAltitude, kalmanAltitude: kalmanLocation.altitude)

print(kalmanLocation.coordinate)

MapService.addNewPointToLastPath(myLocation.coordinate.latitude,
long: myLocation.coordinate.longitude)

Expand All @@ -201,6 +221,44 @@ class MapService: NSObject, CLLocationManagerDelegate
AppNotify.postNotification("locationUpdated")
}

func addNewAltitudeValues(realAltitude: Double, kalmanAltitude: Double)
{
let maxNumberOfElementsInArray = 5

self.allRealsAltidtudes.append(realAltitude)
self.allAltidtudes.append(kalmanAltitude)

if self.realsAltidtudes.count > maxNumberOfElementsInArray
{
let subArray = getLast(array: self.realsAltidtudes, count: maxNumberOfElementsInArray-1)
self.realsAltidtudes = subArray
self.realsAltidtudes.append(realAltitude)
}
else
{
self.realsAltidtudes.append(realAltitude)
}

if self.altidtudes.count > maxNumberOfElementsInArray
{
let subArray = getLast(array: self.altidtudes, count: maxNumberOfElementsInArray-1)
self.altidtudes = subArray
self.altidtudes.append(kalmanAltitude)
}
else
{
self.altidtudes.append(kalmanAltitude)
}
}

func getLast<T>(array: [T], count: Int) -> [T] {
if count >= array.count {
return array
}
let first = array.count - count
return Array(array[first..<first+count])
}

func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("MapService - locationManager - fail")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AppNotify.swift
// HCKalmanFilter
// KalmanFilter
//
// Created by Hypercube on 12/16/16.
// Copyright © 2016 Hypercube. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AppDelegate.swift
// HCKalmanFilter
// KalmanFilter
//
// Created by Hypercube on 4/26/17.
// Copyright © 2017 Hypercube. All rights reserved.
Expand Down
38 changes: 15 additions & 23 deletions ...ets/LaunchImage.launchimage/Contents.json → ...ets/LaunchImage.launchimage/Contents.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,44 @@
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"filename" : "LaunchImage-iPhonePortrait2x.png",
"extent" : "full-screen",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "LaunchImage-iPhonePortraitRetina4.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"orientation" : "landscape",
"idiom" : "ipad",
"filename" : "LaunchImage-iPadPortrait1x.png",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"filename" : "LaunchImage-iPadLandscape1x.png",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"scale" : "1x"
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"filename" : "LaunchImage-iPadPortrait2x.png",
"extent" : "full-screen",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "landscape",
"orientation" : "portrait",
"idiom" : "ipad",
"filename" : "LaunchImage-iPadLandscape2x.png",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
"extent" : "full-screen",
"scale" : "1x"
}
],
"info" : {
Expand Down
Loading

0 comments on commit 2371de0

Please sign in to comment.