Documentation ¶
Overview ¶
Package control package for feedback loop controls
Index ¶
- type Block
- type BlockConfig
- type Config
- type Control
- type Controllable
- type Loop
- func (l *Loop) BlockList(ctx context.Context) ([]string, error)
- func (l *Loop) ConfigAt(ctx context.Context, name string) (BlockConfig, error)
- func (l *Loop) Frequency(ctx context.Context) (float64, error)
- func (l *Loop) GetConfig(ctx context.Context) Config
- func (l *Loop) OutputAt(ctx context.Context, name string) ([]Signal, error)
- func (l *Loop) SetConfigAt(ctx context.Context, name string, config BlockConfig) error
- func (l *Loop) Start() error
- func (l *Loop) Stop()
- type Signal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶ added in v0.0.8
type Block interface { // Reset will reset the control block to initial state. Returns an error on failure Reset(ctx context.Context) error // Next calculate the next output. Takes an array of float64 , a delta time returns True and the output value on success false otherwise Next(ctx context.Context, x []Signal, dt time.Duration) ([]Signal, bool) // UpdateConfig update the configuration of a pre-existing control block returns an error on failure UpdateConfig(ctx context.Context, config BlockConfig) error // Output returns the most recent valid value, useful for block aggregating signals Output(ctx context.Context) []Signal // Config returns the underlying config for a Block Config(ctx context.Context) BlockConfig }
Block interface for a control block.
type BlockConfig ¶ added in v0.0.8
type BlockConfig struct { Name string `json:"name"` // Control Block name Type controlBlockType `json:"type"` // Control Block type Attribute config.AttributeMap `json:"attributes"` // Internal block configuration DependsOn []string `json:"depends_on"` // List of blocks needed for calling Next }
BlockConfig configuration of a given block.
type Config ¶ added in v0.0.8
type Config struct { Blocks []BlockConfig `json:"blocks"` // Blocks Control Block Config Frequency float64 `json:"frequency"` // Frequency loop Frequency }
Config configuration of the control loop.
type Control ¶
type Control interface { // OutputAt returns the Signal at the block name, error when the block doesn't exist OutputAt(ctx context.Context, name string) ([]Signal, error) // ConfigAt returns the Configl at the block name, error when the block doesn't exist ConfigAt(ctx context.Context, name string) (BlockConfig, error) // BlockList returns the list of blocks in a control loop error when the list is empty BlockList(ctx context.Context) ([]string, error) // Frequency returns the loop's frequency Frequency(ctx context.Context) (float64, error) // Start starts the loop Start() error // Stop stops the loop Stop() }
Control control interface can be used to interfact with a control loop to query signals, change config, start/stop the loop etc...
type Controllable ¶
type Controllable interface { // SetPower set the power and direction of the motor SetPower(ctx context.Context, power float64, extra map[string]interface{}) error // GetPosition returns the current encoder count value GetPosition(ctx context.Context, extra map[string]interface{}) (float64, error) }
Controllable controllable type for a DC motor.
type Loop ¶ added in v0.0.8
type Loop struct {
// contains filtered or unexported fields
}
Loop holds the loop config.
func (*Loop) BlockList ¶ added in v0.0.8
BlockList returns the list of blocks in a control loop error when the list is empty.
func (*Loop) ConfigAt ¶ added in v0.0.8
ConfigAt returns the Configl at the block name, error when the block doesn't exist.
func (*Loop) OutputAt ¶ added in v0.0.8
OutputAt returns the Signal at the block name, error when the block doesn't exist.
func (*Loop) SetConfigAt ¶ added in v0.0.8
SetConfigAt returns the Configl at the block name, error when the block doesn't exist.
type Signal ¶
type Signal struct {
// contains filtered or unexported fields
}
Signal holds any data passed between blocks.
func (*Signal) GetSignalValueAt ¶
GetSignalValueAt returns the value of the signal at an index, threadsafe.
func (*Signal) SetSignalValueAt ¶
SetSignalValueAt set the value of a signal at an index, threadsafe.