{"id":29288847,"url":"https://github.com/regnull/kalman","last_synced_at":"2025-07-06T03:12:56.758Z","repository":{"id":57542434,"uuid":"293179100","full_name":"regnull/kalman","owner":"regnull","description":"Kalman filter implementation for geographical coordinates","archived":false,"fork":false,"pushed_at":"2020-09-08T14:14:29.000Z","size":22,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T06:25:04.382Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/regnull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-06T01:01:17.000Z","updated_at":"2023-11-20T08:34:13.000Z","dependencies_parsed_at":"2022-09-26T18:31:11.992Z","dependency_job_id":null,"html_url":"https://github.com/regnull/kalman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/regnull/kalman","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regnull%2Fkalman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regnull%2Fkalman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regnull%2Fkalman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regnull%2Fkalman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/regnull","download_url":"https://codeload.github.com/regnull/kalman/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regnull%2Fkalman/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263841790,"owners_count":23518497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-06T03:12:45.913Z","updated_at":"2025-07-06T03:12:56.742Z","avatar_url":"https://github.com/regnull.png","language":"Go","readme":"# Kalman Filter for Geographical Coordinates in Go\n\nKalman filter is an algorithm that uses a series of measurements observed over time, containing statistical noise and other inaccuracies, \nand produces estimates of unknown variables that tend to be more accurate than those based on a single measurement alone, by estimating a \njoint probability distribution over the variables for each timeframe. \n\nhttps://en.wikipedia.org/wiki/Kalman_filter\n\nThis repo contains a Kalman filter implementation for motion in three dimensions, which takes speed into account but not acceleration.\nIt also contains a specialized implementation to work with geographical coordinates (lattitude, longitude and altitude). This\nimplementation may be used to process GPS measurements from mobile devices to produce a better estimate of the user's position.\n\n## How to Use\n\nSee the example here:\n\nhttps://github.com/regnull/kalman/blob/master/example/main.go\n\nBasically, using Kalman filter involves the following steps:\n\n* Estimate the process noise\n* Create Kalman filter\n* Feed observed values to the filter, one by one\n* Get the estimated location, hopefully with better precision than any of the observed points\n\n### Estimate the process noise\n\nProcess noise tells the filter how much do we expect the user to move, per second. Knowing this value allows the algorithm to estimate how much of the difference between expected and actual values can be attributed to the actual user motion.\n\nHere, we create the process noise struct:\n\n```\n// Estimate process noise.\nprocessNoise := \u0026kalman.GeoProcessNoise{\n    // We assume the measurements will take place at the approximately the\n    // same location, so that we can disregard the earth's curvature.\n    BaseLat: point.Lat,\n    // How much do we expect the user to move, meters per second.\n    DistancePerSecond: 1.0,\n    // How much do we expect the user's speed to change, meters per second squared.\n    SpeedPerSecond: 0.1,\n}\n```\n\nYou must assign non-zero values to DistancePerSecond and SpeedPerSecond, otherwise you will get an error when creating an instance of the filter.\n\n### Create Kalman filter\n\nAfter you create process noise struct, pass it to NetGeoFilter:\n\n```\n// Initialize Kalman filter.\nfilter, err = kalman.NewGeoFilter(processNoise)\nif err != nil {\n    fmt.Printf(\"failed to initialize Kalman filter: %s\\n\", err)\n    os.Exit(1)\n}\n```\n\nYou might get an error back if the filter doesn't like your process noise values.\n\n### Feed observed values to the filter\n\nGeoFilter.Observe() takes two arguments, the time passed since the last measurement and the new observed value. Easy enough.\n\n```\n// Observe the next data point.\nerr = filter.Observe(timeDelta, \u0026point)\n// Sometimes the filter may return error, although this should not happen under any\n// realistic curcumstances.\nif err != nil {\n    fmt.Printf(\"error observing data: %s\\n\", err)\n}\n```\n\nWhere point contains data like this:\n\n```\nkalman.GeoObserved { \n    Lat:                41.154874,\n    Lng:                -73.773139,\n    Altitude:           105.0,\n    Speed:              0.0,\n    SpeedAccuracy:      0.1,\n    HorizontalAccuracy: 100.0,\n    VerticalAccuracy:   10.0,\n}\n```\n\n### Get the estimated values\n\nFinally, get the estimated values obtained by processing the observed values. \n\n```\nestimated := filter.Estimate()\nfmt.Printf(\"Estimated lat: %f\\n\", estimated.Lat)\nfmt.Printf(\"Estimated lng: %f\\n\", estimated.Lng)\nfmt.Printf(\"Estimated alt: %f\\n\", estimated.Altitude)\nfmt.Printf(\"Estimated speed: %f\\n\", estimated.Speed)\nfmt.Printf(\"Estimated horizontal accuracy: %f\\n\", estimated.HorizontalAccuracy)\n```\n\n## License\n\nThis library is published under MIT license:\n\nCopyright 2020 Leonid Gorkin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n## Status\n\nWork in progress.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregnull%2Fkalman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fregnull%2Fkalman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregnull%2Fkalman/lists"}