State estimation and filtering algorithms in Go

go-estimate: State estimation and filtering algorithms in Go

Build Status go.dev reference GoDoc License Go Report Card codecov

This package offers a small suite of basic filtering algorithms written in Go. It currently provides the implementations of the following filters and estimators:

In addition it provides an implementation of Rauch–Tung–Striebel smoothing for Kalman filter, which is an optimal Gaussian smoothing algorithm. There are variants for both LKF (Linear Kalman Filter) and EKF (Extended Kalman Filter) implemented in the smooth package. UKF smoothing will be implemented in the future.

Get started

Get the package:

$ go get github.com/milosgajdos/go-estimate

Get dependencies:

$ make dep

Run unit tests:

$ make test

You can find various examples of usage in go-estimate-examples.

TODO

Contributing

YES PLEASE!

Owner
Milos Gajdos
I like to program stuff
Milos Gajdos
Comments
  • Separate Discrete from Continuous models

    Separate Discrete from Continuous models

    First of all: I am sorry about the last PR I did. I am quite embarrassed of the error I introduced.

    I've changed interface names Model-> DModel, Propagator-> DPropagator to indicate they are discrete-time functions and that they are not compatible with sim.Continuous implementation. Let me know if any of the changes are too much.

  • fix BaseModel.Propagate() implementation

    fix BaseModel.Propagate() implementation

    I found a rather serious mistake in the implementation of Propagate().

    The issue is that next state was calculated as X_{n+1} = A*X_{n} + B*U. The equation modern control theory supposes is dX/dt = A * X_{n} + B*U which means you have to integrate the result in time.

  • Add missing dimensions to `Model.Dims()` for MIMO systems. Resolves #6

    Add missing dimensions to `Model.Dims()` for MIMO systems. Resolves #6

    There was a mistake in sim package in that there was no distinction made between input vector length (u) and state vector length (x). Model dimension now is fully explicit returning length of x state vector, u input vector, y output vector, and z disturbance input vector. Do note that I have yet to implement the disturbance matrix E so for now the fourth parameter returned by Dims() should be equal to length of x (first parameter). I just thought it was a good idea to future-proof the API.

    I've also added documentation to interfaces.

  • Cannot run bf.go example

    Cannot run bf.go example

    When I copy bf.go into my project and run it I get the following output: ../esp/go/pkg/mod/github.com/milosgajdos83/[email protected]/noise/gaussian.go:44:32: g.dist.CovarianceMatrix(nil) used as value But if I run it from the examples dir it works as expected.

  • module `gonum.org/v1/plot.New()` function signature mismatch

    module `gonum.org/v1/plot.New()` function signature mismatch

    myproject/vendor/github.com/milosgajdos/go-estimate/sim/plot.go:35:9: assignment mismatch: 2 variables but plot.New returns 1 values
    myproject/vendor/github.com/milosgajdos/go-estimate/sim/plot.go:43:14: assignment mismatch: 2 variables but plot.NewLegend returns 1 values
    

    Link to file https://github.com/milosgajdos/go-estimate/blob/master/sim/plot.go#L35

    Running go mod tidy does not fix it. I'm on go version go1.16.3 linux/amd64.

  • interface definitions with nomenclature

    interface definitions with nomenclature

    It would be of great use if interfaces where arguments are ambiguous, for example Observer and Filter, named their arguments according to control theory typical nomenclature.

    This is current interface definition

    // Filter is a dynamical system filter.
    type Filter interface {
    	// Predict estimates the next internal state of the system
    	Predict(mat.Vector, mat.Vector) (Estimate, error)
    	// Update updates the system state based on external measurement
    	Update(mat.Vector, mat.Vector, mat.Vector) (Estimate, error)
    }
    
    // Propagator propagates internal state of the system to the next step
    type Propagator interface {
    	// Propagate propagates internal state of the system to the next step
    	Propagate(mat.Vector, mat.Vector, mat.Vector) (mat.Vector, error)
    }
    
    // Observer observes external state (output) of the system
    type Observer interface {
    	// Observe observes external state of the system
    	Observe(mat.Vector, mat.Vector, mat.Vector) (mat.Vector, error)
    }
    

    Problems with this definition include:

    • All arguments are mat.Vector. What convention is being used?
    • Comments do not help either. Overall lackluster documentation

    Other interfaces with this problem:

    • filter.DiscreteModel. This one is fixed easy: StateMatrix() (A mat.Matrix). A,B,C and D matrices are standard nomenclature for these matrices

    Possible solutions

    Below is a mix of adding a little bit of documentation + naming the variables.

    type Filter interface {
    	// Predict estimates the next internal state of the system. x is state, u are inputs
    	Predict(x,u mat.Vector) (filter.Estimate, error)
    	// Update updates the system state based on external measurement. x is state, u are inputs, z is the measurement
    	Update(x, u, z mat.Vector) (filter.Estimate, error) 
    }
    
  • Question on motion model for drones

    Question on motion model for drones

    Hi,

    We are looking for an UKF for motion modelling a drone path where degrees of freedom are very high. Just wanted to check this library is generic enough to incorporate any complex motion model.

  • upgrade dependencies to prevent go module hiccups

    upgrade dependencies to prevent go module hiccups

    The gonum plot error from #7 keeps popping up whenever running go mod tidy on some projects which use gonum and go-estimate. Figure it wouldn't hurt to upgrade dependencies since they seem rather outdated.

    What I did:

    1. Remove go.sum
    2. Remove gonum dependencies in go.mod among others.
    3. Run go clean -modcache
    4. Run `go mod tidy
  • kalman filtering for non fixed time delta updates

    kalman filtering for non fixed time delta updates

    Hi, I was using kalman filter, where I need to call predict but at varying timesteps. I am referring to example where fixed delta t are used for state propagation. My measurement updates and predictions are async and can come at varying time intervals so first update can be called at 1s, next at 5s, and next at 6s... so on. from the source code it seems not doable as m ie. model is private and is fixed during initialization, now I can change A matrix(reflecting delta t multiplication) in model itself but this won't be reflected in kf object, as its pass by value, not pass by pointer. Can you please suggest, if there already exists something for this in library or a workaround.

  • Create distinction between discrete and continuous systems

    Create distinction between discrete and continuous systems

    Below are the changes to the API:

    Interfaces

    • Propagator -> DiscretePropagator
    • Model -> DiscreteModel
    • DiscreteModel -> DiscreteControlSystem (I think this change makes it much clearer about what this interface represents, as it has methods pertaining to control theory constructs while Model was just that, a model of a dynamical system)

    sim package changes

    • BaseModel struct -> Discrete struct
    • Add Continuous struct and allow conversion of a continuous time system to discrete time via ToDiscrete. Will add ToContinous to allow for easy testing.

    Overall the remaining changes were API updates.

Industrial IoT Messaging and Device Management Platform
Industrial IoT Messaging and Device Management Platform

Mainflux Mainflux is modern, scalable, secure, open-source, and patent-free IoT cloud platform written in Go. It accepts user and thing (sensor, actua

Dec 31, 2022
Secure and Interoperable Internet of Things

plgd Cloud Internet of Things (IoT) technologies have evolved rapidly in recent years and continue to change how we interact with our surroundings. Fo

Dec 26, 2022
Securely access remote devices and servers
Securely access remote devices and servers

Deviceplane is an open source device management tool for embedded systems and edge computing. It solves various infrastructure problems related to rem

Dec 15, 2022
Gobot - Golang framework for robotics, drones, and the Internet of Things (IoT)
Gobot - Golang framework for robotics, drones, and the Internet of Things (IoT)

Gobot (https://gobot.io/) is a framework using the Go programming language (https://golang.org/) for robotics, physical computing, and the Internet of Things.

Jan 8, 2023
Raspberry pi project that controls jack-o-lantern via servo motor and PIR motion sensors
Raspberry pi project that controls jack-o-lantern via servo motor and PIR motion sensors

pumpkin-pi ?? Raspberry pi project that controls jack-o-lantern via servo motor and PIR motion sensors to simulate it "watching" you. Inspired by Ryde

Sep 13, 2022
A robust and easy to use MQTT rule engine
A robust and easy to use MQTT rule engine

⚙ MQTT COMMANDER A robust and easy to use MQTT rule engine Configure your MQTT Rules via easy to use YML Files Supports JSON encoded MQTT Messages Sup

Sep 21, 2022
A opinionated multi-tenant hyperscale Internet of Things platform to connect IoT devices fast and securely with minimal TCO

infinimesh IoT Platform infinimesh is a opinionated multi-tenant hyperscale Internet of Things platform to connect IoT devices fast and securely with

Feb 14, 2022
Exploring and comparing different IOT messaging protocols / transports.

IOT Messaging Protocols Blynk https://blynk.io/ A fully integrated suite of IoT software Device provisioning Sensor data visualization Remote control

Jan 2, 2022
Read metrics from a Message Queue in Json format and expose them in a Prometheus compatible format

mq2prom Read metrics from a Message Queue in Json format and expose them in a Prometheus compatible format. Currently only works for MQTT compatible M

Jan 24, 2022
IoT platform with things/user management and visualization, in Go with Docker using microservices

BARIOT IoT platform to Manage Users and their Things and visualize their data. Microservices services architecture build with Go and docker (compose).

Jun 22, 2022
lirc.go - a library to send and receive via lircd

LIRC Go client for Linux Infrared Remote Control (LIRC) package Usage package main import ( "github.com/chbmuc/lirc" "log" "time" ) func keyPo

Oct 24, 2022
Collaborative Filtering (CF) Algorithms in Go!

Go Recommend Recommendation algorithms (Collaborative Filtering) in Go! Background Collaborative Filtering (CF) is oftentimes used for item recommenda

Dec 28, 2022
Tool to support the estimation for true sales prices for Danish properties.
Tool to support the estimation for true sales prices for Danish properties.

Hjem Dette værktøj er designet til at støtte huskøbere til at kunne danne sig et overblik historiske købspriser for nærområdet givet man har udset sig

Nov 9, 2022
TinyGo attitude estimation simulation applet.

tiny-ahrsim TinyGo attitude estimation simulation applet. Instructions Requirements Go installed (golang.org) git installed (git-scm.com) TinyGo insta

Oct 26, 2022
cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resource objects related of Kubernetes Cluster API.

Overview cluster-api-state-metrics (CASM) is a service that listens to the Kubernetes API server and generates metrics about the state of custom resou

Oct 27, 2022
Us-api: a simple service that returns the US state code based on the state

us-api us-api is a simple service that returns the US state code based on the state. It does not support creating, updating nor deleting data. Local D

Dec 13, 2021
:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go
:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go

Region quadtrees in Go Region quadtrees and efficient neighbour finding techniques in Go Go-rquad proposes various implementations of region quadtrees

Dec 13, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Dec 20, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Dec 20, 2022
Go translations of the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Overview Go translations of the Java source code for the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin

Dec 13, 2022