-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollerconfiguration.go
More file actions
49 lines (41 loc) · 1.46 KB
/
controllerconfiguration.go
File metadata and controls
49 lines (41 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package parallel
// ControllerConfiguration types contain the information necessary to calculate
// values from a PID controller.
type ControllerConfiguration struct {
// The proportional term coefficient.
Kp float64
// The integral term coefficient.
Ki float64
// The derivative term coefficient.
Kd float64
// The error function response.
ErrorResponse float64
// The output signal response.
OutputResponse float64
}
// NewControllerConfiguration creates and returns a new controller
// configuration.
func NewControllerConfiguration(kp float64, ki float64, kd float64, errorResponse float64, outputResponse float64) *ControllerConfiguration {
return &ControllerConfiguration{
Kp: kp,
Ki: ki,
Kd: kd,
ErrorResponse: errorResponse,
OutputResponse: outputResponse,
}
}
// newControllerConfigurationFromConfiguration creates and returns a new
// controller configuration from another configuration.
func newControllerConfigurationFromConfiguration(configuration *ControllerConfiguration) *ControllerConfiguration {
return &ControllerConfiguration{
Kp: configuration.Kp,
Ki: configuration.Ki,
Kd: configuration.Kd,
ErrorResponse: configuration.ErrorResponse,
OutputResponse: configuration.OutputResponse,
}
}
// Copy returns a copy of the configuration.
func (c *ControllerConfiguration) Copy() *ControllerConfiguration {
return newControllerConfigurationFromConfiguration(c)
}