https://github.com/einride/pid-go
PID controllers for Go.
https://github.com/einride/pid-go
autonomous-vehicles control-systems go golang pid pid-control pid-controller
Last synced: about 2 months ago
JSON representation
PID controllers for Go.
- Host: GitHub
- URL: https://github.com/einride/pid-go
- Owner: einride
- License: mit
- Created: 2020-12-22T18:04:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-05-12T21:29:14.000Z (about 2 months ago)
- Last Synced: 2025-05-13T01:13:55.594Z (about 2 months ago)
- Topics: autonomous-vehicles, control-systems, go, golang, pid, pid-control, pid-controller
- Language: Go
- Homepage: https://pkg.go.dev/go.einride.tech/pid
- Size: 182 KB
- Stars: 96
- Watchers: 16
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# PID Go
[](https://pkg.go.dev/go.einride.tech/pid)
[](https://goreportcard.com/report/go.einride.tech/pid)
[](https://codecov.io/gh/einride/pid-go)
![]()
PID controllers for Go.
## Examples
### `pid.Controller`
A basic PID controller.
```go
import (
"fmt"
"time""go.einride.tech/pid"
)func ExampleController() {
// Create a PID controller.
c := pid.Controller{
Config: pid.ControllerConfig{
ProportionalGain: 2.0,
IntegralGain: 1.0,
DerivativeGain: 1.0,
},
}
// Update the PID controller.
c.Update(pid.ControllerInput{
ReferenceSignal: 10,
ActualSignal: 0,
SamplingInterval: 100 * time.Millisecond,
})
fmt.Printf("%+v\n", c.State)
// Reset the PID controller.
c.Reset()
fmt.Printf("%+v\n", c.State)
// Output:
// {ControlError:10 ControlErrorIntegral:1 ControlErrorDerivative:100 ControlSignal:121}
// {ControlError:0 ControlErrorIntegral:0 ControlErrorDerivative:0 ControlSignal:0}
}
```\_[Reference ≫](https://en.wikipedia.org/wiki/PID_controller)\_
### `pid.AntiWindupController`
A PID-controller with low-pass filtering of the derivative term, feed forward
term, a saturated control output and anti-windup.*[Reference ≫](http://www.cds.caltech.edu/~murray/amwiki)*
### `pid.TrackingController`
a PID-controller with low-pass filtering of the derivative term, feed forward
term, anti-windup and bumpless transfer using tracking mode control.*[Reference ≫](http://www.cds.caltech.edu/~murray/amwiki)*