GithubHelp home page GithubHelp logo

einride / pid-go Goto Github PK

View Code? Open in Web Editor NEW
75.0 20.0 5.0 174 KB

PID controllers for Go.

Home Page: https://pkg.go.dev/go.einride.tech/pid

License: MIT License

Makefile 5.76% Go 94.24%
go golang pid pid-control pid-controller control-systems autonomous-vehicles

pid-go's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pid-go's Issues

How is this to be used?

Not having any experience with PID controlelrs I need a nudge to get this going.

I have a water heating system that has a pump to push water through a set of solar panels to heat up a large tank. I thought I could employ this controller to manage the pump speed based on the temperature of the hot tank vs the temperature of the water coming off the solar panels. My problem is that I don't really understand how I should be using the controller.

I set the ReferenceSignal to the difference in temperature I am looking for, e.g 3.0 Celsius. Then I set the actual value to the observed difference in the two measured temperatures. I am sampling every 5 seconds.

Is this correct or am I completely missing the point?

Once I get the result by asking for the State, how should I interpret it? Should I use the ControlSignal to adjust the pump speed? Obviously it would need to be capped at 100% but should that somehow be fed back tot he controller?

Please forgive my ignorance here.

Add JSON tags to configuration struct

Hi !
It would be nice to add JSON tags to the conf structure to automate controller configuration. In my case this required me to create a structure with tags and cast it into your, I think this could be simplified by adding it to yours.

Here's my suggestion:

// ControllerConfig contains configurable parameters for a Controller.
type ControllerConfig struct {
	// ProportionalGain determines ratio of output response to error signal.
	ProportionalGain float64 `json:"kp"`
	// IntegralGain determines previous error's affect on output.
	IntegralGain float64 `json:"ki"`
	// DerivativeGain decreases the sensitivity to large reference changes.
	DerivativeGain float64 `json:"kd"`
}

Best regards.

Control signal is not clamped if the .ControlErrorIntegral becomes NaN

I think I've found a bug with the package with AntiWindupController (I think it works for the others as well, didn't check)

If the control of the physical process fails (due to unrelated to the package reasons, ofc) and the feedback values are always giving the error (let's assume it stabilized at an offset from the setpoint), it would always accumulate *.State.ControlErrorIntegral. It's generally ok, but if the process is constantly offset, it accumulates error until it overflows and becomes NaN. In this case, the *.State.ControlSignal is not clamped as in normal operation. It may result in unexpected behaviour.

In my case I just clamped the actual control signal additionally with checks (the approach)

if math.IsNaN(Controller.State.ControlSignal) || math.IsInf(Controller.State.ControlSignal) { // the last one is "just in case"
  actualSignal = Controller.Config.MaxOutput // or minimum
} else {
  actualSignal = Controller.State.ControlSignal
}

Not sure if it should be considered an issue, but I think it's worth mentioning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.